一例phorpiex僵尸网络样本分析

概述

这例样本属于phorpiex僵尸网络家族,情报显示与GrandCrab勒索病毒有关联。

该样本首先在内存中通过两次解密释放出一段shellcode,shellcode又解密了一个pe,使用个PE替换掉当前进程内存,最后跳转到该PE入口点执行。
该样本会修改主机安全策略和防火墙策略,会检测沙箱环境。

通过感染网络磁盘和可移动存储介质传播,会感染系统中压缩文件(向压缩包中添加病毒副本),包括所有的zip,rar,7z,tar文件,会向C2下载后续攻击 载荷执行,使用了类似DGA域名的技术(共涉及120个c2地址)。代码中有许多无用的冗余代码,用于对抗分析。

样本基本信息

Verified:    Unsigned
Link date:    13:33 2017/11/4
MD5:    B095AD570646218EC5EB436BFE766508
SHA1:    B216E92E07B6BFA501D874296C630B7A6501FA52
SHA256: 6f7feb333bff5c66d88f23ae3cb609d2de451ec99f05b98c904913794b2d3b2a

整个样本的执行过程分为三个阶段,第一阶段是解密一段shellcode,跳转到shellcode入口执行;第二阶段是进入shellcode,解密一个pe,加载到0x400000处(替换当前进程的内存),跳转到PE的Entrypoint执行;第三阶段是执行PE,完成病毒的主要功能。

下面分别介绍这三个阶段。

第一阶段

第一阶段的主要功能是在内存中解密一段shellcode,里面有很多冗余代码,给分析带来不少的困扰。使用IDA可以发现,首先使用LocalAlloc分配了一段内存。在LocalAlloc处下断点,分配了一段0x56E8的buffer。

将镜像中地址0x40ca30处,大小为0x56E8的一段内容,拷贝到新分配的buffer中。

在docode1_401000函数中对buffer进行解密,将解密后的内容在存放在一段新的buffer2中,解密后的大小为0x412E。这是第一层解密。

然后使用VirtualProtect修改buffer2的内存属性为RWX.

接着进行第二次解密,这次使用异或解密。

二次解密相对比较简单,用C伪代码表示如下 。

#include <stdio.h>
#include <windows.h>

void decode2(char* buf,int size){
    int gVar = 0xA240d836;
    gVar = 0x343FD*gVar+0x2625A0+0x7923;
    DWORD key =  0x7fff & HIWORD(gVar);
    for (int i; i<size;i++)
    {
        buf[i] ^= LOBYTE(key);
    }
}

最后跳转到解密后的shellcode起始位置执行,这里借助pchunter将这段shellcode提取出来,进行静态分析。

第二阶段 shllcode分析

这段shellcode的主要功能是在内存中解密一个pe,并加载执行。

首先,通过PEB的方式获取了进程的基址和LoadLibraryAGetProcAddress的地址。

通过LoadLibraryAGetProcAddress获取到了一系列API的地址。如下所示。

调用SetErrorMode函数来检测是否在沙箱环境下。(原理可见参考资料)

接着解密出来一个PE文件,将当前进程的内存清空,将解密出来的PE加载到当前进程内存空间,shellcode里面有一个PE加载器,执行拷贝PE头和各节,加载dll构造IAT,进行地址重定位,最后跳转到EntryPoint执行。

在解密处下断点,将这段内存dump出来。这是一个PE,执行病毒的主要功能。

第三阶段 分析dump出来的pe

这个PE的功能比较简单,使用IDA pro很容易分析明白。

dump出来的PE的基本信息

MD5: d829a015f21c9d1f6bf69281e82dd765
SHA1: 1449e2b18b658f2b18a55f0d91af1448d4598532
SHA256: 8c51d3f62e4c2a1c11f744efbb92bed296c96f06605fb69c697d3ab904e847
Verified:    Unsigned
Link date:    19:31 2018/11/29
MachineType:    32-bit

首先检测是否是沙箱环境中。通过检测kernel32.dll模块中是否有有wine_get_unix_file_name函数,来判断当前环境是否是Wine模拟器环境。

若存在下列进程,退出;若存在模块 sbiedll.dll sbiedllx.dll dir_watch.dll wpespy.dll 退出。

