preeny

preeny.一个有用的preload集合

github项目地址:https://github.com/zardus/preeny

Preeny有以下模块:

NameSummary
dealarmDisables alarm() 
deforkDisables fork()
deptraceDisables ptrace()
derandDisables rand() and random()
desigactDisables sigaction()
desockChannels socket communication to the console
desock_dupChannels socket communication to the console (simpler method)
ensockThe opposite of desock -- like an LD_PRELOAD version of socat!
desrandDoes tricky things with srand() to control randomness.
mallocwatchWhen ltrace is inconvenient, mallocwatch provides info on heap operations.
writeoutSome binaries write() to fd 0, expecting it to be a two-way socket. This makes that work (by redirecting to fd 1).
patchPatches programs at load time.
startstopSends SIGSTOP to itself on startup, to suspend the process.

Preeny安装:

$ git clone https://github.com/zardus/preeny.git 

$ apt-get install libini-config3 libini-config-dev 

$ cd preeny 

$ make

在64位x86主机上构建32位x86 preeny

$ CFLAGS = -m32 make

使用方法:

让程序内的sock(),fork(),alarm()函数失效

LD_PRELOAD=x86_64-linux-gnu/desock.so:x86_64-linux-gnu/defork.so:x86_64-linux-gnu/dealarm.so ~/code/security/codegate/2015/rodent/rodent

去随机化:

derand.so 覆盖 rand() and random()
# this will return 42 on each rand() call  每一次rand()都返回42
LD_PRELOAD=x86_64-linux-gnu/derand.so tests/rand

# this will return 1337 on each rand() call #每一次rand()都返回1337
RAND=1337 LD_PRELOAD=x86_64-linux-gnu/derand.so tests/rand
desrand.so 可以覆盖 srand 
# this simply sets the seed to 42  #rand函数种子变为42 (默认设置为42)
LD_PRELOAD=x86_64-linux-gnu/desrand.so tests/rand

# this sets the seed to 1337 #设置seed为1337
SEED=1337 LD_PRELOAD=x86_64-linux-gnu/desrand.so tests/rand

# this sets the seed to such that the first "rand() % 128" will be 10 #设置mod为128 并且第一次rand()%128 的值设置为10
WANT=10 MOD=128 LD_PRELOAD=x86_64-linux-gnu/desrand.so tests/rand

# finally, this makes the *third* "rand() % 128" be 10   #设置mod为128 并且第三次rand()%128 的值设置为10
SKIP=2 WANT=10 MOD=128 LD_PRELOAD=x86_64-linux-gnu/desrand.so tests/rand

下面这两功能我还没用过:与fuzz相关

De-socketing

Certain tools (such as American Fuzzy Lop, for example) are unable to handle network binaries. Preeny includes two "de-socketing" modules. desock.so neuters socket(), bind(), listen(), and accept(), making it return sockets that are, through hackish ways, synchronized to stdin and stdout. desock_dup.so is a simpler version for programs that dup accepted sockets over file descriptors 0, 1, and 2.

A discussion of the different ways to de-socket program, and why Preeny does it the way it does, can be found here.

En-socketing

You can also use preeny to turn a normal binary into a socket binary! Just set the PORT environment variable (default is 1337) and preload ensock.so!

Patch

可以利用patch.so修改指定位置的值

# tests/hello      有一个简单的输出Hello world的程序
Hello world!
# cat hello.p      编写.p文件 指定源字符 字符地址 目地字符
[hello]
address=0x4005c4
content='4141414141'

[world]
address=0x4005ca
content='6161616161'
# PATCH="hello.p" LD_PRELOAD=x86_64-linux-gnu/patch.so tests/hello 
--- section hello in file hello.p specifies 5-byte patch at 0x4005c4
--- section world in file hello.p specifies 5-byte patch at 0x4005ca
AAAAA aaaaa!

  

转载于:https://www.cnblogs.com/elvirangel/articles/7857611.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值