31.07.2015 Views

Download

Download

Download

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

148 Chapter 4 • XSS TheoryFigure 4.37 XSS Exploit In ActionAs a result, the JavaScript code is injected with no visible indication of its existence.The tag does not render, because it is not valid. In a real-world scenario, the alert boxwould be stealing cookies, overwriting pages, or any number of malicious actions.Let’s use the same example above, but assume the Webmaster included code to putslashes in front of any single quotes or double quotes (i.e., add_slashes()). Our previous vectorwithout the last part would now turn into:alert(\"XSS\")'>We are still safely outside the HTML parameter and the INPUT tag, but now our vectorwon’t fire anymore due to the inserted ‘\’ characters.To defeat this, we need to stop usingquotes in our vector. How about using the String.fromCharCode() function in JavaScript tohelp us? String.fromCharCode allows you to include the decimal equivalent of any ASCIIcharacter without having to actually type that string. Here’s what the ASCII chart looks likein hexadecimal (base 6) and decimal (base 10):Decimal:0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 '40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 /

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!