19.09.2017 Views

the-web-application-hackers-handbook

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

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

456 Chapter 12 n Attacking Users: Cross-Site Scripting<br />

If this happens, do not give up! Your next task is to determine what serverside<br />

processing is occurring that is affecting your input. There are three broad<br />

possibilities:<br />

n The <strong>application</strong> (or a <strong>web</strong> <strong>application</strong> firewall protecting <strong>the</strong> <strong>application</strong>)<br />

has identified an attack signature and has blocked your input.<br />

n The <strong>application</strong> has accepted your input but has performed some kind of<br />

sanitization or encoding on <strong>the</strong> attack string.<br />

n The <strong>application</strong> has truncated your attack string to a fixed maximum length.<br />

We will look at each scenario in turn and discuss various ways in which <strong>the</strong><br />

obstacles presented by <strong>the</strong> <strong>application</strong>’s processing can be bypassed.<br />

Beating Signature-Based Filters<br />

In <strong>the</strong> first type of filter, <strong>the</strong> <strong>application</strong> typically responds to your attack string<br />

with an entirely different response than it did for <strong>the</strong> harmless string. For<br />

example, it might respond with an error message, possibly even stating that a<br />

possible XSS attack was detected, as shown in Figure 12-8.<br />

Figure 12-8: An error message generated by ASP.NET’s anti-XSS filters<br />

If this occurs, <strong>the</strong> next step is to determine what characters or expressions<br />

within your input are triggering <strong>the</strong> filter. An effective approach is to remove<br />

different parts of your string in turn and see whe<strong>the</strong>r <strong>the</strong> input is still being<br />

blocked. Typically, this process establishes fairly quickly that a specific expression<br />

such as is causing <strong>the</strong> request to be blocked. You <strong>the</strong>n need to<br />

test <strong>the</strong> filter to establish whe<strong>the</strong>r any bypasses exist.<br />

There are so many different ways to introduce script code into HTML pages<br />

that signature-based filters normally can be bypassed. You can find an alternative

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

Saved successfully!

Ooh no, something went wrong!