Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. void printHex(const char *s);
  5.  
  6. //Assemlbly comments in NASM syntax.
  7. char *shellcode="\x31\xc0" //xor eax, eax
  8. "\xb0\x68" //movb al, 'h'
  9. "\x50" //push eax
  10. "\x31\xc0" //xor eax, eax
  11. "\x68\x2f\x62\x61\x73" //push '/bas'
  12. "\x68\x2f\x62\x69\x6e" //push '/bin'
  13. "\x89\xe3" //mov ebx, esp
  14. "\x50" //push eax
  15. "\x50" //push eax
  16. "\x50" //push eax
  17. "\x53" //push ebx
  18. "\x89\xe1" //mov ecx, esp
  19. "\x50" //push eax
  20. "\x66\x68\x2d\x63" //pushw '-c'
  21. "\x89\xe2" //mov edx, esp
  22. "\x89\x51\x4" //mov [ecx+4], edx
  23. "\x50" //push eax
  24. "\x66\x68\x78\x74" //pushw 'xt'
  25. "\x68\x73\x74\x2e\x74" //push 'st.t'
  26. "\x68\x74\x20\x74\x65" //push 't te'
  27. "\x68\x73\x3b\x63\x61" //push 's;ca'
  28. "\x68\x78\x74\x3b\x6c" //push 'xt;l'
  29. "\x68\x73\x74\x2e\x74" //push 'st.t'
  30. "\x68\x74\x3e\x74\x65" //push 't>te'
  31. "\x68\x20\x74\x65\x73" //push ' tes'
  32. "\x68\x65\x63\x68\x6f" //push 'echo'
  33. "\x89\xe2" //mov edx, esp
  34. "\x89\x51\x8" //mov [ecx+8], edx
  35. "\x50" //push eax
  36. "\x89\xe2" //mov edx, esp
  37. "\xb0\x0b" //mov al, 11
  38. "\xcd\x80"; //int $0x80
  39.  
  40. int main() {
  41.   printHex(shellcode);
  42.   printf("%d Bytes.\n",strlen(shellcode));
  43.   int (*ret)() = (int(*)())shellcode;
  44.   ret();
  45. }
  46.  
  47. void printHex(const char *s) {
  48.   while (*s)
  49.     printf("\\x%02x", (unsigned int) *s++ & 0xff);
  50.   printf("\n");
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement