Featured Content Slider

Home » » picoctf 2013 - Pretty Hard Programming: 95

picoctf 2013 - Pretty Hard Programming: 95

Vo Uu | 20:47 | 0 nhận xét
src: https://picoctf.com/problems/php1/index.phps


<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
Share this article :

0 nhận xét:

Đăng nhận xét

Recent Post

Test Footer 1

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. The UG - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger