Skip to content

Latest commit

 

History

History
70 lines (59 loc) · 3.26 KB

利用思维导图快速读懂框架和理清思路.md

File metadata and controls

70 lines (59 loc) · 3.26 KB

原文链接:http://www.cnseay.com/4526/

偶尔会收到邮件、微博还有博客来咨询,说在代码审计的时候总感觉比较乱,读不懂框架,理不清思路,发现了一段漏洞代码,但是不知道怎么去找漏洞的利用点(请求哪个URL,提交什么数据),这是因为你对这套程序的大框架还不够熟悉,对程序执行流程理解不够透彻。

既然这么多人反馈,那我就简单说一下我的方式:利用思维导图

思维道途是个很好的东西,我在思考各种事情、写复杂程序等等各种场景都会用上这个东西,当然代码审计的时候也会用到,因为他能帮我很快熟悉框架,并且记录可能出现安全问题的地方。如下图所示:

这是在审计禅道时弄的一个简单的思维导图,禅道这套系统一个审计出来了几十个漏洞利用点,包括免灯枯注入和Getshell。

可以看到我的这个思维道途,里面包括以下几个因素:

  1. 程序执行过程(URL怎么解析、首先调用哪些文件等等)
  2. 重要配置文件
  3. 模块解释
  4. 出现问题的点(用红旗标记)
  5. 代码备注

这样一来我们对程序的框架就会一览无余,思路自然清晰。

还有一个问题是关于:怎么挖掘免登录的漏洞?

程序自然会检测权限,就像我这个思维导图里面写的禅道一样,common模块的isopenmethod()函数检查权限,哪些模块可以不用登陆或者低权限可访问。

public function isOpenMethod($module, $method) {
    if ($module == 'user' and strpos('login|logout|deny|reset', $method) !== false)
        return true;
    if ($module == 'api' and $method == 'getsessionid')
        return true;
    if ($module == 'misc' and $method == 'ping')
        return true;
    if ($module == 'misc' and $method == 'checktable')
        return true;
    if ($module == 'misc' and $method == 'qrcode')
        return true;
    if ($module == 'misc' and $method == 'about')
        return true;
    if ($module == 'misc' and $method == 'checkupdate')
        return true;
    if ($module == 'misc' and $method == 'changelog')
        return true;
    if ($module == 'sso' and $method == 'login')
        return true;
    if ($module == 'sso' and $method == 'logout')
        return true;
    if ($module == 'sso' and $method == 'bind')
        return true;
    if ($module == 'sso' and $method == 'gettodolist')
        return true;
    if ($module == 'block' and $method == 'main')
        return true;

    if ($this->loadModel('user')->isLogon() or ($this->app->company->guest and $this->app->user->account == 'guest')) {
        if (stripos($method, 'ajax') !== false)
            return true;
        if (stripos($method, 'downnotify') !== false)
            return true;
        if ($module == 'tutorial')
            return true;
        if ($module == 'block')
            return true;
        if ($module == 'product' and $method == 'showerrornone')
            return true;
    }
    return false;
}

从代码中可以看出,主要是userapimiscsso以及block模块的部分函数无需登录就可以访问,$module代买模块,$method代表函数,那我们就可以把这些函数都看一遍,看是否存在可利用的漏洞。