【bugku】web21 (ereg函数绕过)

题目

进入题目,源代码里面提示了p1.html,进入该文件,源代码里面会发现script代码里面定义了一串字符,怀疑是base64,解密出来果不其然,上核心代码!

if(!$_GET['id'])
{
	header('Location: hello.php?id=1');
	exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
	echo 'no no no no no no no';
	return ;
}
$data = @file_get_contents($a,'r');
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 !!!";
}


?>

从上面可以看到需要满足以下几点才能够读取到flag

  1. 传入的a当做file_get_contents的参数返回的内容需要为bugku is a nice plateform!
  2. id需要弱等于0但不能为0 //因为if(!$_GET['id'])这串代码,我还给坑了很久
  3. 传入的b长度需要大于5,且第一个字符传入到eregi函数,需要匹配1114但第一个字符不能为4

绕过方法:

一、file_get_concents函数可以利用伪协议绕过:

  • 使用php://input,再post提交bugku is a nice plateform!
  • 使用data: text/plain,data:text/plain;base64来提交关键字符串

二、id可以为字母,也可以用科学计数法0e开头的字符串,就能够达到弱等于0但不等于0

  • id=abc
  • id=0e123

三、eregi函数可以使用%00来进行截断绕过,但想要匹配1114,第一个字符也可以为一个.

  • b=%00123456
  • b=.123456
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值