forked from wonderkun/CTF_web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge7.php
54 lines (43 loc) · 1.21 KB
/
challenge7.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
# GOAL: get the key from $hidden_password[207]
session_start();
error_reporting(0);
function auth($password, $hidden_password) {
$res = 0;
if(isset($password) && $password != "") {
if($password == $hidden_password) {
$res = 1;
}
}
$_SESSION["logged"] = $res;
return $res;
}
function display($res){
$aff = htmlentities($res);
return $aff;
}
if(!isset($_SESSION["logged"]))
$_SESSION["logged"] = 0;
$aff = "";
include("config.inc.php");
foreach($_REQUEST as $request) {
if(is_array($request)) {
die("Can not use Array in request!");
}
}
$password = $_POST["password"];
if(!ini_get("register_globals")) {
$superglobals = array($_POST, $_GET);
if(isset($_SESSION)) {
array_unshift($superglobals, $_SESSION);
}
foreach($superglobals as $superglobal) {
extract($superglobal, 0);
}
}
if((isset($password) && $password != "" && auth($password, $hidden_password[207]) == 1) || (is_array($_SESSION) && $_SESSION["logged"] == 1)) {
$aff = display("$hidden_password[207]");
} else {
$aff = display("Try again");
}
echo $aff;