Advertisement
yorath

ceedoHookFunc

Sep 22nd, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 6FD0C3B8 -> 6FD13AA0(6FD13980) -> 6FD11B1A(6FD11AD0) -> 6FD36053(6FD35FD0) -> 6FD35F5E(6FD35EE0) -> 6FD3643B(6FD363D0) -> (6FD3E050)
  2.  
  3. // NtMapViewOfSection
  4. 00150000 55              push    ebp
  5. 00150001 8bec            mov     ebp,esp
  6. 00150003 ff752c          push    dword ptr [ebp+2Ch]
  7. 00150006 ff7528          push    dword ptr [ebp+28h]
  8. 00150009 ff7524          push    dword ptr [ebp+24h]
  9. 0015000c ff7520          push    dword ptr [ebp+20h]
  10. 0015000f ff751c          push    dword ptr [ebp+1Ch]
  11. 00150012 ff7518          push    dword ptr [ebp+18h]
  12. 00150015 ff7514          push    dword ptr [ebp+14h]
  13. 00150018 ff7510          push    dword ptr [ebp+10h]
  14. 0015001b ff750c          push    dword ptr [ebp+0Ch]
  15. 0015001e ff7508          push    dword ptr [ebp+8]
  16. 00150021 e88c010000      call    001501b2       // go back
  17. 00150026 85c0            test    eax,eax
  18. 00150028 753f            jne     00150069
  19. 0015002a 8b4510          mov     eax,dword ptr [ebp+10h]
  20. 0015002d 8b00            mov     eax,dword ptr [eax]
  21. 0015002f 3d0000807c      cmp     eax,7C800000h      // Hook BaseDllInitialize
  22. 00150034 7414            je      0015004a
  23. 00150036 3d0000d06f      cmp     eax,6FD00000h
  24. 0015003b 752a            jne     00150067
  25. 0015003d 05bcb30700      add     eax,7B3BCh
  26. 00150042 c70000001600    mov     dword ptr [eax],160000h
  27. 00150048 eb1d            jmp     00150067
  28. 0015004a e85f010000      call    001501ae
  29. 0015004f 2d4f000000      sub     eax,4Fh
  30. 00150054 8d9024060000    lea     edx,[eax+624h]
  31. 0015005a 0502020000      add     eax,202h
  32. 0015005f ff32            push    dword ptr [edx]
  33. 00150061 50              push    eax
  34. 00150062 e8f3000000      call    0015015a
  35. 00150067 33c0            xor     eax,eax
  36. 00150069 c9              leave
  37. 0015006a c22800          ret     28h
  38.  
  39. // Hook BaseDllInitialize
  40. 0015006d 55              push    ebp
  41. 0015006e 8bec            mov     ebp,esp
  42. 00150070 53              push    ebx
  43. 00150071 e838010000      call    001501ae
  44. 00150076 2d76000000      sub     eax,76h
  45. 0015007b 8bd8            mov     ebx,eax
  46. 0015007d 8d9024060000    lea     edx,[eax+624h]
  47. 00150083 52              push    edx
  48. 00150084 0507020000      add     eax,207h
  49. 00150089 ff32            push    dword ptr [edx]
  50. 0015008b 50              push    eax
  51. 0015008c e8c9000000      call    0015015a   // restore the original function
  52. 00150091 5a              pop     edx
  53. 00150092 ff7510          push    dword ptr [ebp+10h]
  54. 00150095 ff750c          push    dword ptr [ebp+0Ch]
  55. 00150098 ff7508          push    dword ptr [ebp+8]
  56. 0015009b ff12            call    dword ptr [edx]    // call BaseDllInitialize, jump to NtMapViewOfSection
  57. 0015009d 84c0            test    al,al
  58. 0015009f 7423            je      001500c4
  59. 001500a1 8d830c020000    lea     eax,[ebx+20Ch]
  60. 001500a7 badbae807c      mov     edx,7C80AEDBh
  61. 001500ac 50              push    eax
  62. 001500ad ffd2            call    edx        // LoadLibraryW
  63. 001500af 85c0            test    eax,eax
  64. 001500b1 740c            je      001500bf
  65. 001500b3 ba20c3d06f      mov     edx,6FD0C320h
  66. 001500b8 6a00            push    0
  67. 001500ba 6a01            push    1
  68. 001500bc 50              push    eax
  69. 001500bd ffd2            call    edx    // DllEntry
  70. 001500bf b801000000      mov     eax,1
  71. 001500c4 5b              pop     ebx
  72. 001500c5 c9              leave
  73. 001500c6 c20c00          ret     0Ch
  74.  
  75. // LdrLoadDll
  76. 001500c9 55              push    ebp
  77. 001500ca 8bec            mov     ebp,esp
  78. 001500cc 53              push    ebx
  79. 001500cd 56              push    esi
  80. 001500ce 57              push    edi
  81. 001500cf 8b5d10          mov     ebx,dword ptr [ebp+10h]
  82. 001500d2 85db            test    ebx,ebx
  83. 001500d4 7460            je      00150136
  84. 001500d6 0fb70b          movzx   ecx,word ptr [ebx]
  85. 001500d9 85c9            test    ecx,ecx
  86. 001500db 7459            je      00150136
  87. 001500dd 66b85c00        mov     ax,5Ch
  88. 001500e1 8b7b04          mov     edi,dword ptr [ebx+4]
  89. 001500e4 8d1439          lea     edx,[ecx+edi]
  90. 001500e7 8d7afe          lea     edi,[edx-2]
  91. 001500ea d1e9            shr     ecx,1
  92. 001500ec fd              std
  93. 001500ed f266af          repne scas word ptr es:[edi]
  94. 001500f0 7503            jne     001500f5
  95. 001500f2 83c702          add     edi,2
  96. 001500f5 fc              cld
  97. 001500f6 83c702          add     edi,2
  98. 001500f9 8bca            mov     ecx,edx
  99. 001500fb 2bcf            sub     ecx,edi
  100. 001500fd d1e9            shr     ecx,1
  101. 001500ff 81f90b000000    cmp     ecx,0Bh
  102. 00150105 752f            jne     00150136
  103. 00150107 8bf7            mov     esi,edi
  104. 00150109 bf48041500      mov     edi,150448h
  105. 0015010e 85ff            test    edi,edi
  106. 00150110 7424            je      00150136
  107. 00150112 66ad            lods    word ptr [esi]
  108. 00150114 6683f861        cmp     ax,61h
  109. 00150118 720a            jb      00150124
  110. 0015011a 6683f87a        cmp     ax,7Ah
  111. 0015011e 7704            ja      00150124
  112. 00150120 6683e820        sub     ax,20h
  113. 00150124 66af            scas    word ptr es:[edi]
  114. 00150126 750e            jne     00150136
  115. 00150128 e2e8            loop    00150112
  116. 0015012a e87f000000      call    001501ae
  117. 0015012f 05ed040000      add     eax,4EDh
  118. 00150134 8bd8            mov     ebx,eax
  119. 00150136 ff7514          push    dword ptr [ebp+14h]
  120. 00150139 53              push    ebx
  121. 0015013a ff750c          push    dword ptr [ebp+0Ch]
  122. 0015013d ff7508          push    dword ptr [ebp+8]
  123. 00150140 e895000000      call    001501da       // go back
  124. 00150145 85c0            test    eax,eax
  125. 00150147 740a            je      00150153
  126. 00150149 3b5d10          cmp     ebx,dword ptr [ebp+10h]
  127. 0015014c 7405            je      00150153
  128. 0015014e 8b5d10          mov     ebx,dword ptr [ebp+10h]
  129. 00150151 ebe3            jmp     00150136
  130. 00150153 5f              pop     edi
  131. 00150154 5e              pop     esi
  132. 00150155 5b              pop     ebx
  133. 00150156 c9              leave
  134. 00150157 c21000          ret     10h
  135.  
  136. // Hook function
  137. 0015015a 55              push    ebp
  138. 0015015b 8bec            mov     ebp,esp
  139. 0015015d 83c4f4          add     esp,0FFFFFFF4h
  140. 00150160 53              push    ebx
  141. 00150161 56              push    esi
  142. 00150162 57              push    edi
  143. 00150163 c745f805000000  mov     dword ptr [ebp-8],5
  144. 0015016a 8b450c          mov     eax,dword ptr [ebp+0Ch]
  145. 0015016d 8945fc          mov     dword ptr [ebp-4],eax
  146. 00150170 bbd0d6927c      mov     ebx,7C92D6D0h
  147. 00150175 8d45f4          lea     eax,[ebp-0Ch]
  148. 00150178 50              push    eax
  149. 00150179 6a04            push    4
  150. 0015017b 8d45f8          lea     eax,[ebp-8]
  151. 0015017e 50              push    eax
  152. 0015017f 8d45fc          lea     eax,[ebp-4]
  153. 00150182 50              push    eax
  154. 00150183 6aff            push    0FFFFFFFFh
  155. 00150185 ffd3            call    ebx
  156. 00150187 8b7508          mov     esi,dword ptr [ebp+8]
  157. 0015018a 8b7d0c          mov     edi,dword ptr [ebp+0Ch]
  158. 0015018d b905000000      mov     ecx,5
  159. 00150192 f3a4            rep movs byte ptr es:[edi],byte ptr [esi]
  160. 00150194 8d45f4          lea     eax,[ebp-0Ch]
  161. 00150197 50              push    eax
  162. 00150198 ff75f4          push    dword ptr [ebp-0Ch]
  163. 0015019b 8d45f8          lea     eax,[ebp-8]
  164. 0015019e 50              push    eax
  165. 0015019f 8d45fc          lea     eax,[ebp-4]
  166. 001501a2 50              push    eax
  167. 001501a3 6aff            push    0FFFFFFFFh
  168. 001501a5 ffd3            call    ebx
  169. 001501a7 5f              pop     edi
  170. 001501a8 5e              pop     esi
  171. 001501a9 5b              pop     ebx
  172. 001501aa c9              leave
  173. 001501ab c20800          ret     8
  174.  
  175.  
  176. 001501ae 8b0424          mov     eax,dword ptr [esp]
  177. 001501b1 c3              ret
  178.  
  179. // go back
  180. 001501b2 b86c000000      mov     eax,6Ch
  181. 001501b7 e949d37d7c      jmp     7c92d505
  182.  
  183.  
  184. 001501bc 92              xchg    eax,edx
  185. 001501bd 7ceb            jl      001501aa
  186. 001501bf 21807c5c0500    and     dword ptr [eax+55C7Ch],eax
  187. 001501c5 0000            add     byte ptr [eax],al
  188. 001501c7 d592            aadb    92h
  189. 001501c9 7c8c            jl      00150157
  190. 001501cb 97              xchg    eax,edi
  191. 001501cc 1200            adc     al,byte ptr [eax]
  192. 001501ce 2800            sub     byte ptr [eax],al
  193. 001501d0 0000            add     byte ptr [eax],al
  194. 001501d2 6c              ins     byte ptr es:[edi],dx
  195. 001501d3 97              xchg    eax,edi
  196. 001501d4 12b86c000000    adc     bh,byte ptr [eax+6Ch]
  197.  
  198. // Go back
  199. 001501da 686c020000      push    26Ch
  200. 001501df e9c4617e7c      jmp     7c9363a8
  201.  
  202. 001501e4 92              xchg    eax,edx
  203. 001501e5 7ceb            jl      001501d2
  204. 001501e7 21807c5c0500    and     dword ptr [eax+55C7Ch],eax
  205. 001501ed 00a363937c8c    add     byte ptr [ebx-73836C9Dh],ah
  206. 001501f3 97              xchg    eax,edi
  207. 001501f4 1200            adc     al,byte ptr [eax]
  208. 001501f6 2800            sub     byte ptr [eax],al
  209. 001501f8 0000            add     byte ptr [eax],al
  210. 001501fa 6c              ins     byte ptr es:[edi],dx
  211. 001501fb 97              xchg    eax,edi
  212. 001501fc 12686c          adc     ch,byte ptr [eax+6Ch]
  213. 001501ff 0200            add     al,byte ptr [eax]
  214. 00150201 00e9            add     cl,ch
  215. 00150203 2a4a94          sub     cl,byte ptr [edx-6Ch]
  216. 00150206 838bff558bec5a  or      dword ptr [ebx-1374AA01h],5Ah
  217. 0015020d 003a            add     byte ptr [edx],bh
  218. 0015020f 005c0063        add     byte ptr [eax+eax+63h],bl
  219. 00150213 006500          add     byte ptr [ebp],ah
  220. 00150216 650064006f      add     byte ptr gs:[eax+eax+6Fh],ah
  221. 0015021b 005c0043        add     byte ptr [eax+eax+43h],bl
  222. 0015021f 006500          add     byte ptr [ebp],ah
  223. 00150222 650064006f      add     byte ptr gs:[eax+eax+6Fh],ah
  224. 00150227 005c0053        add     byte ptr [eax+eax+53h],bl
  225. 0015022b 006d00          add     byte ptr [ebp],ch
  226. 0015022e 61              popad
  227. 0015022f 007200          add     byte ptr [edx],dh
  228. 00150232 7400            je      00150234
  229. 00150234 50              push    eax
  230. 00150235 006c0061        add     byte ptr [eax+eax+61h],ch
  231. 00150239 007900          add     byte ptr [ecx],bh
  232. 0015023c 65007200        add     byte ptr gs:[edx],dh
  233. 00150240 5c              pop     esp
  234. 00150241 006e00          add     byte ptr [esi],ch
  235. 00150244 61              popad
  236. 00150245 007000          add     byte ptr [eax],dh
  237. 00150248 6300            arpl    word ptr [eax],ax
  238. 0015024a 6f              outs    dx,dword ptr [esi]
  239. 0015024b 007200          add     byte ptr [edx],dh
  240. 0015024e 65002e          add     byte ptr gs:[esi],ch
  241. 00150251 0064006c        add     byte ptr [eax+eax+6Ch],ah
  242. 00150255 006c0000        add     byte ptr [eax+eax],ch
  243. 00150259 0000            add     byte ptr [eax],al
  244.  
  245. 00150411 0000            add     byte ptr [eax],al
  246. 00150413 005a00          add     byte ptr [edx],bl
  247. 00150416 3a00            cmp     al,byte ptr [eax]
  248. 00150418 5c              pop     esp
  249. 00150419 006300          add     byte ptr [ebx],ah
  250. 0015041c 65006500        add     byte ptr gs:[ebp],ah
  251. 00150420 64006f00        add     byte ptr fs:[edi],ch
  252. 00150424 5c              pop     esp
  253. 00150425 005700          add     byte ptr [edi],dl
  254. 00150428 69006e006400    imul    eax,dword ptr [eax],64006Eh
  255. 0015042e 6f              outs    dx,dword ptr [esi]
  256. 0015042f 007700          add     byte ptr [edi],dh
  257. 00150432 7300            jae     00150434
  258. 00150434 5c              pop     esp
  259. 00150435 005300          add     byte ptr [ebx],dl
  260. 00150438 7900            jns     0015043a
  261. 0015043a 7300            jae     0015043c
  262. 0015043c 7400            je      0015043e
  263. 0015043e 65006d00        add     byte ptr gs:[ebp],ch
  264. 00150442 3300            xor     eax,dword ptr [eax]
  265. 00150444 3200            xor     al,byte ptr [eax]
  266. 00150446 5c              pop     esp
  267. 00150447 004d00          add     byte ptr [ebp],cl
  268. 0015044a 53              push    ebx
  269. 0015044b 004300          add     byte ptr [ebx],al
  270. 0015044e 4f              dec     edi
  271. 0015044f 005200          add     byte ptr [edx],dl
  272. 00150452 45              inc     ebp
  273. 00150453 004500          add     byte ptr [ebp],al
  274. 00150456 2e0044004c      add     byte ptr cs:[eax+eax+4Ch],al
  275. 0015045b 004c0000        add     byte ptr [eax+eax],cl
  276. 0015045f 0000            add     byte ptr [eax],al
  277.  
  278. KiUserApcDispatcher -> LdrpInitializeProcess -> LdrpLoadDll(kernel32.dll) -> LdrMapDll -> ZwMapViewOfSection
  279. LdrpCallInitRoutine -> BaseDllInitialize
  280. CShellExecute::_DoExecCommand -> ShCreateProcess -> CreateProcess
  281.  
  282. ceedo.exehook了SheelExecuteEx,当其启动子进程时,会hook子进程的LdrLoadDll和NtMapViewOfSection,并且通过VirtualAlloc分配一块空间用来写入自定义的被hook的函数。主线程启动后,子进程加载kernel32.dll,被hook的NtMapViewOfSection会hook kernel32!BaseDllInitialize. 当运行被hook的BaseDllInitialize时,napcore.dll会被加载并调用其DllEntryPoint函数。DllEntryPoint会hook ntdll和kernel32中的函数。具体操作是:将原函数的前5个字节保存,计算原函数与hook函数的地址差,将地址差写到原函数的前5个字节。此时,DllEntryPoint会hook ntdll!NtMapViewOfSection,当子进程还需要加载其他dll时,会hook该dll中的函数。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement