{"id":3895,"date":"2019-02-20T19:04:37","date_gmt":"2019-02-20T11:04:37","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3895"},"modified":"2019-02-20T19:04:37","modified_gmt":"2019-02-20T11:04:37","slug":"java-http-host-%e5%a4%b4%e6%94%bb%e5%87%bb%e5%8e%9f%e7%90%86%e4%bb%a5%e5%8f%8a%e5%a6%82%e4%bd%95%e9%98%b2%e5%be%a1","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3895","title":{"rendered":"Java HTTP Host \u5934\u653b\u51fb\u539f\u7406\u4ee5\u53ca\u5982\u4f55\u9632\u5fa1"},"content":{"rendered":"<p>\n\t\u5f88\u5bf9\u5fae\u4fe1\u7fa4\u91cc\u7684\u7f51\u53cb\uff0c\u6211\u90fd\u79f0\u4ed6\u4eec\u4e3a\u8001\u94c1\uff0c\u4ece\u6765\u4e0d\u79f0\u5144\u9053\u5f1f\u7684\uff0c\u56e0\u4e3a\u6211\u89c9\u5f97\u4e0d\u771f\u5b9e\u3002\u4e0d\u5411\u67d0\u4e1c\uff0c\u8bf4\u4e00\u5957\u505a\u4e00\u5957\u3002\n<\/p>\n<p>\n\t\u5176\u5b9e\u4f60\u53ea\u8981\u8ba4\u771f\u5bf9\u5f85\u5927\u5bb6\uff0c\u5927\u5bb6\u90fd\u4f1a\u770b\u5728\u5fc3\u91cc\uff0c\u4f60\u4eec\u8bf4\u662f\u4e0d\u662f\uff01\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"host \u6f0f\u6d1e\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g0d3dh6wmej20at0b3gmc.jpg\" style=\"width: 389px;height: 399px\" \/>\n<\/p>\n<p>\n\t\u5bf9\u4e8e Java \u7a0b\u5e8f\u5458\u6765\u8bf4\uff0c\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a\u8dd1\u591a\u4e2a\u7a0b\u5e8f\u662f\u975e\u5e38\u5e38\u89c1\u7684\u73b0\u8c61\u3002\n<\/p>\n<p>\n\t\u4f46\u662f\u8fd9\u6837\u505a\u540e\u4f1a\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u5bb9\u6613\u9020\u6210 Host \u5934\u653b\u51fb\u3002\u8fd9\u4e5f\u662f\u4e4b\u524d\u5fae\u4fe1\u7fa4\u91cc\u4e00\u4e2a\u7f51\u53cb\u9047\u5230\u7684\u95ee\u9898\u3002\u4eca\u5929\u6211\u5728\u8fd9\u91cc\u7ed9\u5927\u5bb6\u626f\u4e00\u626f\u3002\n<\/p>\n<p>\n\thost \u5934(host header\u6216\u79f0\u4e3b\u673a\u5934)\u653b\u51fb\uff0c\u975e\u5e38\u5e38\u89c1\u3002\u6bd4\u5982\uff0c\u5728 jsp \u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u53ef\u80fd\u5b58\u5728\u7c7b\u4f3c\u4e0b\u9762\u7684\u4ee3\u7801\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;&lt;%=path%&gt;\/js\/zcms\/zDrag.js&quot;&gt;&lt;\/script&gt;\r\n&lt;script src=&quot;&lt;%=request.getContextPath() %&gt; \/manage\/test.js&quot;&gt;&lt;\/script&gt; \r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;${pageContext.request.contextPath }\/scripts\/a.js&quot;&gt;&lt;\/script&gt;<\/pre>\n<p>\n\t\u4e0a\u9762\u7684\u51e0\u79cd\u52a0\u8f7d\u8def\u5f84\uff0c\u80cc\u540e\u90fd\u662f\u901a\u8fc7 host \u53d6\u5f97 url \u5730\u5740\uff0c\u518d\u62fc\u63a5\u4e0a\u56fa\u5b9a\u7684\u5185\u5bb9\u3002\n<\/p>\n<p>\n\t\u8fd9\u4e2a\u65f6\u5019\uff0c\u5047\u5982\u6211\u628a\u4f60\u7684 host \u5934\u7ed9\u6539\u6389\u4e86\uff0c\u6bd4\u5982\u6539\u6210\u6211\u7684 www.xttblog.com\u3002\u7136\u540e\u8fd9\u65f6\u4f60\u5728\u52a0\u8f7d\u7684 js \u6587\u4ef6\uff0c\u53ef\u80fd\u5c31\u6765\u6e90\u4e8e\u6211\u7684\u7f51\u7ad9\u4e2d\u5df2\u505a\u597d\u9677\u9631\u7684 js \u6587\u4ef6\u4e86\u3002\n<\/p>\n<p>\n\t\u8fd9\u6837\uff0c\u9ed1\u5ba2\u5c31\u80fd\u62ff\u5230\u4f60\u7684 cookie\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u7b49\u5173\u952e\u6570\u636e\u3002\u8fd9\u5c31\u662f\u8457\u540d\u7684 host \u5934\u653b\u51fb\u3002\n<\/p>\n<p>\n\t\u66f4\u6709\u751a\u8005\uff0c\u5728\u4f60\u7684\u7f51\u7ad9\u4e0a\u653e\u5165\u75c5\u6bd2\uff0c\u6316\u77ff\u7b49\u4ee3\u7801\u3002\u800c\u4f60\u8fd8\u4e0d\u77e5\u9053\u4f60\u88ab\u5229\u7528\u4e86\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u4ee3\u7801\u89c4\u8303\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g0d3d5zocnj20hq0buaba.jpg\" style=\"width: 638px;height: 426px\" \/>\n<\/p>\n<p>\n\t\u90a3\u4e48\u8be5\u600e\u4e48\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u5462\uff1f\u5f88\u7b80\u5355\uff0c\u4e0b\u9762\u6211\u4eec\u4ee5 Nginx \u4e3a\u4f8b\uff0c\u53ea\u9700\u8981\u4fee\u6539\u4e00\u4e0b\u914d\u7f6e\u6587\u4ef6\u5373\u53ef\u3002Apache \u6211\u5c31\u4e0d\u4e3e\u4f8b\u4e86\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\nserver {\r\n   listen 8888 default;\r\n   server_name _;\r\n   location \/ {\r\n        return 403;\r\n   }\r\n}<\/pre>\n<p>\n\t\u6dfb\u52a0\u4e00\u4e2a\u9ed8\u8ba4 server\uff0c\u5f53 host \u5934\u88ab\u4fee\u6539\u5339\u914d\u4e0d\u5230 server \u65f6\u4f1a\u8df3\u5230\u8be5\u9ed8\u8ba4 server\uff0c\u8be5\u9ed8\u8ba4 server \u76f4\u63a5\u8fd4\u56de 403 \u9519\u8bef\u3002\n<\/p>\n<p>\n\t\u91cd\u542f nginx \u5373\u53ef\u3002\n<\/p>\n<p>\n\t\u9664\u4e86\u8fd9\u79cd\u505a\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u5728\u76ee\u6807 server \u6dfb\u52a0\u68c0\u6d4b\u89c4\u5219\u3002\u6bd4\u5982\u4e0b\u9762\u7684 if \u5224\u65ad\u914d\u7f6e\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\nserver {\r\n  server_name  192.168.0.171;\r\n  listen       8888;\r\n  if ($http_Host !~*^192.168.0.171:8888$){\r\n    return 403;\r\n  }\r\n  include \/etc\/nginx\/default.d\/*.conf;\r\n  location \/ {\r\n    root \/www\/dvwa;\r\n    index index.php index.html index.htm;\r\n  }\r\n}<\/pre>\n<p>\n\t\u53e6\u5916\uff0c\u5728 Tomcat \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u76f4\u63a5\u914d\u7f6e Host \u7684 name \u4e3a\u5177\u4f53\u7684 ip \u5730\u5740\uff0c\u4e0d\u8981\u914d\u7f6e localhost\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;Host name=&quot;localhost&quot;  appBase=&quot;webapps&quot;  \r\n            unpackWARs=&quot;true&quot; autoDeploy=&quot;true&quot;  \r\n            xmlValidation=&quot;false&quot; xmlNamespaceAware=&quot;false&quot;&gt; \r\n          &lt;Alias&gt;10.1.8.158&lt;\/Alias&gt;&lt;!--10.1.8.158 \u672c\u5730\u5c40\u57df\u7f51--&gt;  \r\n   &lt;Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot; directory=&quot;logs&quot;  \r\n              prefix=&quot;localhost_access_log.&quot; suffix=&quot;.txt&quot;  resolveHosts=&quot;false&quot;  \r\n              pattern=&quot;%a %A %b %B %h %H %l %m %p %s %S %t %u %U %v %D %T&quot; \/&gt;  \r\n&lt;\/Host&gt;<\/pre>\n<p>\n\t\u8bf4\u767d\u4e86\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u662f\u56e0\u4e3a\u4f60\u4f7f\u7528\u4e86 Host \u800c\u6ca1\u9a8c\u8bc1\u5b83\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\nString path = request.getContextPath();\r\nString basePath = request.getScheme() + &quot;:\/\/&quot; \r\n  + request.getServerName() \r\n  + &quot;:&quot; + request.getServerPort() \r\n  + path + &quot;\/&quot;;<\/pre>\n<p>\n\t\u76ee\u524d\uff0c\u7eff\u76df\u3001burpsuite\u3001360 \u7b49\u5de5\u5177\u90fd\u53ef\u4ee5\u5bf9\u8fd9\u4e00\u6f0f\u6d1e\u8fdb\u884c\u68c0\u6d4b\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3895\">Java HTTP Host \u5934\u653b\u51fb\u539f\u7406\u4ee5\u53ca\u5982\u4f55\u9632\u5fa1<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5f88\u5bf9\u5fae\u4fe1\u7fa4\u91cc\u7684\u7f51\u53cb\uff0c\u6211\u90fd\u79f0\u4ed6\u4eec\u4e3a\u8001\u94c1\uff0c\u4ece\u6765\u4e0d\u79f0\u5144\u9053\u5f1f\u7684\uff0c\u56e0\u4e3a\u6211\u89c9\u5f97\u4e0d\u771f\u5b9e\u3002\u4e0d\u5411\u67d0\u4e1c\uff0c\u8bf4\u4e00\u5957\u505a\u4e00\u5957\u3002 \u5176\u5b9e\u4f60\u53ea\u8981 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[358,124,1749,1481,355],"class_list":["post-3895","post","type-post","status-publish","format-standard","hentry","category-java","tag-admin","tag-http","tag-http-3","tag-xss"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3895"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3895\/revisions"}],"predecessor-version":[{"id":3896,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3895\/revisions\/3896"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}