python.exe
pythonw.exe
prl_cc.exe
prl_tools.exe
vmsrvc.exe
vmusrvc.exe
xenservice.exe
vboxservice.exe
vboxtray.exe
vboxcontrol.exe
vmwareservice.exe
vmwaretray.exe
tpautoconnsvc.exe
vmtoolsd.exe
vmwareuser.exe

创建互斥量 4950605050040,若存在同名互斥量,退出 。

在系统目录 %windir%、%userprofile%、%appdata%、%temp% 之一中创建目录4960650049563030, 将自己拷贝为winsvcs.exe

添加开机启动项Microsoft Windows Services,用于启动winsvcs.exe

修改系统的防火墙策略,禁用安全中心设置,禁用系统还原。修改的注册表项如下。

HKEY_LOCAL_MACHINE\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List\\
[%windir% %userprofile% %appdata% %temp%]之一 + \4960650049563030\winsvcs.exe  4960650049563030\winsvcs.exe:*:Enabled:Microsoft Windows Services


HKEY_LOCAL_MACHINE\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\DisableAntiSpyware=1


HKEY_LOCAL_MACHINE\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection\\
DisableScanOnRealtimeEnable=1
DisableOnAccessProtection=1
DisableBehaviorMonitoring=1

禁用
HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft\\Security Center\\
AntiVirusOverride=1
UpdatesOverride=1
FirewallOverride=1
AntiVirusDisableNotify=1
UpdatesDisableNotify=1
AutoUpdateDisableNotify=1
FirewallDisableNotify=1

HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft\\Security Center\\svc\
AntiVirusOverride=1
UpdatesOverride=1
FirewallOverride=1
AntiVirusDisableNotify=1
UpdatesDisableNotify=1
AutoUpdateDisableNotify=1
FirewallDisableNotify=1

禁用系统还原
HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\\DisableSR=1

下面介绍病毒的感染过程和网络行为。

感染行为

下面深入讲一下这个病毒是如何感染系统 的。

感染可移动存储介质和网络驱动器

通过遍历系统内的所有驱动器,感染其中的可移动存储介质和网络驱动器。

感染U盘的过程:删除U盘根目录下的后缀名为lnk vbs bat js scr com jse cmd pif jar dll的文件,在U盘根目录下创建名为_的目录,将U盘下所有的文件移动到该目录下,将病毒副本拷贝到_目录下,命名为DeviceManager.exe。在U盘的根目录下创建一个以卷名命名的快捷方式文件,图标为驱动器图标(shell32.dll 8),指向%windir%\\system32\\cmd.exe /c start _ & _\\DeviceManager.exe & exit。在U盘的根目录创建autorun.inf文件,内容为[autorun]\nopen=_\\DeviceManager.exe\nUseAutoPlay=1.

感染网络驱动器过程相同,只是快捷方式的图标为网络驱动器图标(shell32.dll 9)。

感染系统中的压缩文件

检查文件%appdata%\winsvcs_.txt是否存在,若存在,说明已经感染过,跳过;若不存在,则创建该文件并隐藏,遍历系统中所有驱动器,感染其中的压缩文件。

感染后缀名为zip、rar、7z、tar的文件,将自身副本添加中到压缩文件中,命名为Windows Archieve Manager.exe

若碰到下列路径,会使用自身副本替换路径下的exe文件。

\\public_html
\\htdocs
\\httpdocs
\\wwwroot
\\ftproot
\\share
\\income
\\upload

网络行为

这个样本中硬编码了120个url,如下,其中有119个域名和1个IP,这些域名有点像DGA域名,应该只有其中部分有效。

