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.

(gdb)<br />

0x8048344 : 0xb0<br />

(gdb)<br />

0x8048345 : 0x01<br />

(gdb)<br />

0x8048346 : 0xcd<br />

(gdb)<br />

0x8048347 : 0x80<br />

(gdb)<br />

Agora iremos montá-lo denovo, somente com os códigos em<br />

hexadecimal.:<br />

shellcode/hexawrite2.c<br />

/*<br />

* Shellcode pronto em hexadecimal.<br />

* Imprime a string "MOTDLabs" na tela.<br />

* by IP_FIX .<br />

* MotdLabs .<br />

* Compilação: # gcc -o hexawrite2 hexawrite2.c<br />

*/<br />

#include <br />

char shellcode[] = "\x31\xc0" /* xor %eax, %eax */<br />

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

"\xb3\x01" /* mov $0x1, %bl */<br />

"\x6a\x0a" /* push $0x0A */<br />

"\x68\x4c\x61\x62\x73" /* push $0x7362614C */<br />

"\x68\x4d\x4f\x54\x44" /* push $0x44544F4D */<br />

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

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

"\xb2\x0a" /* mov $0xa, %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 />

main() {<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/hexawrite2.c<br />

72

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

Saved successfully!

Ooh no, something went wrong!