secskill
  • Introduction
  • 1.web应用漏洞
    • 1.1 SQL注入漏洞
      • 1.1.1 type注入利用
      • 1.1.2 mothod注入利用
      • 1.1.3 按照效果注入利用
      • 1.1.4 order,limit和from后的注入
      • 1.10.1 sqlmap使用
    • 1.2 目录遍历漏洞
    • 1.3 跨站脚本漏洞
      • 1.3.10 flash xss
      • 1.3.11 Uxss
    • 1.4 未过滤HTML代码漏洞
    • 1.5 数据库运行出错
    • 1.6 Flash安全配置缺陷漏洞
    • 1.7 编辑器漏洞
      • 1.7.1 kindeditor编辑器漏洞
        • 1.7.1.1 kindeditor<=4.1.5文件上传漏洞
      • 1.7.2 fckeditor编辑器漏洞
        • 1.7.2.1 fckeditor<=2.6.4文件上传漏洞
    • 1.8 URL Redirect漏洞
    • 1.9 任意文件上传漏洞
    • 1.10 敏感信息泄露漏洞
    • 1.11 未加密登陆请求漏洞
    • 1.12 后台弱口令漏洞
    • 1.13 后台口令暴力破解漏洞
    • 1.14 跨站请求伪造漏洞
    • 1.15 Unicode 编码转换漏洞
    • 1.16 Possible .Net Error Message
    • 1.17 发生内部错误漏洞
    • 1.18 旁站攻击漏洞
    • 1.19 后台登录页面绕过
    • 1.20 Possible PHP Error Message
    • 1.21 UrlPath Pollution
    • 1.22 File Operation-Web.xml漏洞
    • 1.23 短文件名泄漏漏洞
    • 1.24 OS注入漏洞
    • 1.25 SOAP注入漏洞
    • 1.26 SMTP注入漏洞
    • 1.27 LDAP注入漏洞
    • 1.28 命令执行漏洞
    • 1.29 HTTP消息头注入漏洞
    • 1.30 验证机制缺陷漏洞
    • 1.31 越权漏洞
    • 1.31 服务端请求伪造漏洞
    • 1.32 xxe漏洞
    • 1.33 逻辑漏洞
    • 1.34 支付漏洞
      • 1.34.1 支付漏洞
    • 1.35 cors漏洞
      • 1.35.1 cors
    • 1.36 jsonp漏洞
    • 1.37 点击劫持漏洞
    • 1.38 框架注入漏洞
    • 1.39 文件包含漏洞
    • 1.40 CRLF注入漏洞
    • 1.41 SSTI漏洞
  • 2.中间件漏洞
    • 2.1 IIS
      • 2.1.1 CVE-2017-7269
    • 2.2 Apache
    • 2.3 Axis2
    • 2.4 lighttpd
    • 2.5 Tomcat
      • 2.5.1 CVE-2017-12615
    • 2.6 Nginx
    • 2.7 WebLogic
    • 2.8 JBoss
    • 2.9 Websphere
    • 2.10 Struct2
    • 2.11 XAMMP
    • 2.12 LAMPP
    • 2.13 FastCGI
    • 2.14 PHPCGI
    • 2.15 JOnAS
    • 2.16 Joomla
      • 2.16.1 CVE-2017-8917
    • 2.17 Padding oracle
    • 2.18 Jenkins
      • 2.18.1 CVE-2019-1003000
      • 2.18.2 CVE-2017-1000353
    • 2.18 Drupal
      • 2.18.1 CVE-2019-6340l
    • 2.19 PHPGD
      • 2.19.1 CVE-2019-6977
    • 2.20 PhpMyAdmin
      • 2.20.1 CVE-2016-5734
      • 2.20.2 反序列化漏洞
      • 2.20.3 CVE-2018-12613
    • 2.21 PHP
      • 2.21.1 extract
      • 2.21.2 strcmp
      • 2.21.3 urldecode
      • 2.21.4 md5
      • 2.21.5 strpos
      • 2.21.6 is_numeric
      • 2.21.7 sha
      • 2.21.7 ereg
      • 2.21.8 creat
  • 3.系统漏洞
    • 3.1 DNS域传送漏洞
    • 3.2 SSH Services Port 22 Enabled
    • 3.3 NetBIOS Services Port 139 Enabled
    • 3.4 OpenSSL 漏洞
    • 3.5 docker remote API漏洞
    • 3.6 Samba远程代码执行漏洞
    • 3.7 Windows系统漏洞
      • 3.7.1 ms17-010
      • 3.7.2 ms08-067
      • 3.7.3 ms16-075
      • 3.7.4 CVE-2017-0213
      • 3.7.5 ms16-135
      • 3.7.6 CVE-2018-8120
      • 3.7.7 CVE-2018-0824
    • 3.8 linux系统漏洞
      • 3.8.1 ubuntu
        • 3.8.1.1 CVE-2015-1328
        • 3.8.1.2 CVE-2017-16995
    • 3.9 openssh漏洞
      • 3.9.1 cve-2016-6515
  • 4.网络漏洞
    • 4.1 ARP欺骗嗅探漏洞
    • 4.2 反弹shell的N种姿势
    • 4.3 DNS欺骗
  • 5.cms漏洞
    • 5.1 08cms
    • 5.2 74cms
    • 5.3 Appcms
    • 5.4 Aspcms
    • 5.5 Bluecms
    • 5.6 Cscms
    • 5.7 Dedecms
    • 5.8 Discuz
      • 5.8.1 Discuz任意文件删除
    • 5.9 Dkcms
    • 5.10 Ecshop
    • 5.11 Finecms
    • 5.12 Fscms
    • 5.13 Jeecms
    • 5.14 Ibcms
    • 5.15 Maccms
    • 5.16 Php168
    • 5.17 Phpcms
    • 5.18 Phpmywind
    • 5.19 Phpwind
    • 5.20 Phpweb
    • 5.21 Qibocms
    • 5.22 Seacms
    • 5.23 Shopex
    • 5.24 Thinkphp
      • 5.24.1 SQL
      • 5.24.2 RCE
      • 5.24.3 RCE2
    • 5.25 Typecho
    • 5.26 Wordpress
      • 5.26.1 Wordpress Plugin_sql
    • 5.27 Xycms
    • 5.28 Zabbix
    • 5.29 Zblog
    • 5.30 Zzcms
