{"id":307,"date":"2021-12-07T09:59:28","date_gmt":"2021-12-07T01:59:28","guid":{"rendered":"https:\/\/www.langsasec.cn\/?p=307"},"modified":"2022-11-14T22:45:33","modified_gmt":"2022-11-14T14:45:33","slug":"xssnote","status":"publish","type":"post","link":"https:\/\/blog.langsasec.cn\/index.php\/2021\/12\/07\/xssnote\/","title":{"rendered":"XSS\u7b14\u8bb0"},"content":{"rendered":"<p>\u539f\u7406\uff1a\u524d\u7aef\u4ee3\u7801\u6ce8\u5165<\/p>\n<p>\u6761\u4ef6\uff1a<\/p>\n<p>1.\u7528\u6237\u80fd\u591f\u63a7\u5236\u8f93\u5165<\/p>\n<p>2.\u7a0b\u5e8f\u6267\u884c\u7684\u4ee3\u7801\u62fc\u63a5\u4e86\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u3002<\/p>\n<p>\u7c7b\u578b<\/p>\n<p><strong>\u53cd\u5c04\u578bXSS<\/strong>\uff1a\u5fc5\u987b\u4e00\u6b21\u6027\u8f93\u5165\u6240\u6709\u6076\u610f\u8bed\u53e5\uff0c\u5229\u7528\u6761\u4ef6\u82db\u523b<\/p>\n<p><strong>\u5b58\u50a8\u578bXSS<\/strong>\uff1a\u6301\u4e45\u6027\uff0c\u5c06\u6211\u4eec\u7684\u6076\u610f\u8bed\u53e5\u5b58\u50a8\u8d77\u6765\u518d\u89e6\u53d1\uff08\u5b58\u50a8\u5230\u4e86\u670d\u52a1\u5668\uff09<\/p>\n<p><strong>DOM\u578b<\/strong>XSS:\u57fa\u4e8eDOM\u5bf9\u8c61\u7684XSS<\/p>\n<p><strong>\u5e38\u89c1\u7684\u89e6\u53d1\u68c0\u6d4b\u65b9\u6cd5<\/strong><\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-js\">\u5229\u7528script\u5f39\u7a97\u6807\u7b7e \uff1a&lt;script&gt;alert(1)&lt;\/script&gt;     alert(1):\u5229\u7528\u5f39\u7a97\u6765\u9a8c\u8bc1\u662f\u5426\u89e6\u53d1XSS\n\n\u4f2a\u534f\u8bae\uff1a&lt;a href =javascript:alert(1) &gt;1&lt;\/a&gt;\n\n\u4e8b\u4ef6\u6cd5:&lt;a onmousemove=alert(1)&gt;1&lt;\/a&gt; \n&lt;img src=# onerror=alert(1) \/&gt;\n\n(\u5176\u4ed6\u4e8b\u4ef6\u53ef\u4ee5\u53c2\u8003\uff1ahttps:\/\/www.w3school.com.cn\/jsref\/jsref_events.asp)<\/code><\/pre>\n<p>\u8865\u5145\uff1a<\/p>\n<p><strong>\u540c\u6e90\u7b56\u7565<\/strong><\/p>\n<p>\u540c\u534f\u8bae\u3001\u540c\u7aef\u53e3\u3001\u540c\u57df\u540d<\/p>\n<p><strong>http-only<\/strong>: cookie\u91cc\u7684\u4e00\u4e2a\u5c5e\u6027\uff0c\u5f00\u542f\u4ee5\u540e\u5c31\u4e0d\u80fd\u5229\u7528js\u53bb\u8bfb\u53d6\u9875\u9762\u7684cookie<\/p>\n<p>\u5229\u7528\uff1aXSS\u5e73\u53f0<br \/>\n\u5371\u5bb3\uff1a<br \/>\n1\u3001Cookie\u7684\u7a83\u53d6 \uff08\u2606\u2606\u2606\u2606\u2606\uff09<br \/>\n2\u3001\u5185\u7f51\u6e17\u900f<br \/>\n3\u3001\u9493\u9c7c<br \/>\n4\u3001\u83b7\u53d6\u6d4f\u89c8\u5668\u4fdd\u5b58\u7684\u660e\u6587\u5bc6\u7801<br \/>\n5\u3001\u622a\u5c4f<br \/>\nXSS\u600e\u4e48\u9632\u5fa1\uff1a<br \/>\n1\u3001\u8fc7\u6ee4 =&gt; \u4e0d\u8ba9\u4f60\u8f93\u5165\u5371\u9669\u7684\u5b57\u7b26<br \/>\n2\u3001httponly =&gt; \u8ba9JS\u65e0\u6cd5\u8bfb\u53d6\u5230Httponly\u4fdd\u62a4\u7684Cookie\u5b57\u6bb5<br \/>\n3\u3001HTML\u5b9e\u4f53\u5316 =&gt; \u8f6c\u4e49\u6210\u6ca1\u6709\u5371\u9669\u7684\u5b57\u7b26<br \/>\n\u7ed5\u8fc7http-only:\u627e\u5230phpinfo\uff0c\u53ef\u4ee5\u67e5\u770b\u5230cookie<br \/>\nDOM\u662f\u4e00\u4e2a\u4e0e\u5e73\u53f0\u3001\u7f16\u7a0b\u8bed\u8a00\u65e0\u5173\u7684\u63a5\u53e3, \u7528\u6765\u4f20\u9012\u6570\u636e.<br \/>\n1.JS\u811a\u672c\u53ef\u4ee5\u52a8\u6001\u5730\u8bbf\u95ee\u548c\u66f4\u65b0\u6587\u6863\u5185\u5bb9\u3001\u7ed3\u6784\u548c\u6837\u5f0f<br \/>\n2.JS\u5229\u7528dom\u7684\u63a5\u53e3\u53ef\u4ee5\u52a8\u6001\u7684\u6539\u53d8\u7f51\u9875\u7684\u5185\u5bb9<\/p>\n<p><strong>\u5927\u90e8\u5206\u7684dom\u578bXSS\u90fd\u662f\u4e0d\u548c\u76ee\u6807\u670d\u52a1\u5668\u8fdb\u884c\u4ea4\u4e92\u7684<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/d611b31e16bc71e1074987268c735299.png\" alt=\"image-20220429000655658\" title=\"XSS\u7b14\u8bb0\u63d2\u56fe\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"dom%e5%9e%8bxss%e5%b8%b8%e8%a7%81%e7%9a%84%e4%b8%89%e7%a7%8d%e7%8a%b6%e6%80%81\"><\/span>DOM\u578bXSS\u5e38\u89c1\u7684\u4e09\u79cd\u72b6\u6001<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>\n<p><strong>Document.write \u5728\u9875\u9762\u4e0a\u9762\u5199\u5185\u5bb9\u3002 \u4e0b\u8ff0\u4ee3\u7801\u7684\u542b\u4e49\u662f\u83b7\u53d6URL\u91cc\u9762\u7684name\u7684\u4f20\u53c2\u7136\u540e\u8f93\u51fa\u5728\u9875\u9762\uff0c\u5b83\u53ef\u4ee5\u63a5\u53d7native\u7f16\u7801\u503c<\/strong><\/p>\n<p><strong>\u8f6c\u7801\u5730\u5740\uff1a<a href=\"http:\/\/tool.oschina.net\/encode?type=3\">http:\/\/tool.oschina.net\/encode?type=3<\/a><\/strong><\/p>\n<p>!<img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/2e71b2b32860de11a5e539da323497dd.png\" alt=\"image-20220429000722123\" title=\"XSS\u7b14\u8bb0\u63d2\u56fe1\" \/><\/p>\n<\/li>\n<li>\n<p><strong>innerHTML \u5c5e\u6027\u8bbe\u7f6e\u6216\u8fd4\u56de\u8868\u683c\u884c\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u6807\u7b7e\u4e4b\u95f4\u7684 HTML,\u4ee5\u4e0b\u4ee3\u7801\u662f\u91cd\u65b0\u8bbe\u7f6eid=zkaq\u7684\u6807\u7b7e\u91cc\u9762\u7684\u503c<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/34e6b1556c30dfba2f4c9eb568972845.png\" alt=\"image-20220429000737098\" title=\"XSS\u7b14\u8bb0\u63d2\u56fe2\" \/><\/p>\n<\/li>\n<li>\n<p><strong>eval \u628a\u5b57\u7b26\u4e32\u5f53\u4ee3\u7801\u6267\u884c,\u8fd9\u91cc\u662f\u83b7\u53d6\u951a\u70b9\u540e\u7684\u503c\u7136\u540e\u653e\u5165eval<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/e1e185fc031dd961439c1fbbef7fd69c.png\" alt=\"image-20220429000757831\" title=\"XSS\u7b14\u8bb0\u63d2\u56fe3\" \/><\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u7406\uff1a\u524d\u7aef\u4ee3\u7801\u6ce8\u5165 \u6761\u4ef6\uff1a 1.\u7528\u6237\u80fd\u591f\u63a7\u5236\u8f93\u5165 2.\u7a0b\u5e8f\u6267\u884c\u7684\u4ee3\u7801\u62fc\u63a5\u4e86\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u3002 \u7c7b\u578b \u53cd\u5c04\u578bXSS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,19],"tags":[],"class_list":["post-307","post","type-post","status-publish","format-standard","hentry","category-webpt-studynote","category-penetration-test"],"_links":{"self":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/comments?post=307"}],"version-history":[{"count":6,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/307\/revisions"}],"predecessor-version":[{"id":1071,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/307\/revisions\/1071"}],"wp:attachment":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/media?parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/categories?post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/tags?post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}