Madmouse

encrypted binary integrity chacking with anti debug POC

Jun 3rd, 2015
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;// ------------------------------------------------------------------------------
  2. ;// THE BEER-WARE LICENSE (Revision 43):
  3. ;// <aaronryool@gmail.com> wrote this file. As long as you retain this notice you
  4. ;// can do whatever you want with this stuff. If we meet some day, and you think
  5. ;// this stuff is worth it, you can buy me a beer in return
  6. ;// ------------------------------------------------------------------------------
  7.  
  8. ; for a full write up on this, go here:
  9. ; https://www.hackthissite.org/forums/viewtopic.php?f=156&t=12300&p=88305
  10.  
  11. [bits 32]
  12. section .text
  13. global _start
  14.  
  15. org 0x08048000
  16. ehdr:                                      ; Elf32_Ehdr
  17.     db 0x7F, "ELF", 1, 1, 1, 0         ;   e_ident
  18.     times 8 db      0
  19.     dw 2                               ;   e_type
  20.     dw 3                               ;   e_machine
  21.     dd 1                               ;   e_version
  22.     dd _start                          ;   e_entry
  23.     dd phdr - $$                       ;   e_phoff
  24.     dd 0                               ;   e_shoff
  25.     dd 0                               ;   e_flags
  26.     dw ehdrsize                        ;   e_ehsize
  27.     dw phdrsize                        ;   e_phentsize
  28.     dw 1                               ;   e_phnum
  29.     dw 0                               ;   e_shentsize
  30.     dw 0                               ;   e_shnum
  31.     dw 0                               ;   e_shstrndx
  32.     ehdrsize equ $ - ehdr
  33.  
  34. phdr:                                      ; Elf32_Phdr
  35.     dd 1                               ;   p_type
  36.     dd 0                               ;   p_offset
  37.     dd $$                              ;   p_vaddr
  38.     dd $$                              ;   p_paddr
  39.     dd filesize                        ;   p_filesz
  40.     dd filesize                        ;   p_memsz
  41.     dd 7                               ;   p_flags
  42.     dd 0x1000                          ;   p_align
  43.     phdrsize equ $ - phdr
  44. _start:
  45.     jmp code
  46. begin:
  47.     pop esi             ; pop the address of our data
  48.     mov ecx, 36         ; set loop count to the size of the encrypted data
  49.     xor eax, eax
  50.     xor ebx, ebx
  51. decode:
  52.     mov al, byte [_start+ebx]       ; load character from key into al
  53.     xor byte [esi], al              ; xor the key with the encrypted code
  54.     inc esi                         ; increment our address
  55.     inc ebx                         ; increment our secondary counter
  56. loop decode
  57.     jmp hello
  58.     db 0x9c, 0xc8, 0x96, 0x5a, 0xb4, 0x8e, 0x5f ; garbage filler because the key code is smaller than 36 bytes
  59. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  60. ; encrypted code:
  61. code:
  62.     call begin
  63. hello:
  64.     db 0x00,0x0e,0x07,0x88,0xe4,0x31,0xdb,0x31
  65.     db 0xe3,0x70,0x35,0x68,0x8b,0x31,0x58,0x4d
  66.     db 0x84,0xe3,0x21,0xee,0xac,0xbc,0x1d,0x0b
  67.     db 0x83,0x69,0xf0,0xa4,0xf9,0x7a,0xc3,0xe1
  68.     db 0x2d,0x84,0xb8,0xf5
  69. ;_start:
  70. ;   jmp hi
  71. ;main:
  72. ;   pop ecx
  73. ;   xor eax, eax
  74. ;   xor ebx, ebx
  75. ;   xor edx, edx
  76. ;   mov al, 0x4
  77. ;   mov bl, 1
  78. ;   mov dl, 12
  79. ;   int 0x80
  80. ;   jmp end
  81. ;hi:
  82. ;   call main
  83. ;   db "hello world", 0xa
  84. ;end:
  85.  
  86. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  87. ; exit
  88.     xor ebx, ebx
  89.     xor eax, eax
  90.     inc eax
  91.     int 0x80
  92.  
  93. filesize equ $ - $$
Add Comment
Please, Sign In to add comment