{"id":29,"date":"2022-04-04T17:19:40","date_gmt":"2022-04-04T09:19:40","guid":{"rendered":"https:\/\/reverieland.cn\/?p=29"},"modified":"2022-04-04T17:19:40","modified_gmt":"2022-04-04T09:19:40","slug":"%e8%b7%a8%e5%9f%9f%e9%97%ae%e9%a2%98%e7%9a%84%e4%b8%89%e7%a7%8d%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/reverieland.cn\/index.php\/29\/","title":{"rendered":"\u8de8\u57df\u95ee\u9898\u7684\u4e09\u79cd\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1.\u540c\u6e90\u7b56\u7565<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1.\u540c\u6e90\u7b56\u7565\u7684\u5b9a\u4e49<\/h4>\n\n\n\n<p>\u6240\u8c13\u540c\u6e90\u662f\u6307\"\u534f\u8bae+\u57df\u540d+\u7aef\u53e3\"\u4e09\u8005\u76f8\u540c\uff0c\u5373\u4fbf\u4e24\u4e2a\u4e0d\u540c\u7684\u57df\u540d\u6307\u5411\u540c\u4e00\u4e2a ip \u5730\u5740\uff0c\u4e5f\u975e\u540c\u6e90\u3002\u540c\u6e90\u7b56\u7565\/SOP\uff08Same origin policy\uff09\u662f\u4e00\u79cd\u7ea6\u5b9a\uff0c\u7531 Netscape \u516c\u53f8 1995 \u5e74\u5f15\u5165\u6d4f\u89c8\u5668\uff0c\u5b83\u662f\u6d4f\u89c8\u5668\u6700\u6838\u5fc3\u4e5f\u6700\u57fa\u672c\u7684\u5b89\u5168\u529f\u80fd\uff0c\u73b0\u5728\u6240\u6709\u652f\u6301 JavaScript \u7684\u6d4f\u89c8\u5668\u90fd\u4f1a\u4f7f\u7528\u8fd9\u4e2a\u7b56\u7565\u3002\u5982\u679c\u7f3a\u5c11\u4e86\u540c\u6e90\u7b56\u7565\uff0c\u6d4f\u89c8\u5668\u5f88\u5bb9\u6613\u53d7\u5230 XSS\u3001 CSFR \u7b49\u653b\u51fb\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.\u4ec0\u4e48\u662f\u6e90<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>1.\u6e90\uff08origin\uff09\u5c31\u662f\u534f\u8bae\u3001\u57df\u540d\u548c\u7aef\u53e3\u53f7\u3002<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>2.\u4f8b\uff1a\u76f8\u5bf9\u4e8e http:\/\/www.a.com\/test\/index.html \u7684\u540c\u6e90\u68c0\u6d4b<\/li><\/ul>\n\n\n\n<p>[1] http:\/\/www.a.com\/dir\/page.html ----\u6210\u529f\uff0cport\u9ed8\u8ba4\u662f80<br>[2] http:\/\/www.child.a.com\/test\/index.html ----\u5931\u8d25\uff0c\u57df\u540d\u4e0d\u540c<br>[3] https:\/\/www.a.com\/test\/index.html ----\u5931\u8d25\uff0c\u534f\u8bae\u4e0d\u540c<br>[4] http:\/\/www.a.com:8080\/test\/index.html ----\u5931\u8d25\uff0c\u7aef\u53e3\u53f7\u4e0d\u540c<br>[5] http:\/\/www.domain.com\/a.js http:\/\/192.168.4.12\/b.js \u867d\u7136\u57df\u540d\u6307\u5411\u7684ip\u548cip\u76f8\u540c\uff0c\u4e5f\u4e0d\u662f\u540c\u6e90\uff0c\u56e0\u4e3a\u57df\u540d\u4e0d\u540c\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2.\u89e3\u51b3\u65b9\u68481\uff1ajsonp<\/h3>\n\n\n\n<p>\u901a\u5e38\u4e3a\u4e86\u51cf\u8f7bweb\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\uff0c\u6211\u4eec\u628ajs\u3001css\uff0cimg\u7b49\u9759\u6001\u8d44\u6e90\u5206\u79bb\u5230\u53e6\u4e00\u53f0\u72ec\u7acb\u57df\u540d\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u5728html\u9875\u9762\u4e2d\u518d\u901a\u8fc7\u76f8\u5e94\u7684\u6807\u7b7e\u4ece\u4e0d\u540c\u57df\u540d\u4e0b\u52a0\u8f7d\u9759\u6001\u8d44\u6e90\uff0c\u800c\u88ab\u6d4f\u89c8\u5668\u5141\u8bb8\uff0c\u57fa\u4e8e\u6b64\u539f\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u52a8\u6001\u521b\u5efascript\uff0c\u518d\u8bf7\u6c42\u4e00\u4e2a\u5e26\u53c2\u7f51\u5740\u5b9e\u73b0\u8de8\u57df\u901a\u4fe1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u4ec5\u5c55\u793a\u539f\u751f\u5b9e\u73b0\n &lt;script>\r\n    var script = document.createElement('script');\r\n    script.type = 'text\/javascript';\r\n\r\n    \/\/ \u4f20\u53c2\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u540d\u7ed9\u540e\u7aef\uff0c\u65b9\u4fbf\u540e\u7aef\u8fd4\u56de\u65f6\u6267\u884c\u8fd9\u4e2a\u5728\u524d\u7aef\u5b9a\u4e49\u7684\u56de\u8c03\u51fd\u6570\r\n    script.src = 'http:\/\/www.domain2.com:8080\/login?user=admin&amp;callback=handleCallback';\r\n    document.head.appendChild(script);\r\n\r\n    \/\/ \u56de\u8c03\u6267\u884c\u51fd\u6570\r\n    function handleCallback(res) {\r\n        alert(JSON.stringify(res));\r\n    }\r\n &lt;\/script><\/code><\/pre>\n\n\n\n<p>\u7f3a\u70b9\uff1aJSONP\u53ea\u652f\u6301GET\u8bf7\u6c42\uff0c\u4e0d\u652f\u6301POST\u8bf7\u6c42\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u89e3\u51b3\u65b9\u68482\uff1adocument.domain + iframe\u8de8\u57df<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">  1.\u7236\u7a97\u53e3\uff1a(http:\/\/www.domain.com\/a.html)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;iframe id=\"iframe\" src=\"http:\/\/child.domain.com\/b.html\">&lt;\/iframe>\r\n&lt;script>\r\n    document.domain = 'domain.com';\r\n    var user = 'admin';\r\n&lt;\/script><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">  2.\u5b50\u7a97\u53e3\uff1a(http:\/\/child.domain.com\/b.html)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\r\n    document.domain = 'domain.com';\r\n    \/\/ \u83b7\u53d6\u7236\u7a97\u53e3\u4e2d\u53d8\u91cf\r\n    alert('get js data from parent ---> ' + window.parent.user);\r\n&lt;\/script><\/code><\/pre>\n\n\n\n<p>\u7f3a\u70b9\uff1a\u6709\u9650\u5236\uff0c\u4ec5\u9002\u7528\u4e8e\u4e3b\u57df\u76f8\u540c\uff0c\u5b50\u57df\u4e0d\u540c\u7684\u8de8\u57df\u5e94\u7528\u573a\u666f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.\u89e3\u51b3\u65b9\u68483\uff1a<strong>\u00a0location.hash + iframe\u8de8\u57df<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">  1.a.html\uff1a(http:\/\/www.domain1.com\/a.html)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;iframe id=\"iframe\" src=\"http:\/\/www.domain2.com\/b.html\" style=\"display:none;\">&lt;\/iframe>\r\n&lt;script>\r\n    var iframe = document.getElementById('iframe');\r\n\r\n    \/\/ \u5411b.html\u4f20hash\u503c\r\n    setTimeout(function() {\r\n        iframe.src = iframe.src + '#user=admin';\r\n    }, 1000);\r\n    \r\n    \/\/ \u5f00\u653e\u7ed9\u540c\u57dfc.html\u7684\u56de\u8c03\u65b9\u6cd5\r\n    function onCallback(res) {\r\n        alert('data from c.html ---> ' + res);\r\n    }\r\n&lt;\/script><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">  2.b.html\uff1a(http:\/\/www.domain2.com\/b.html)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;iframe id=\"iframe\" src=\"http:\/\/www.domain1.com\/c.html\" style=\"display:none;\">&lt;\/iframe>\r\n&lt;script>\r\n    var iframe = document.getElementById('iframe');\r\n\r\n    \/\/ \u76d1\u542ca.html\u4f20\u6765\u7684hash\u503c\uff0c\u518d\u4f20\u7ed9c.html\r\n    window.onhashchange = function () {\r\n        iframe.src = iframe.src + location.hash;\r\n    };\r\n&lt;\/script><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.\uff09c.html\uff1a(http:\/\/www.domain1.com\/c.html)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\r\n    \/\/ \u76d1\u542cb.html\u4f20\u6765\u7684hash\u503c\r\n    window.onhashchange = function () {\r\n        \/\/ \u518d\u901a\u8fc7\u64cd\u4f5c\u540c\u57dfa.html\u7684js\u56de\u8c03\uff0c\u5c06\u7ed3\u679c\u4f20\u56de\r\n        window.parent.parent.onCallback('hello: ' + location.hash.replace('#user=', ''));\r\n    };\r\n&lt;\/script><\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u540c\u6e90\u7b56\u7565 1.\u540c\u6e90\u7b56\u7565\u7684\u5b9a\u4e49 \u6240\u8c13\u540c\u6e90\u662f\u6307&#8221;\u534f\u8bae+\u57df\u540d+\u7aef\u53e3&#8221;\u4e09\u8005\u76f8\u540c\uff0c\u5373\u4fbf\u4e24\u4e2a\u4e0d\u540c\u7684\u57df\u540d\u6307\u5411\u540c\u4e00\u4e2a ip \u5730\u5740\uff0c\u4e5f\u975e\u540c\u6e90\u3002\u540c &#8230;<\/p>\n","protected":false},"author":1,"featured_media":30,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[7],"class_list":["post-29","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-frontend","tag-7"],"_links":{"self":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":1,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":31,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions\/31"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/media\/30"}],"wp:attachment":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}