今天拿到一文件。感觉不是很复杂,但实际已分析简直蛋疼,还是一样从我这个菜鸟的角度来说说如何分析这个文件的,分析的不到位的地方还请大神们指点指点。1。老规矩,先跑跑行为
可以看到有注入,注册表,网络的操作。(对于注入我是真的不太了解,没关系遇到了网上现查)看了看到如表,一堆乱七八糟的玩意,于是我打开OD准备直接下端点。BP CreateRemoteProcessBP RegSetValueKey...之类的玩意,由于对windowsAPI不了解,所以都是现查的跑了下发现有的断不下来,有的断的也不是我想要的结果,没办法无从下手了,我只能想到最笨的办法,单步40f9e5 VirtualProtect 修改41a309内存页属性
Decrypt(41a304,41d363)
使用VirtualAlloc申请内存
41a340 VirtualAlloc -> 9e0000 大小为1000
解密Decrypt(41a2f0,41a309)
拷贝.rdata区段代码至申请的内存:
41a309 Copy 41cc20-41cfd3 -> 9E0000 3B4
41a309 Copy 41cfd3-41bd48 ->9e03b3 3b4
解密Decrypt(41a2f0,9e0000)
41a383 Call 9E0009 执行代码
使用VirtualAlloc申请内存
9e014e VirtualAlloc ->9f0000大小为8d6e3
拷贝400820到9F000+146E3 = a046e3 大小5c0f
拷贝40bdf0到 a0a2f2大小为3b4f
拷贝40fa10到 a0de41大小为65eb
拷贝406550到 a1442c大小为 5589
拷贝416410到 a199b5大小为 3e1d
替换部分解密代码:
拷贝41cfd3到 a046e3大小为 3e1d
拷贝41b8a0到 a046e3大小为 4a8
拷贝41d479到 a046e3大小为 3c8
拷贝41e350到 a046e3大小为 1360
拷贝41a570到 a05ae3大小为 b58
拷贝41f6e8到 a046e3大小为 86c
拷贝41b0d0到 a04f4f大小为 4f8
使用VirtualAlloc保留空间
9e0275 VirtualAlloc->400000 大小为23000
使用VirtualAlloc保留空间
9e0287 VirtualAlloc->B90000 大小为23000
使用VirtualAlloc提交
9e029a VirtualAlloc->B90000 大小为1000
拷贝A046E3代码至B90000 大小为400 header
使用VirtualAlloc申请内存
9e02ee VirtualAlloc->B91000 大小为16000
拷贝A04AE3代码至B91000 大小为15600 .text
使用VirtualAlloc申请内存
9e02ee VirtualAlloc->BA7000 大小为1000 .rdata
使用VirtualAlloc申请内存
9e02ee VirtualAlloc->BB2000 大小为1000 .reloc
其中Decrypt是我推测出来的解密部分代码,他的作用就是把两块区域的代码做一个运算,放到其中一块去
此时在内存中已经形成一个PE文件.
修改b90000-b91000属性为readonly head
修改b91000-ba7000为excute_read .text
同样方法修改ba7000-ba8000execute .rdata
修改ba8000-bb2000 excute_read noAcccess .data
修改bb2000-bb3000 noAccess .reloc
取消提交.reloc页
使用jmp指令调到该处:
利用fs:[30]取得kernel32地址.
获取到相应api地址:
b91120 push CsrAllocateCaptureBuffer CsrAllocateMessagePointer CsrAllocateCaptureMessageBuffer
CsrCaptureMessageMutiUnicodeStringInPlace CsrCaptureMessageString CsrCaptureTimeout CsrClientCallServer
CsrClientConnectToServer CsrFreeCaptureBuffer CsrGetProcessId CsrIdentifyAlertableThreads CsrNewThread
CsrProbeForRead CsrProbeForWrite CsrSetPriorityClass DbgBreakPoint DbgPrint DbgPrintEx DbgPrintReturnControlC
DbgPrompt DbgQueryDebugFilterState DbgSetDebugFilterState DbgViConnectToDbg DbgViContinue DbgViConvertStateChangeStructure
DbgViDebugActiveProcess DbgViGetThreadDebugObject ..
获取主机名
B9E67A CALL 00B8EE90 get computername
申请空间 保存主机名和cpuinfo
84EF CALL EDX ZwVirutalAllocateMemory A60000 1000 computername cpuinfo
申请空间临时保存字符串,保存systemdir和processor_level信息:
B98836 CALL EAX ZwFreeVirtualMemorry A60000 1000
BC6000 6000 SYSTEMDIR c:
CD0000 PROCESSOR_LEVEL 3A09
对字符串做相应处理:
B96B64 CALL ECX advapi32.CryptAcquireContextW advapi32.CreateHash CryptHashData CryptGetHashParam 加密
B984EF CALL EDX ntdll.ZwAllocateVirtualMemory A70000 1000
B9854F CALL ECX memset
B984EF CALL EDX ZwVirtualAllocateMemory CC0000 1000
B9854F CALL ECX memeset 清0
B96D52 CALL EAX sprintf %02x 格式的结果 FE810AA94399F781A39D6FAB8AC0CED7
使用wscat连接后的字符串BaseNamedObjectsFE810AA94399F781A39D6FAB8AC0CED7
创建互斥体BaseNamedObjectsFE810AA94399F781A39D6FAB8AC0CED7
B9AD9D CALL EAXRtlInitUnicodeString
B9ADE3 CALL EDX ntldll.ZwOpenEvent
ZwQueryInformationProcess 获取explorer.exe完整路径
B96519 CALL EDX ntdll.ZwCreateFile 获取该文件句柄,用于注入
B9A053 CALL EDX kernel32.CreateProcessInternalW
ZwCreateSection
B9B268 ZwMapViewOfSection DD0000 23000
B9B28C CALL EDX memcpy copy代码到explorer.exe里
B9A763 ntdll.RtlCreateUserThread 在explorer.exe中创建线程,并挂起
12fe44,12fe54,0,a62b0,0,0,0,1,0,cc
OD附加explorer.exe 00a62b0处:
根据上面获取到的字符串命名:
使用ZwCreateFile 复制自身到c:f955aef955ae.exe,并隐藏文件夹和文件
使用ZwSetValueKey修改注册表,开机自启:
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun6f955a c:f955aef955ae.exe
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun*f955a
c:f955aef955ae.exe
winExec执行vssadmin.exe Delete Shadows /ALL /Quite删除所有卷影副本
注入svchost.exe
9b7d9 CALL 00099FC0 c:windowssystem32svchost.exe -k netsvcs
96519 CALL EDX ntdll.ZwCreateFile
9a053 CALL EDX kernel32.CreateProcessInternalW
注入地址为0xa6190
附加svchost.exe:
使用ZwSetValueKey修改注册表,禁用自动更新,系统还原
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetSeriviceswscsvcStart 0x4
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetSeriviceswuauservStart 0x4
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetSerivicesBITSStart 0x4
InterNetOpenUrl
http://torichipinis.com/+seria
http://milimalipali.com/+seria
到此我已经蛋疼至极,好多细节地方已无探究,因为用到好多Zw跟Nt系列的玩意,简直不懂
给我的经验就是有时候单步跟是一种笨但是很有效地方法。