19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 21 n A Web Application Hacker’s Methodology 833<br />

7.4.5 If you believe that your input is being passed to an OS command of<br />

some kind, but <strong>the</strong> attack strings listed are unsuccessful, see if you can<br />

use <strong>the</strong> < or > character to direct <strong>the</strong> contents of a file to <strong>the</strong> command’s<br />

input or to direct <strong>the</strong> command’s output to a file. This may enable you<br />

to read or write arbitrary file contents. If you know or can guess <strong>the</strong><br />

actual command being executed, try injecting command-line parameters<br />

associated with that command to modify its behavior in useful ways<br />

(for example, by specifying an output file within <strong>the</strong> <strong>web</strong> root).<br />

7.4.6 If you find that <strong>the</strong> <strong>application</strong> is escaping certain key characters you need<br />

to perform a command injection attack, try placing <strong>the</strong> escape character<br />

before each such character. If <strong>the</strong> <strong>application</strong> does not escape <strong>the</strong> escape<br />

character itself, this usually leads to a bypass of this defensive measure.<br />

If you find that whitespace characters are blocked or sanitized, you may<br />

be able to use $IFS in place of spaces on UNIX-based platforms.<br />

7.5 Test for Path Traversal<br />

7.5.1 For each fuzz test you have performed, review <strong>the</strong> results generated<br />

by <strong>the</strong> path traversal attack strings listed in step 7.1.3. You can click <strong>the</strong><br />

top of <strong>the</strong> payload column in Burp Intruder to sort <strong>the</strong> results table by<br />

payload and group <strong>the</strong> results for <strong>the</strong>se strings. For any cases where<br />

an unusual error message or a response with an abnormal length was<br />

received, review <strong>the</strong> response manually to determine whe<strong>the</strong>r it contains<br />

<strong>the</strong> contents of <strong>the</strong> specified file or o<strong>the</strong>r evidence that an anomalous<br />

file operation occurred.<br />

7.5.2 In your mapping of <strong>the</strong> <strong>application</strong>’s attack surface, you should have<br />

noted any functionality that specifically supports <strong>the</strong> reading and writing<br />

of files on <strong>the</strong> basis of user-supplied input. In addition to <strong>the</strong> general<br />

fuzzing of all parameters, you should manually test this functionality<br />

very carefully to identify any path traversal vulnerabilities that exist.<br />

7.5.3 Where a parameter appears to contain a filename, a portion of a filename,<br />

or a directory, modify <strong>the</strong> parameter’s existing value to insert an<br />

arbitrary subdirectory and a single traversal sequence. For example, if<br />

<strong>the</strong> <strong>application</strong> submits this parameter:<br />

file=foo/file1.txt<br />

try submitting this value:<br />

file=foo/bar/../file1.txt<br />

If <strong>the</strong> <strong>application</strong>’s behavior is identical in <strong>the</strong> two cases, it may be<br />

vulnerable, and you should proceed to <strong>the</strong> next step. If <strong>the</strong> behavior<br />

is different, <strong>the</strong> <strong>application</strong> may be blocking, stripping, or sanitizing

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

Saved successfully!

Ooh no, something went wrong!