DogCat
Enumerating Parameters - Bypass PHP Filter using Wrapper - Exploiting LFI to get RCE - Env PrivEsc - Docker Escape
Starting off with a nmap scan to know what are all the open ports
Seems like the
/?view
php query displays some .jpg files, everytime you request for a dog's images the backend sends a different picture which means it already has few pics
When we append a slash after the dog, we get an error, It basically uses the include func in php which includes files from an external source - Purely vulnerable to LFI kinda attacks !, It even appends a
.php
extension after the slash, hmm fishy right ? why not simply check theindex.php
which is one directory above - /?view=dog/../index (Did not add the .php, as it automatically appends)
Still no clue, return the same error, so now why don't we try a php wrapper to encode our desired output using base64? So when we try this, we get the desired
index.php
in a base64 format
Decoding the above gives us the source code on the filtering works !
We can see that we have the control over the
$ext
variable which is responsible for appending the.php
after the filename and most importantly the/?view
should start with either dog or cat
So inorder to bypass this, we can include the $ext variable in our url and give it an empty value
Using the above trick we can dump the
/etc/passwd
file, no bash session users only www-data is available
Now let's abuse the LFI, checking the
/var/log/apache2/access.log
- We find our User-Agent being passed in all the requests - which confirms we can perform Apache Log Poisoning attack and leverage it to a RCE !
Inorder to exploit the log poison attack, we'll first have to insert the php-cmd payload into our User-Agent
Insert a php-exec shell from https://revshells.com into the
cmd
and get a reverse shell !
NOTE - Do not commit any mistake while inserting the php payload in the User-Agent, once there is a mistake in the log file then no matter whateva you do, you'll not get the desired result nor even can view the access.log
- Grab the first flag and go one directory back and cat out the second flag
Privilege Escalation
Let's start our enumeration by reading the sudo permissions for the current user
GTFObins to the rescue !
Enumerating the box more gives us that there might be a docker container and flag4 is hidden there, enumerating the /opt directory gives us a writable file called backup.sh
Seems to be like that - .sh file is running as cron job and let's just append our reverse shell to get r00t
Last updated