首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Linux频道
Google
首页 入门 Linux编程 系统管理 网络管理 Linux认证 Unix/BSD Linux数据库 Linux集群 Linux手册 Linux下载 Ubuntu 论坛 专题 RSS
您现在的位置: 中国IT实验室 >> Linux >> 系统管理 >> 系统管理 >> 正文

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

    R_386_GLOB_DAT 6 word32 S 通常我们看到的是R_386_JMP_SLOT这种类型的R_386_GLOB_DAT This relocation type is used to set a global offset table entry to the addressof the specified symbol。 The special relocation type allows one to determinethe correspondence between symbols and global offset table entries。

* R_386_GLOB_DAT

这种重定位类型用于设置一个全局偏移表入口为指定符号的地址。该特定的重定位 (alert7大侠译)类型允许你决定符号和全局偏移表入口之间的一致性。

S This means the value of the symbol whose index resides in the relocation entry。

* S

表示索引驻留在重定位入口处的符号值。

[19] 。got PROGBITS 0804a290 001290 000058 04 WA 0 0 4

[20] 。dynamic DYNAMIC 0804a2e8 0012e8 0000c8 08 WA 5 0 4

offset=0804a2e4

实际上这个重定位标示的偏移是got节的最后一个入口,并设置这个入口的值为__gmon_start__的这个符号的地址。

下面做一个小测试实际看一下:

/*test。c*/

int __gmon_start__(){return 0;}

int main(){return __gmon_start__();}

EOF

[wujian@redhat72 elf_door]$ readelf -a test

Section Headers:

[Nr] Name Type Addr Off Size ES Flg Lk Inf Al

[。。]

[ 8] 。rel。dyn REL 08048294 000294 000008 08 A 4 0 4

[ 9] 。rel。plt REL 0804829c 00029c 000020 08 A 4 b 4

[。。]

[12] 。text PROGBITS 08048330 000330 000160 00 AX 0 0 16

[19] 。got PROGBITS 080494dc 0004dc 000020 04 WA 0 0 4

[20] 。dynamic DYNAMIC 080494fc 0004fc 0000c8 08 WA 5 0 4

----------------------------------------------------------------

Relocation section '。rel。dyn' at offset 0x294 contains 1 entries:

Offset Info Type Symbol's Value Symbol's Name

080494f8 00606 R_386_GLOB_DAT 08048430 __gmon_start__ offset=0x080494f8实际是got的最后一个入口偏移

----------------------------------------------------------------

Relocation section '。rel。plt' at offset 0x29c contains 4 entries:

Offset Info Type Symbol's Value Symbol's Name

080494e8 00107 R_386_JUMP_SLOT 080482e4 __register_frame_info

080494ec 00207 R_386_JUMP_SLOT 080482f4 __deregister_frame_info

080494f0 00307 R_386_JUMP_SLOT 08048304 __libc_start_main

----------------------------------------------------------------

Symbol table '。dynsym' contains 7 entries:

Num: Value Size Type Bind Vis Ndx Name

3: 08048304 202 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2。0">__libc_start_main@GLIBC_2。0 (2)

6: 08048430 10 FUNC GLOBAL DEFAULT 12 __gmon_start__

rel。dyn实际重定位对应。dynsym 本来__gmon_start__不应该出现在这里,对应与上面的解释

10个字节,函数类型,value为0x8048430,关联与[12]。text

----------------------------------------------------------------

Symbol table '。symtab' contains 77 entries:

Num: Value Size Type Bind Vis Ndx Name

[。。] 实际上__gmon_start不需要重定位

67: 08048304 202 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_2。0">__libc_start_main@@GLIBC_2。0

76: 08048430 10 FUNC GLOBAL DEFAULT 12 __gmon_start__

------------------------------------------------------------------

[wujian@redhat72 elf_door]$ gdb -q test

(gdb) disas main

Dump of assembler code for function main:

0x804843c : push %ebp

0x804843d : mov %esp,%ebp

0x804843f : sub $0x8,%esp

0x8048442 : call 0x8048430 <__gmon_start__>

0x8048447 : mov %eax,%eax

0x8048449 : mov %eax,%eax

0x804844b : leave

0x804844c : ret

0x804844d : lea 0x0(%esi),%esi

End of assembler dump。

(gdb) b *0x8048430

Breakpoint 1 at 0x8048430

(gdb) r

Starting program: /home/wujian/share/elf_door/test

Breakpoint 1, 0x08048430 in __gmon_start__ ()

(gdb) disas

Dump of assembler code for function __gmon_start__:

0x8048430 <__gmon_start__>: push %ebp

0x8048431 <__gmon_start__+1>: mov %esp,%ebp

0x8048433 <__gmon_start__+3>: mov $0x0,%eax

0x8048438 <__gmon_start__+8>: pop %ebp

0x8048439 <__gmon_start__+9>: ret

0x804843a <__gmon_start__+10>: mov %esi,%esi

End of assembler dump。

(gdb) x/x 0x80494f8 ---〉got偏移地址offset处的入口值修改为该符号的地址

0x80494f8 <_GLOBAL_OFFSET_TABLE_+28>: 0x08048430

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

【责编:Youping】
中国IT教育
相关产品和培训
文章评论
 友情推荐链接
 专题推荐

 ·防范Linux病毒 打造没有病毒的乐土…
 ·Linux Shell编程实用指南…
 ·Linux日志分析与管理
 ·揭密Linux内存管理
 ·邮件服务Sendmail应用配置
 ·Linux 安全管理…
 ·Linux 下DNS服务器架设攻略…
 ·Linux 下的路由的配置与应用…
 ·专题:Apache实用手册
 ·全面剖析Linux文件系统
 今日更新
 认证培训
 频道精选
 Windows频道导航