Madmouse

A hello world for encrypted binary obfuscation

Jan 28th, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; A hello world for encrypted binary obfuscation
  3. ;   Brought to you by MadMouse
  4. ; Play like this:
  5. ;   nasm -f elf64 hello.s -o hello.o
  6. ;   ld -N hello.o -o hello
  7.  
  8.  
  9. [bits 64]
  10. section .text
  11. global _start
  12. _start:
  13.     call main
  14.     ; key data
  15.     db 0x7b,0xcb,0xdd,0x3e,0xbe,0x0b,0x43,0xb4,0x99,0x6b,0xa7,0xbe
  16.     db 0x0e,0x27,0x26,0xb0,0xdb,0x98,0xea,0x86,0xdf,0x20,0x68,0x15
  17.     db 0x2f,0x9b,0x4e,0x5c,0x04,0x39,0x20,0x03,0xdb,0xa5,0x7c,0xcb
  18.     db 0xa8,0x22
  19.     ; encrypted code:
  20.     db 0x93,0xc7,0xdd,0x3e,0xbe,0x63,0x26,0xd8,0xf5,0x04,0x87,0xc9
  21.     db 0x61,0x55,0x4a,0xd4,0xd1,0xc6,0x5a,0xd8,0x6f,0x21,0x28,0x9d
  22.     db 0xe8,0x29,0x42,0x53,0x01,0x89,0x1c,0x4b,0xea,0x5a,0x73,0xce
  23.     db 0xa8,0x09
  24.  
  25. main:
  26.     pop rsi         ; pop the address of our data
  27.     mov cl, 38      ; set loop count to the size of the encrypted data
  28. decode:
  29.     mov al, byte [rsi]  ; load character from key into al
  30.     xor byte [rsi+38], al   ; xor the key with the encrypted code
  31.     inc rsi         ; increment our address
  32. loop decode
  33.     jmp rsi         ; jump into our decrypted code :D
Advertisement
Add Comment
Please, Sign In to add comment