通用代码审计思路
一、敏感函数回溯参数过程
二、通读全文代码
骑士CMS (宽子节注入,深入了解/php双引号,配置文件,代码执行?)
1.查看应用文件结构
api,admin,manage,include
2.查看关键文件代码
common.func.php, 过滤函数,addslashes() , XSS过滤函数mystrip_tags() ,new_html_special_chars(), remove_xss() , getip() , SQL查询统一操作函数 inserttable() 、updatetable() ,wheresql() , 令牌生成函数 asyn_userkey()
3.查看配置文件
config.php , cache_config.php , 双引号解析代码执行问题,DBCHARSET 宽子节注入问题,set names gbk
4.跟读首页文件
5.跟进其它功能入口文件
三、根据功能点定向审计
文件上传功能
任意文件上传,文件名SQL注入
文件管理功能
任意文件读取,XSS
登录认证功能
任意用户登录,越权
找回密码功能
验证码爆破,验证凭证算法是否可信
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;
}