http://ssofhoseuegsgrfnu.ru/
http://92.63.197.48/
http://slpsrgpsrhojifdij.ru/
http://aiiaiafrzrueuedur.ru/
http://fuaiuebndieufeufu.ru/
http://eiifngjfksisiufjf.ru/
http://eoroooskfogihisrg.ru/
http://noeuaoenriusfiruu.ru/
http://iuirshriuisruruuf.ru/
http://afeifieuuufufufuf.ru/
http://srndndubsbsifurfd.ru/
http://fiiauediehduefuge.ru/
http://nousiieiffgogogoo.ru/
http://fifiehsueuufidhfi.ru/
http://eofihsishihiursgu.ru/
http://nnososoosjfeuhueu.ru/
http://ssofhoseuegsgrfnj.su/
http://slpsrgpsrhojifdij.su/
http://aiiaiafrzrueuedur.su/
http://fuaiuebndieufeufu.su/
http://eiifngjfksisiufjf.su/
http://eoroooskfogihisrg.su/
http://noeuaoenriusfiruu.su/
http://iuirshriuisruruuf.su/
http://afeifieuuufufufuf.su/
http://srndndubsbsifurfd.su/
http://fiiauediehduefuge.su/
http://nousiieiffgogogoo.su/
http://fifiehsueuufidhfi.su/
http://eofihsishihiursgu.su/
http://nnososoosjfeuhueu.su/
http://ssofhoseuegsgrfnj.in/
http://slpsrgpsrhojifdij.in/
http://aiiaiafrzrueuedur.in/
http://fuaiuebndieufeufu.in/
http://eiifngjfksisiufjf.in/
http://eoroooskfogihisrg.in/
http://noeuaoenriusfiruu.in/
http://iuirshriuisruruuf.in/
http://afeifieuuufufufuf.in/
http://srndndubsbsifurfd.in/
http://fiiauediehduefuge.in/
http://nousiieiffgogogoo.in/
http://fifiehsueuufidhfi.in/
http://eofihsishihiursgu.in/
http://nnososoosjfeuhueu.in/
http://ssofhoseuegsgrfnj.net/
http://slpsrgpsrhojifdij.net/
http://aiiaiafrzrueuedur.net/
http://fuaiuebndieufeufu.net/
http://eiifngjfksisiufjf.net/
http://eoroooskfogihisrg.net/
http://noeuaoenriusfiruu.net/
http://iuirshriuisruruuf.net/
http://afeifieuuufufufuf.net/
http://srndndubsbsifurfd.net/
http://fiiauediehduefuge.net/
http://nousiieiffgogogoo.net/
http://fifiehsueuufidhfi.net/
http://eofihsishihiursgu.net/
http://ssofhoseuegsgrfnj.biz/
http://slpsrgpsrhojifdij.biz/
http://aiiaiafrzrueuedur.biz/
http://fuaiuebndieufeufu.biz/
http://eiifngjfksisiufjf.biz/
http://eoroooskfogihisrg.biz/
http://noeuaoenriusfiruu.biz/
http://iuirshriuisruruuf.biz/
http://afeifieuuufufufuf.biz/
http://srndndubsbsifurfd.biz/
http://fiiauediehduefuge.biz/
http://nousiieiffgogogoo.biz/
http://fifiehsueuufidhfi.biz/
http://eofihsishihiursgu.biz/
http://nnososoosjfeuhueu.net/
http://ssofhoseuegsgrfnj.com/
http://slpsrgpsrhojifdij.com/
http://aiiaiafrzrueuedur.com/
http://fuaiuebndieufeufu.com/
http://eiifngjfksisiufjf.com/
http://eoroooskfogihisrg.com/
http://noeuaoenriusfiruu.com/
http://iuirshriuisruruuf.com/
http://afeifieuuufufufuf.com/
http://srndndubsbsifurfd.com/
http://fiiauediehduefuge.com/
http://nousiieiffgogogoo.com/
http://fifiehsueuufidhfi.com/
http://eofihsishihiursgu.com/
http://nnososoosjfeuhueu.com/
http://ssofhoseuegsgrfnj.biz/
http://slpsrgpsrhojifdij.biz/
http://aiiaiafrzrueuedur.biz/
http://fuaiuebndieufeufu.biz/
http://eiifngjfksisiufjf.biz/
http://eoroooskfogihisrg.biz/
http://noeuaoenriusfiruu.biz/
http://iuirshriuisruruuf.biz/
http://afeifieuuufufufuf.biz/
http://srndndubsbsifurfd.biz/
http://fiiauediehduefuge.biz/
http://nousiieiffgogogoo.biz/
http://fifiehsueuufidhfi.biz/
http://eofihsishihiursgu.biz/
http://nnososoosjfeuhueu.biz/
http://ssofhoseuegsgrfnj.info/
http://slpsrgpsrhojifdij.info/
http://aiiaiafrzrueuedur.info/
http://fuaiuebndieufeufu.info/
http://eiifngjfksisiufjf.info/
http://eoroooskfogihisrg.info/
http://noeuaoenriusfiruu.info/
http://iuirshriuisruruuf.info/
http://afeifieuuufufufuf.info/
http://srndndubsbsifurfd.info/
http://fiiauediehduefuge.info/
http://nousiieiffgogogoo.info/
http://fifiehsueuufidhfi.info/
http://eofihsishihiursgu.info/
http://nnososoosjfeuhueu.info/

