阅 读 文 章

精通solaris的,来讨论讨论solaris sparc的共享库重定向技术

[来源:网上转载 (http://www.chinaunix.net) | 作者:网友(e4gle) | 时间:2007-05-27 | 浏览:人次 ]


Shared Library Injection and Redirection 

---| 简介 

Phrack 56-9 Backdooring binary objects 一文中介绍了利用BFD向Shared Library中插入代码,并修改Shared Library中的一个函数地址指向插入的代码. 但是,插入的代码必须以汇编书写,并且要手工计算一些地址. 本文描述如何在SPARC Solaris 8下实现这种技术. 而且进一步做了重定向工作,使插入代码可以用 c 书写. 考虑到BFD接口复杂,文档混乱, 我们不使用BFD做ELF文件操作. 

---| 准备工作 

本文中程序的编译和调试都在如下环境进行: 
bash-2.03$ uname -a 
SunOS LabSolaris 5.8 Generic_108528-09 sun4u sparc SUNW,Ultra-5_10 
bash-2.03$ gcc -v 
Reading specs from /opt/gnu32/lib/gcc-lib/sparc-sun-solaris2.8/3.0/specs 
Configured with: ./configure --prefix=/opt/gnu32 : (reconfigured) ./configure --prefix=/opt/gnu32 --enable-languages=c,c++ 
Thread model: posix 
gcc version 3.0 
bash-2.03$ objdump -V 
GNU objdump 2.11.2 
Copyright 1997, 98, 99, 2000, 2001 Free Software Foundation, Inc. 
This program is free software&#59; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. 

需要准备如下程序: 
/* haha.c */ 
#include <stdio.h>; 
void haha(void) 

printf(&quot;haha\n&quot;)&#59; 


/* huhu.c */ 
void huhu(void) 

printf(&quot;huhu\n&quot;)&#59; 

编译成动态库: 
bash-2.03$ gcc -fPIC -G -nostdlib -o libtst.so haha.c huhu.c 

再准备如下 c 程序: 
/* hehe.c */ 
void hehe(void) 

haha()&#59; 

编译成 object 文件: 
bash-2.03$ gcc -fpic -c hehe.c 

准备如下测试程序: 
/* t.c */ 
int main(int argc,char **argv) 

huhu()&#59; 
return 0&#59; 


---| SPARC下的ELF 

一个ELF动态库(SPARC)通常包括以下区(Section): 
.hash : hash table 
.interp: ELF interpreter 
.dynsym : dynamic symbol table 
.dynstr : dynamic string table 
.rela.* : relocation section 
.text : code section 
.rodata : readonly data section 
上面几个区共同组成了代码段(text segment),在内存中映象可读,可执行, 
论坛热门帖子: [lch203] 写得蛮好的linux学习笔记(10-21)
[黑马制造] 学习java的30个目标(10-19)
[笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19)
[udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18)
[沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18)
TAG标签: 定向 技术 共享 精通 #59 quot nquot sym- 符号 插入

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.