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.

562 Chapter 13 n Attacking Users: O<strong>the</strong>r Techniques<br />

Many <strong>web</strong> servers contain image files located at unique URLs. The following<br />

code checks for a specific image associated with a popular range of DSL routers:<br />

<br />

If <strong>the</strong> function notNetgear is not invoked, <strong>the</strong> server has been successfully<br />

fingerprinted as a NETGEAR router. The script can <strong>the</strong>n proceed to attack <strong>the</strong><br />

<strong>web</strong> server, ei<strong>the</strong>r by exploiting any known vulnerabilities in <strong>the</strong> particular<br />

software or by performing a request forgery attack. In this example, <strong>the</strong> attacker<br />

could attempt to log in to <strong>the</strong> router with default credentials and reconfigure<br />

<strong>the</strong> router to open additional ports on its external interface, or expose its administrative<br />

function to <strong>the</strong> world. Note that many highly effective attacks of this<br />

kind require only <strong>the</strong> ability to issue arbitrary requests, not to process <strong>the</strong>ir<br />

responses, so <strong>the</strong>y are unaffected by <strong>the</strong> same-origin policy.<br />

In certain situations, an attacker may be able to leverage DNS rebinding techniques<br />

to violate <strong>the</strong> same-origin policy and actually retrieve content from <strong>web</strong><br />

servers on <strong>the</strong> local network. These attacks are described later in this chapter.<br />

Exploiting Non-HTTP Services<br />

Going beyond attacks against <strong>web</strong> servers, in some situations it is possible to<br />

leverage a user’s browser to target non-HTTP services that are accessible from<br />

<strong>the</strong> user’s machine. Provided that <strong>the</strong> service in question tolerates <strong>the</strong> HTTP<br />

headers that unavoidably come at <strong>the</strong> start of each request, an attacker can send<br />

arbitrary binary content within <strong>the</strong> message body to interact with <strong>the</strong> non-HTTP<br />

service. Many network services do in fact tolerate unrecognized input and still<br />

process subsequent input that is well-formed for <strong>the</strong> protocol in question.<br />

One technique for sending an arbitrary message body cross-domain was<br />

described in Chapter 12, in which an HTML form with <strong>the</strong> enctype attribute set<br />

to text/plain was used to send XML content to a vulnerable <strong>application</strong>. O<strong>the</strong>r<br />

techniques for delivering <strong>the</strong>se attacks are described in <strong>the</strong> following paper:<br />

www.ngssoftware.com/research/papers/InterProtocolExploitation.pdf<br />

Such interprotocol attacks may be used to perform unauthorized actions on<br />

<strong>the</strong> destination service or to exploit code-level vulnerabilities within that service<br />

to compromise <strong>the</strong> targeted server.<br />

Fur<strong>the</strong>rmore, in some situations, behavior in non-HTTP services may actually<br />

be exploitable to perform XSS attacks against <strong>web</strong> <strong>application</strong>s running on <strong>the</strong><br />

same server. Such an attack requires <strong>the</strong> following conditions to be met:<br />

n The non-HTTP service must be running on a port that is not blocked by<br />

browsers, as described previously.<br />

n The non-HTTP service must tolerate unexpected HTTP headers sent by<br />

<strong>the</strong> browser, and not just shut down <strong>the</strong> network connection when this<br />

happens. The former is common for many services, particularly those<br />

that are text-based.

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

Saved successfully!

Ooh no, something went wrong!