当病毒运行后,会依次请求这120个域名,访问http://[c2]/tldr.php?newinf=1来告诉C2已经上线了。User-Agent"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0"

之后会请求http://[c2]/tldr.php?online=1,向http://[c2]/[t|m|p|s|o].exe请求一个可执行文件,保存为临时文件并运行。

感染后的症状

感染后,U盘中所有的文件在隐藏目录_

快捷方式的目标如下,_目录下的DeviceManger.exe为病毒副本。

U盘根目录下,有一个隐藏的autorun.inf文件,如下所示。

感染后的rar文件,里面多了一个Windows Archieve Manager.exe文件,为病毒副本。

感染后的zip文件,里面多了一个Windows Archieve Manager.exe文件,为病毒副本。

感染后的.7z文件格式错误无法打开。

遇到含有下列关键字的路径,将下面的exe程序替换成病毒副本。如下图所示。

\\public_html
\\htdocs
\\httpdocs
\\wwwroot
\\ftproot
\\share
\\income
\\upload

IOC

hash

文件
%appdata%\winsvcs_.txt 
%windir%\4960650049563030\winsvcs.exe
%userprofile%\4960650049563030\winsvcs.exe
%appdata%\4960650049563030\winsvcs.exe
%temp%\4960650049563030\winsvcs.exe
%temp%\Windows Archive Manager.exe
%temp%\[随机数字].exe
U盘或网络驱动器
X:\_\DeviceManager.exe
X:\autorun.inf
X:\[卷名].lnk
压缩包中有一个文件 Windows Archive Manager.exe

互斥量
4960650049563030


注册表
添加开机启动项
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"Microsoft Windows Services"="C:\4960650049563030\winsvcs.exe"
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"Microsoft Windows Services"="C:\4960650049563030\winsvcs.exe"

禁用windows Defender
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\DisableAntiSpyware=1

禁用windows Defender实时防护
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\real-Time Protection\DisableScanOnRealtimeEnable=1
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\real-Time Protection\DisableOnAccessProtection=1
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\real-Time Protection\DisableBehaviorMonitoring=1

禁用windows安全中心的一些功能
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\AntiVirusOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\UpdatesOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\FirewallOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\AntiVirusDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\UpdatesDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\AutoUpdateDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\FirewallDisableNotify=1

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\AntiVirusOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\UpdatesOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\FirewallOverride=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\AntiVirusDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\UpdatesDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\AutoUpdateDisableNotify=1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\svc\FirewallDisableNotify=1

禁用系统还原
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows  NT\CurrentVersion\SystemRestore\DisableSR=1