Powered by GitBook
On this page
  • urldecode()
  • 二次urldecode注入
  • DocCms漏洞分析

Was this helpful?

  1. 2.中间件漏洞
  2. 2.21 PHP

2.21.3 urldecode

Previous2.21.2 strcmpNext2.21.4 md5

Last updated 6 years ago

Was this helpful?

urldecode()

urldecode()函数使用参考

<?php
if(eregi("hackerDJ",$_GET[id])) {
echo("

not allowed!

");
exit();
}
$_GET[id] = urldecode($_GET[id]);
if($_GET[id] == "hackerDJ")
{
echo "
Access granted!

";
echo "
flag

";
}
?>

tips:

eregi — 不区分大小写的正则表达式匹配

int eregi( string $pattern, string $string[, array &$regs] )

本函数和 ereg() 完全相同,只除了在匹配字母字符时忽略大小写的区别。 

ereg()函数

int ereg ( string $pattern , string $string [, array &$regs ] )

以区分大小写的方式在 string 中寻找与给定的正则表达式 pattern 所匹配的子串。 

如果找到与 pattern 中圆括号内的子模式相匹配的子串并且函数调用给出了第三个参数 regs,则匹配项将被存入 regs 数组中。$regs[1] 包含第一个左圆括号开始的子串,$regs[2] 包含第二个子串,以此类推。$regs[0] 包含整个匹配的字符串。 

如果在 string 中找到 pattern 模式的匹配则返回所匹配字符串的长度,如果没有找到匹配或出错则返回 FALSE。如果没有传递入可选参数 regs 或者所匹配的字符串长度为 0,则本函数返回 1。

代码审计需要满足两个条件:1. id里面不能包含字符串“hackerDJ”

2. id经过urldecode()之后等于字符串“hackerDJ”

利用浏览器默认对提交的数据进行一次url解码

所以对“hackerDJ”二次编码

payload:

二次urldecode注入

示例代码:

<?php
$a = addslashes($_GET['p']);
$b = urldecode($a);
echo '$a= '.$a;
echo '<br / >';
echo '$b= '.$b;
 ?>

以此代码为例,本来使用了魔术引号的方法,直接提交将会出现单引号

但因为进行了urldecode解码就导致了二次注入问题

成功绕过..

DocCms漏洞分析

代码分析

在/content/search/index.php中,首先对参数keyword进行非法字符检测,

<?php
//首页搜索,站内关键字搜索
function index()
{
    global $db;
    global $request;
    global $params;
    global $tag;    // 标签数组

    !checkSqlStr($request['keyword'])? $request['keyword'] = $request['keyword'] : exit('非法字符');
    $keyword = urldecode($request['keyword']);

    if(empty($keyword))
    {
        echo '<script>alert("请输入您要查询的内容!");window.history.go(-1);</script>';
    }

进一步追溯checkSqlStr函数,看代码如何过滤,在/inc/function.php中

function checkSqlStr($string)
{
    $string = strtolower($string);
    return preg_match('/select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile|_user/i', $string);
}

checkSqlStr函数对传入的字符串进行正则匹配,检测是否函数非法字符。

继续看在/content/search/index.php中的get_search_result函数:

function get_search_result($modelName)
{
    global $db,$request;
    !checkSqlStr($request['keyword'])? $request['keyword'] = $request['keyword'] : exit('非法字符');
    $keyword = urldecode($request['keyword']);
    switch($modelName)
    {
        case 'article':
            $sql = "SELECT * FROM ".TB_PREFIX."article WHERE title LIKE '%".$keyword."%' OR content LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'list':
            $sql="SELECT * FROM ".TB_PREFIX."list WHERE  title LIKE '%".$keyword."%' OR content LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'product':
            $sql="SELECT * FROM ".TB_PREFIX."product  WHERE title LIKE '%".$keyword."%' OR content LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'download':
            $sql="SELECT * FROM ".TB_PREFIX."download WHERE title LIKE '%".$keyword."%' OR content LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'picture':
            $sql="SELECT * FROM ".TB_PREFIX."picture WHERE title LIKE '%".$keyword."%' OR description LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'video':
            $sql="SELECT * FROM ".TB_PREFIX."video WHERE title LIKE '%".$keyword."%' OR description LIKE '%".$keyword."%' ORDER BY id DESC";
            break;
        case 'jobs':
            $sql="SELECT *  FROM ".TB_PREFIX."jobs WHERE  lastTime>='".date('Y-m-d')."' AND (title LIKE '%".$keyword."%' OR content LIKE '%".$keyword."%')  ORDER BY id DESC";
            break;
        case 'poll':
            $sql="SELECT * FROM ".TB_PREFIX."poll_category  WHERE  title LIKE '%".$keyword."%'  ORDER BY id DESC";
            break;
        default: break;
    }
    return $db->get_results($sql);
}

参数keyword进行非法字符检测后,进行url解码,然后拼接到SQL语句中执行。

如果我们传入双重url编码的字符串,将绕过非法字符检测,然后经urldecode解码,带入数据库中执行,导致SQL注入漏洞存在。

此时就可以使用sqlmap的chardoubleencode.py进行双重编码进行注入了

http://www.php.net/manual/zh/function.urldecode.php
http://123.206.87.240:9009/10.php?id=%68ackerDJ