TimeKORP
- ๐ Website: HackTheBox
- ๐ฅ Level: Very Easy
- ๐ Category: Web
- ๐ Link: TimeKORP
๐ Description¶
Are you ready to uncover the mysteries and expose the truth hidden within KROPโs digital domain? Join the challenge and prove your skills in the world of cybersecurity. Remember, time is money, but in this case the rewards may be much greater than you imagine.
๐ Walkthrough¶
The site looks very simple: it shows the current time.
We notice that the URL has this structure:
There is also another page with a similar format:
By changing the format
parameter, the content is reflected on the webpage.
Letโs take a look at the source code:
public function index($router)
{
$format = isset($_GET['format']) ? $_GET['format'] : '%H:%M:%S';
$time = new TimeModel($format);
return $router->view('index', ['time' => $time->getTime()]);
}
If the format
parameter is not provided, it defaults to %H:%M:%S
. Now letโs see how getTime()
is implemented:
public function __construct($format)
{
$this->command = "date '+" . $format . "' 2>&1";
}
public function getTime()
{
$time = exec($this->command);
$res = isset($time) ? $time : '?';
return $res;
}
The value of format
is concatenated into a shell command that is then executed by exec
. A full example command looks like this:
The trick is to concatenate additional commands to the base one. Letโs try with a simple echo
:
The resulting command becomes:
And indeed the page returns โhelloโ:
Now we can simply read the flag with cat /flag
using the payload:
Answer
HTB{t1m3_f0r_th3_ult1m4t3_pwn4g3_****}