该漏洞的问题出现在login.php中,由于编码采用GBK,而对$post_username变量没有进行严格的过滤和转义,导致可以绕过SQL防护,实现注入,下面针对此漏洞进行详细分析。
首先在login.php中第4行
```
if(isset($post_loginsubmit)) {
if($editor = $db->get_by('*', 'admins', "editor='".$db->addslashes($post_username)."'")) {
if(ak_md5($post_password, 0, 2) == $editor['password']) {
if($editor['freeze'] == 1) adminmsg($lan['youarefreeze'], 'index.php', 3, 1);
if(!empty($post_rememberlogin)) {
setlogin($post_username, $thetime + 24 * 3600 * 365 * 10);
} else {
setlogin($post_username);
}
$target = 'index.php';
if(ifthemeuninstalled()) $target = 'index.php?file=theme&action=themeinstall';
adminmsg($lan['login_success'], $target);
} else {
adminmsg($lan['login_failed'], 'index.php?file=login', 3, 1);
}
```
在db->get_by方法中,采用addslashes($post_username)过滤,构造\的方法防止SQL注入,随后在if语句中,调用了common.ini.php中的setlogin函数。第174行
```
function setlogin($adminid, $expire = 0) {
global $dbpw, $dbname, $codekey;
if(!isset($dbpw)) $dbpw = '';
$verify = md5("$adminid|$dbpw|$dbname|$codekey");
aksetcookie('auth', "$adminid|$verify", $expire);
}
```
在post参数中,采用宽字节的方法,假设输入%BF%27,这时会对%27进行过滤,加上\就变成了%bf%5c%27,这样%bf%5c构成了一个宽字符,%27就会被单独解析,导致SQL注入
暂无评论