Advertisement
emin_int11

debug malware

Nov 10th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =Yazdığım kiçik dokumentasiya. Öz hazırladıqım malware-da istifadə etdiyim anti-dbg texnikalarından biridir.=
  2. Windows NT data structure TIB ==> PEB (opaque type)  
  3. PEB addr can be accessed as an offset of segment register FS locate == > the addr at TIB (Thread environment block data structure) in import table offset 0x30 (30h) linear address of PEB
  4.  
  5. img diagram: http://1.bp.blogspot.com/-qu8V9tv1p2I/T9Hby63yfAI/AAAAAAAAACA/wlwHTQMkgmU/s1600/finding_kernel32.png
  6.  
  7. Receiving PEB (pointer) addr from TIB
  8. INSTRUCTION (1)
  9.  
  10. http://en.wikipedia.org/wiki/Win32_Thread_Information_Block#Contents_of_the_TIB_.2832-bit_Windows.29
  11.  
  12. Position    Length  Windows Versions    Description
  13. FS:[0x30]   4   NT          Linear address of Process Environment Block (PEB)
  14.  
  15.  
  16. The address of PEB movement with mov instruction
  17. INSTRUCTION(2)
  18.     In the PEB settled BeingDebugged field = offset 0x0002
  19.  
  20. Ref:
  21. blog.rewolf.pl/blog/wp-content/uploads/2013/03/PEB_Evolution.pdf
  22.  
  23. x86 offset  Field Name          x64 offset
  24. offset:bit(len)                 offset:bit(len)
  25. 0x0002      unsigned char,BeingDebugged     0x0002
  26.  
  27.  
  28. ======================================================================================================
  29. used extra segment register : FS +==> FS are commonly used by OS kernels to access thread-specific memory.In windows, the FS register is used to manage thread-specific memory.
  30.  
  31. asm (intel) syntax
  32.  
  33. mov EAX, FS:[0x30] #1
  34. mov EAX,[EAX+2] #2
  35.  
  36. C my malware source :)
  37.  
  38. #include<stdio.h>
  39. void *antideb()
  40. {
  41.     void *pTib;
  42. //AT&T syntax
  43.     __asm__("movl %%fs:0x30, %%eax" : : : );
  44.     __asm__("movl 2(%%eax), %%eax" : "=r" (pTib) : : );
  45.     return pTib;
  46. }
  47.  
  48. void main(){
  49.        
  50.     printf("%x\n",antideb());  
  51.     //validation pointer and kayfa davam :)
  52. }
  53.  
  54. debug screen :?
  55.  
  56. http://f-picture.net/lfp/s004.radikal.ru/i205/1411/88/20ffac09e12d.png/htm
  57.  
  58.  
  59. #eminghuliev,@st1ll_di3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement