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 17 n Attacking Application Architecture 653<br />

A user can modify <strong>the</strong> country parameter to include arbitrary files. One<br />

possible attack might be to request URLs containing script commands so that<br />

<strong>the</strong>se are written to <strong>the</strong> <strong>web</strong> server log file and <strong>the</strong>n include this log file using<br />

<strong>the</strong> local file inclusion behavior.<br />

An interesting method exploiting an architectural quirk in PHP is that PHP<br />

session variables are written to file in cleartext, named using <strong>the</strong> session token.<br />

For example, <strong>the</strong> file:<br />

/var/lib/php5/sess_9ceed0645151b31a494f4e52dabd0ed7<br />

may contain <strong>the</strong> following content, which includes a user-configured nickname:<br />

logged_in|i:1;id|s:2:”24”;username|s:11:”manicsprout”;nickname|s:22:<br />

“msp”;privilege|s:1:”1”;<br />

An attacker may be able to exploit this behavior by first setting his nickname<br />

to , as shown in Figure 17-3. He can <strong>the</strong>n include his<br />

session file to cause <strong>the</strong> id command to be executed using <strong>the</strong> following URL,<br />

as shown in Figure 17-4:<br />

http://eis/mdsecportal/prefs/preference_2.php?country=../../../../../../<br />

../../var/lib/php5/sess_9ceed0645151b31a494f4e52dabd0ed7%00<br />

Figure 17-3: Configuring a nickname containing server-executable script code

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

Saved successfully!

Ooh no, something went wrong!