old-30 -- MySQL Connection Hijack

URL: http://webhacking.kr:10003arrow-up-right

old-30.png
<?php
if ($_GET["view_source"]) {
    highlight_file(__FILE__);
}

($db = mysqli_connect()) or die();

mysqli_select_db($db, "chall30") or die();

($result = mysqli_fetch_array(mysqli_query($db, "select flag from chall30_answer"))) or die();

if ($result[0]) {
    include "/flag";
}
?>

This challenge doesn't contain include "../../config.php"; like other PHP files and performs mysqli_connect without any parameters.

https://www.php.net/manual/en/mysqli.construct.phparrow-up-right

old-30-1.png

Runtime Configurationarrow-up-right

old-30-2.png

Prepare database:

Did you know that you can set php.ini values right inside the .htaccess file? It's actually very easy srcarrow-up-right

Start a tunnel for your database, like ngrok or some other service

Create .htaccess

Upload and visit your directory, flag should get included.

Last updated