网络
http://ssofhoseuegsgrfnu.ru/
http://92.63.197.48/
http://slpsrgpsrhojifdij.ru/
http://aiiaiafrzrueuedur.ru/
http://fuaiuebndieufeufu.ru/
http://eiifngjfksisiufjf.ru/
http://eoroooskfogihisrg.ru/
http://noeuaoenriusfiruu.ru/
http://iuirshriuisruruuf.ru/
http://afeifieuuufufufuf.ru/
http://srndndubsbsifurfd.ru/
http://fiiauediehduefuge.ru/
http://nousiieiffgogogoo.ru/
http://fifiehsueuufidhfi.ru/
http://eofihsishihiursgu.ru/
http://nnososoosjfeuhueu.ru/
http://ssofhoseuegsgrfnj.su/
http://slpsrgpsrhojifdij.su/
http://aiiaiafrzrueuedur.su/
http://fuaiuebndieufeufu.su/
http://eiifngjfksisiufjf.su/
http://eoroooskfogihisrg.su/
http://noeuaoenriusfiruu.su/
http://iuirshriuisruruuf.su/
http://afeifieuuufufufuf.su/
http://srndndubsbsifurfd.su/
http://fiiauediehduefuge.su/
http://nousiieiffgogogoo.su/
http://fifiehsueuufidhfi.su/
http://eofihsishihiursgu.su/
http://nnososoosjfeuhueu.su/
http://ssofhoseuegsgrfnj.in/
http://slpsrgpsrhojifdij.in/
http://aiiaiafrzrueuedur.in/
http://fuaiuebndieufeufu.in/
http://eiifngjfksisiufjf.in/
http://eoroooskfogihisrg.in/
http://noeuaoenriusfiruu.in/
http://iuirshriuisruruuf.in/
http://afeifieuuufufufuf.in/
http://srndndubsbsifurfd.in/
http://fiiauediehduefuge.in/
http://nousiieiffgogogoo.in/
http://fifiehsueuufidhfi.in/
http://eofihsishihiursgu.in/
http://nnososoosjfeuhueu.in/
http://ssofhoseuegsgrfnj.net/
http://slpsrgpsrhojifdij.net/
http://aiiaiafrzrueuedur.net/
http://fuaiuebndieufeufu.net/
http://eiifngjfksisiufjf.net/
http://eoroooskfogihisrg.net/
http://noeuaoenriusfiruu.net/
http://iuirshriuisruruuf.net/
http://afeifieuuufufufuf.net/
http://srndndubsbsifurfd.net/
http://fiiauediehduefuge.net/
http://nousiieiffgogogoo.net/
http://fifiehsueuufidhfi.net/
http://eofihsishihiursgu.net/
http://ssofhoseuegsgrfnj.biz/
http://slpsrgpsrhojifdij.biz/
http://aiiaiafrzrueuedur.biz/
http://fuaiuebndieufeufu.biz/
http://eiifngjfksisiufjf.biz/
http://eoroooskfogihisrg.biz/
http://noeuaoenriusfiruu.biz/
http://iuirshriuisruruuf.biz/
http://afeifieuuufufufuf.biz/
http://srndndubsbsifurfd.biz/
http://fiiauediehduefuge.biz/
http://nousiieiffgogogoo.biz/
http://fifiehsueuufidhfi.biz/
http://eofihsishihiursgu.biz/
http://nnososoosjfeuhueu.net/
http://ssofhoseuegsgrfnj.com/
http://slpsrgpsrhojifdij.com/
http://aiiaiafrzrueuedur.com/
http://fuaiuebndieufeufu.com/
http://eiifngjfksisiufjf.com/
http://eoroooskfogihisrg.com/
http://noeuaoenriusfiruu.com/
http://iuirshriuisruruuf.com/
http://afeifieuuufufufuf.com/
http://srndndubsbsifurfd.com/
http://fiiauediehduefuge.com/
http://nousiieiffgogogoo.com/
http://fifiehsueuufidhfi.com/
http://eofihsishihiursgu.com/
http://nnososoosjfeuhueu.com/
http://ssofhoseuegsgrfnj.biz/
http://slpsrgpsrhojifdij.biz/
http://aiiaiafrzrueuedur.biz/
http://fuaiuebndieufeufu.biz/
http://eiifngjfksisiufjf.biz/
http://eoroooskfogihisrg.biz/
http://noeuaoenriusfiruu.biz/
http://iuirshriuisruruuf.biz/
http://afeifieuuufufufuf.biz/
http://srndndubsbsifurfd.biz/
http://fiiauediehduefuge.biz/
http://nousiieiffgogogoo.biz/
http://fifiehsueuufidhfi.biz/
http://eofihsishihiursgu.biz/
http://nnososoosjfeuhueu.biz/
http://ssofhoseuegsgrfnj.info/
http://slpsrgpsrhojifdij.info/
http://aiiaiafrzrueuedur.info/
http://fuaiuebndieufeufu.info/
http://eiifngjfksisiufjf.info/
http://eoroooskfogihisrg.info/
http://noeuaoenriusfiruu.info/
http://iuirshriuisruruuf.info/
http://afeifieuuufufufuf.info/
http://srndndubsbsifurfd.info/
http://fiiauediehduefuge.info/
http://nousiieiffgogogoo.info/
http://fifiehsueuufidhfi.info/
http://eofihsishihiursgu.info/
http://nnososoosjfeuhueu.info/
http://[host]/tldr.php?newinf=1
http://[host]/tldr.php?online=1
http://[host]/m.exe
http://[host]/p.exe
http://[host]/s.exe
http://[host]/o.exe
UserAgent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0

# 总结

这个样本使用的以下技术:

  1. 使用好几种检测沙箱的方式,比如SetErrorMode、wine_get_unix_file_name函数、检测特定进程等等;

  2. 使用了众多个域名来规避检测;

  3. 感染压缩包的方式,使用COM接口来操作rar,zip和tar格式文件,不过7z格式文件有问题。

  4. 使用注册表关闭系统安全设置,很多注册表项先前都不知道。

    总之,分析过程确实长知识了。

参考资料

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值