Madmouse

DICK STATUS opaque predicate binary obfuscation

Jan 30th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1. // play like this lol:
  2. // $ gcc -fno-stack-protector -z execstack lol.c -o lol
  3. /////////////////////////////////////////////////////////
  4. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. //; I SPEAK TEH TRUFF
  6. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7. //_start:
  8. //  xor eax, eax
  9. //  mov al, 0x1
  10. //  xor rdi, rdi
  11. //  ret
  12. //
  13. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14. //; decoder foo
  15. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. //_start:
  17. //  mov rcx, rsi    ; move size argument into rcx for the loop
  18. //  mov rsi, rdi    ; move the the text pointer to rsi
  19. //  xor rax, rax    ; clear out registers
  20. //  xor rdi, rdi
  21. //decode:               ; decode text
  22. //  xor byte [rsi], 0xFF
  23. //  inc rsi
  24. //loop decode
  25. //  xor rax, rax
  26. //  ret
  27.  
  28.  
  29. typedef unsigned char by;
  30.  
  31. main(m)
  32. {
  33.     // functional shellcode that takes encrypted shellcode and encodes / decodes it
  34.     m="\x48\x89\xf1\x48\x89\xfe\x48\x31\xc0"\
  35.       "\x48\x31\xd2\x48\x31\xff\x80\x36\xff"\
  36.       "\x48\xff\xc6\xe2\xf8\xc3";
  37.    
  38.     // encrypted opaque predicate
  39.     by e[]="\xce\x3f\x4f\xfe\xb7\xce\x00\x3c";
  40.     ((void(*)(void*,int))m)(e,8); // decode the opaque function
  41.  
  42.     // check for always true, and re encode the shellcode
  43.     if(((int(*)())e)()+((int(*)(void*,int))m)(e,8))
  44.         puts("I spaek teh truff");      // say something funny
  45. }
Advertisement
Add Comment
Please, Sign In to add comment