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 10 n Attacking Back-End Components 373<br />

HACK STEPS<br />

1. If <strong>the</strong> <strong>application</strong> function you are attacking provides read access to a file,<br />

attempt to access a known world-readable file on <strong>the</strong> operating system in<br />

question. Submit one of <strong>the</strong> following values as <strong>the</strong> filename parameter<br />

you control:<br />

../../../../../../../../../../../../etc/passwd<br />

../../../../../../../../../../../../windows/win.ini<br />

If you are lucky, your browser displays <strong>the</strong> contents of <strong>the</strong> file you have<br />

requested, as shown in Figure 10-5.<br />

2. If <strong>the</strong> function you are attacking provides write access to a file, it may be<br />

more difficult to verify conclusively whe<strong>the</strong>r <strong>the</strong> <strong>application</strong> is vulnerable.<br />

One test that is often effective is to attempt to write two files — one<br />

that should be writable by any user, and one that should not be writable<br />

even by root or Administrator. For example, on Windows platforms you<br />

can try this:<br />

../../../../../../../../../../../../writetest.txt<br />

../../../../../../../../../../../../windows/system32/config/sam<br />

On UNIX-based platforms, files that root may not write are versiondependent,<br />

but attempting to overwrite a directory with a file should<br />

always fail, so you can try this:<br />

../../../../../../../../../../../../tmp/writetest.txt<br />

../../../../../../../../../../../../tmp<br />

For each pair of tests, if <strong>the</strong> <strong>application</strong>’s behavior is different in<br />

response to <strong>the</strong> first and second requests (for example, if <strong>the</strong> second<br />

returns an error message but <strong>the</strong> first does not), <strong>the</strong> <strong>application</strong> probably<br />

is vulnerable.<br />

3. An alternative method for verifying a traversal flaw with write access is<br />

to try to write a new file within <strong>the</strong> <strong>web</strong> root of <strong>the</strong> <strong>web</strong> server and <strong>the</strong>n<br />

attempt to retrieve this with a browser. However, this method may not<br />

work if you do not know <strong>the</strong> location of <strong>the</strong> <strong>web</strong> root directory or if <strong>the</strong><br />

user context in which <strong>the</strong> file access occurs does not have permission to<br />

write <strong>the</strong>re.

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

Saved successfully!

Ooh no, something went wrong!