Extract The Flag

Description

<No Description After CTF Ended...>

Challengearrow-up-right Sourcearrow-up-right

Solution

<?php
if (isset($_GET['src'])) {
    highlight_file(__FILE__);
    die();
}

error_reporting(0);
include_once 'flag.php';
session_start();
$_SESSION['admin'] = false;
extract($_POST);
?>
...
<div class="row">
    <div class="card">
        <h4>Flag</h4>
        <!-- admin content -->
        <?php
        if (isset($_SESSION['admin'])) {
            if ($_SESSION['admin']) {
                echo "Your flag: " . $flag;
                echo "<br>";
            }
        }
        ?>
    </div>
</div>
...

The vulnaribility with given php code is extractarrow-up-right. Basically if you pass array such as [name=>Ryan],after extract you will have access to variable named name with value Ryan. This introduces vulnaribility because we can also overwrite variables.

circle-check

Last updated