Initial recon shows that only one port is open with a web server running
Browsing to the web server, there is a static page with an image.
After a little bit of enumeration we find one other page on the web server(debug.php).
Browsing to the page we find a web page which allows us to ping an inputted IP address.
I was able to verify that the ping command was working by running a packet capture when I submitted my query
After experimenting with various inputs I found that you can inject commands by appending a semicolon and adding additional commands.
The only issue is we have blind command injection as the page does not return the output of the commands.
After reading the man page for ping, there is one interesting arguments which can be used to transmit our command output.
The “-p” ping argument allows you specify 16 bytes to fill out the packet you send.
By abusing the “-p” argument and encoding the results of a command we have a working a shell.
Initially, I was trying to transmit 16 bytes at a time but faced issues when decoding a payload which was smaller than 16 bytes.
I gave up transmitting 16 bytes at a time and ended up only transmitting 1 byte at a time.
The below command will stop the first command, execute a command of our choosing and encode the command results in a series of ping packets
Initially I was thinking of decoding the ping packets using a shell script with tshark but settled with scapy.
I hacked together the following script which will capture the ping packets, decode them and print the injected command’s output.
The script will output your command output similar to the following.
After getting the ping decode script working, I explored the file system a little bit.
It appeared that nginx was running inside of a chroot with only a few commands avaliable to us.
It also appeared that there was a local firewall dropping traffic.
I ended up downloading the interesting looking ‘sysadmin-tool’ binary which was being hosted and started investigating.
What was interesting is that that binary has the SUID bit set.
I ran strings against the binary which revealed the following interesting strings:
It appears that the binary will disable the local firewall and provide login credentials.
I proceeded to run the binary and expected it disabled the local firewall and provided provided login credentials.
After a quick port scan, we see that SSH is now open. If you SSH in using the provided credentials you’ll be dropped into a rbash shell.
Looking around you can see there is a custom program named “wopr” running as root.
I proceeded to download the binary and check for bufferoverflows.