libcef
(Chromium嵌入式框架)与GLIBC_2.13
(Debian测试版中的eglibc可以提供)配合良好,但需要从GLIBC_2.15
中获得一个麻烦的额外函数(这是eglibc无法提供的):$ readelf -s libcef.so | grep -E "@GLIBC_2\.1[4567]"
1037: 00000000 0 FUNC GLOBAL DEFAULT UND __fdelt_chk@GLIBC_2.15 (49)
2733: 00000000 0 FUNC GLOBAL DEFAULT UND __fdelt_chk@@GLIBC_2.15
我的攻击计划是LD_PRELOAD
一个提供这些函数的Shim库,但这似乎不起作用。我真的想避免安装GLIBC_2.17
(因为它在Debian experimental中;即使是Debian sid仍然有GLIBC_2.13
)。
这是我尝试过的东西。
fdelt_chk.c
基本上是从GNU C库偷来的:
#include <sys/select.h>
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
unsigned long int
__fdelt_chk (unsigned long int d)
{
if (d >= FD_SETSIZE)
__chk_fail ();
return d / __NFDBITS;
}
strong_alias (__fdelt_chk, __fdelt_warn)
我的 Versions
脚本如下所示:
GLIBC_2.15 {
__fdelt_chk; __fdelt_warn;
};
然后我按照以下方式构建库:
$ gcc -m32 -c -fPIC fdelt_chk.c -o fdelt_chk.o
$ gcc -m32 -shared -nostartfiles -Wl,-s -Wl,--version-script Versions -o fdelt_chk.so fdelt_chk.o
不过,如果我再运行Steam(需要添加许多额外内容才能使其正常工作),加载器仍然无法找到该符号:
% LD_LIBRARY_PATH="/home/tinctorius/.local/share/Steam/ubuntu12_32" LD_PRELOAD=./fdelt_chk.so:./steamui.so ./steam
./steam: /lib/i386-linux-gnu/i686/cmov/libc.so.6: version `GLIBC_2.15' not found (required by /home/tinctorius/.local/share/Steam/ubuntu12_32/libcef.so)
然而,版本符号也由我刚刚构建的.so
提供:
% readelf -s fdelt_chk.so
Symbol table '.dynsym' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FUNC GLOBAL DEFAULT UND __chk_fail@GLIBC_2.3.4 (3)
2: 0000146c 0 NOTYPE GLOBAL DEFAULT ABS _edata
3: 0000146c 0 NOTYPE GLOBAL DEFAULT ABS _end
4: 00000310 44 FUNC GLOBAL DEFAULT 11 __fdelt_warn@@GLIBC_2.15
5: 00000310 44 FUNC GLOBAL DEFAULT 11 __fdelt_chk@@GLIBC_2.15
6: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.15
7: 0000146c 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
此时,我不知道我能做什么来欺骗加载器(是谁?)选择我的符号。我是否完全朝着正确的方向前进?
=all
并检查rtld(ld-linux.so)如何搜索__fdelt
和@@GLIBC_2.15
。 - osgx/lib/i386-linux-gnu/i686/cmov/libc.so.6
并立即放弃。也许我需要为fdelt_chk.so选择一个合适的soname... - user824425-Wl,-soname,libc.so.6
会导致一切崩溃,因为现在它不会查找除了我的库之外的其他库。是否可能通过绝对soname导入实际的libc
,并重新导出所有其他符号? - user824425