Advertisement
Guest User

Untitled

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