返回列表 发新帖
查看: 574|回复: 0

求小草根分析[好团队]附件收益 20141010(PHP≤5.2)

[复制链接]

228

热度

15

元宝

24

贡献

步入草根

联盟成员

发表于 2014-10-10 17:27:52 | 显示全部楼层 |阅读模式
好不容易利用discuz x3.2的一个漏洞搞的一个shell拿到的一个插件,求分析开源
  1. <?php

  2. if ( !defined( "IN_DISCUZ" ) || !defined( "IN_ADMINCP" ) )
  3. {
  4.     exit( "Aecsse Denied" );
  5. }
  6. global $_G;
  7. global $pluginid;
  8. global $pluginarray;
  9. $table1 = DB::table( "haoteam_vars" );
  10. $table2 = DB::table( "haoteam_lang" );
  11. $pname = $pluginarray['plugin']['identifier'];
  12. $folder = DISCUZ_ROOT."source".DIRECTORY_SEPARATOR."plugin".DIRECTORY_SEPARATOR.$pname;
  13. if ( !function_exists( "haoteam_validator" ) )
  14. {
  15.     if ( file_exists( $folder.DIRECTORY_SEPARATOR."vars.func.php" ) )
  16.     {
  17.         require_once( $folder.DIRECTORY_SEPARATOR."vars.func.php" );
  18.     }
  19.     else
  20.     {
  21.         cpmsg( "plugin_not_found" );
  22.     }
  23. }
  24. if ( file_exists( $folder.DIRECTORY_SEPARATOR."cert.php" ) )
  25. {
  26.     require_once( $folder.DIRECTORY_SEPARATOR."cert.php" );
  27.     $sid = $cert[5];
  28. }
  29. $uniqueid = $_G['setting']['siteuniqueid'] ? $_G['setting']['siteuniqueid'] : C::t( "common_setting" )->fetch( "siteuniqueid" );
  30. $cert = array(
  31.     "qid" => $uniqueid,
  32.     "bbsUrl" => $_G['siteurl'],
  33.     "plugin" => $pname,
  34.     "sid" => $sid,
  35.     "siteurl" => $_G['setting']['siteurl']
  36. );
  37. $insurl = $_SERVER['QUERY_STRING'];
  38. $sql1 = "\r\nCREATE TABLE IF NOT EXISTS `".$table1."` (\r\n  `pluginvarid` mediumint(8) unsigned NOT NULL auto_increment,\r\n  `pluginid` smallint(6) unsigned NOT NULL default '0',\r\n  `identifier` varchar(50) NOT NULL,\r\n  `displayorder` tinyint(3) NOT NULL default '0',\r\n  `title` varchar(100) NOT NULL default '',\r\n  `description` text NOT NULL,\r\n  `variable` varchar(40) NOT NULL default '',\r\n  `type` varchar(255) NOT NULL,\r\n  `value` text NOT NULL,\r\n  `extra` text NOT NULL,\r\n  `module` varchar(255) NOT NULL,\r\n  `submenu` varchar(255) NOT NULL,\r\n  `subnum` int(10) NOT NULL,\r\n  PRIMARY KEY  (`pluginvarid`),\r\n  KEY `pluginid` (`pluginid`)\r\n) ENGINE=MyISAM  DEFAULT CHARSET=gbk;\r\nDELETE FROM {$table1} WHERE identifier = '{$pname}';";
  39. if ( $admincp->isfounder && $_G['config']['plugindeveloper'] && file_exists( $folder.DIRECTORY_SEPARATOR."table".DIRECTORY_SEPARATOR."table_haoteam_lang.php" ) )
  40. {
  41.     $sql2 = "CREATE TABLE IF NOT EXISTS ".$table2." (\r\n  `id` mediumint(8) NOT NULL AUTO_INCREMENT,\r\n  `pluginname` varchar(40) NOT NULL,\r\n  `system` tinyint(1) NOT NULL DEFAULT '0',\r\n  `variable` varchar(40) NOT NULL,\r\n  `value` text NOT NULL,\r\n  `module` varchar(255) NOT NULL,\r\n  PRIMARY KEY (`id`)\r\n) ENGINE=MyISAM  DEFAULT CHARSET=gbk;\r\nDELETE FROM {$table2} WHERE pluginname = '{$pname}';";
  42. }
  43. $table4 = DB::table( "piaobo_attachment" );
  44. $table5 = DB::table( "piaobo_attachment_shar" );
  45. $table6 = DB::table( "piaobo_attachment_extcredits" );
  46. $table_all = array(
  47.     $table4,
  48.     $table5,
  49.     $table6
  50. );
  51. if ( $_GET['step'] )
  52. {
  53.     sleep( 1 );
  54. }
  55. switch ( $_GET['step'] )
  56. {
  57. case "1" :
  58.     loadcache( $pname."_drk_developer" );
  59.     if ( !$_G['cache'][$pname."_drk_developer"] )
  60.     {
  61.         haoteam_validator( $pname.".plugin", 0, array( "check", "install", "upgrade", "vars.func" ) );
  62.         haoteam_check( "http://www.51piaobo.com/", $cert, array( "check", "install", "upgrade", "vars.func" ) );
  63.     }
  64.     cpmsg( unie( "检测环境完成,载入团队数据表……" ), "{$insurl}&step=2", "loading" );
  65.     break;
  66. case "2" :
  67.     if ( $sql1 )
  68.     {
  69.         runquery( $sql1 );
  70.     }
  71.     cpmsg( unie( "载入好团队数据完成,导入语言包……" ), "{$insurl}&step=3", "loading" );
  72.     break;
  73. case "3" :
  74.     if ( $sql2 )
  75.     {
  76.         runquery( $sql2 );
  77.         foreach ( $pluginarray['language'] as $key => $languages )
  78.         {
  79.             foreach ( $languages as $k => $langs )
  80.             {
  81.                 $data['pluginname'] = $pname;
  82.                 $data['system'] = 0;
  83.                 $data['variable'] = $k;
  84.                 $data['value'] = $langs;
  85.                 $data['module'] = $key;
  86.                 C::t( "#".$pname."#haoteam_lang" )->insert( $data );
  87.             }
  88.         }
  89.         unset( $data );
  90.     }
  91.     cpmsg( unie( "导入语言包完成……" ), "{$insurl}&step=4", "loading" );
  92.     break;
  93. case "4" :
  94.     foreach ( $table_all as $table )
  95.     {
  96.         if ( !check_table_is_exist( $table ) )
  97.         {
  98.             $table_tmp = str_ireplace( $_G['config']['db'][1]['tablepre'], "", $table );
  99.             $tmp = explode( "_", $table );
  100.             if ( $_G['config']['db'][1]['tablepre'] == $tmp[0] )
  101.             {
  102.                 $table_tmp = $tmp[0].$table_tmp;
  103.             }
  104.             require_once( $folder."/install/install_".$table_tmp.".php" );
  105.             if ( $piaobo_install )
  106.             {
  107.                 @unlink( $folder."/install/install_".$table_tmp.".php" );
  108.             }
  109.         }
  110.     }
  111.     savecache( $pname."_tables", $table_all );
  112.     foreach ( $pluginarray['haoteamvars'] as $vars )
  113.     {
  114.         $data = array(
  115.             "pluginid" => $pluginid
  116.         );
  117.         foreach ( $vars as $key => $val )
  118.         {
  119.             $data[$key] = $val;
  120.         }
  121.         C::t( "#".$pname."#haoteam_vars" )->insert( $data );
  122.     }
  123.     cpmsg( unie( "导入应用数据表完成..." ), "{$insurl}&step=5", "loading" );
  124.     break;
  125. case "5" :
  126.     C::t( "common_plugin" )->update( $pluginid, array( "available" => "1" ) );
  127.     updatecache( array( "plugin", "setting", "styles" ) );
  128.     cleartemplatecache( );
  129.     updatemenu( "plugin" );
  130.     cpmsg( unie( "清理缓存……" ), "{$insurl}&step=6", "loading" );
  131.     break;
  132. case "6" :
  133.     if ( file_exists( $folder."/install/install_import.php" ) )
  134.     {
  135.         require_once( $folder."/install/install_import.php" );
  136.     }
  137.     cpmsg( unie( "数据导入及临时文件创建" ), "{$insurl}&step=7", "loading" );
  138.     break;
  139. case "7" :
  140.     $file_exists = $folder."/install/install_wsq.php";
  141.     if ( file_exists( $file_exists ) )
  142.     {
  143.         cpmsg( unie( "是否启用微社区模块(不影响传统论坛功能)" ), "{$insurl}&step=8", "form", array( ), "", TRUE, ADMINSCRIPT.( "?".$insurl."&step=9" ) );
  144.     }
  145.     else
  146.     {
  147.         cpmsg( unie( "数据导入及临时文件创建" ), "{$insurl}&step=9", "loading" );
  148.     }
  149.     break;
  150. case "8" :
  151.     require_once( $folder."/install/install_wsq.php" );
  152.     cpmsg( unie( "数据导入及临时文件创建" ), "{$insurl}&step=10", "loading" );
  153.     break;
  154. case "9" :
  155.     $finish = TRUE;
  156.     break;
  157. default :
  158.     cpmsg( unie( "开始安装前的准备,检测环境..." ), "{$insurl}&step=1", "loading" );
  159. }
  160. ?>
复制代码


返回列表 发新帖
 懒得打字嘛,点击右侧快捷回复【最新发布】   【赞助草根吧享更多权益】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

收藏帖子 返回列表 搜索

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

小黑屋|手机版|草根吧