来源:自学PHP网 时间:2015-04-15 15:00 作者: 阅读:次
[导读] 直接看到 app model attackAction class php这个文件public function initLogHacker() { *get* foreach($_GET as $key=$value){if (!in_array($key, array( 39;ac 39;, 39;a 39;, 39;c 39;, 39;d...
直接看到/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]); } }
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(); } } }
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函数我们无视就好了。影响不大。
修复方案:重写过滤函数 |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com