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.

728 Chapter 19 n Finding Vulnerabilities in Source Code<br />

n gzfile<br />

n gzpassthru<br />

n readgzfile<br />

n copy<br />

n rename<br />

n rmdir<br />

n mkdir<br />

n unlink<br />

n file_get_contents<br />

n file_put_contents<br />

n parse_ini_file<br />

The following functions are used to include and evaluate a specified PHP<br />

script. If an attacker can cause <strong>the</strong> <strong>application</strong> to evaluate a file he controls, he<br />

can achieve arbitrary command execution on <strong>the</strong> server.<br />

n include<br />

n include_once<br />

n require<br />

n require_once<br />

n virtual<br />

Note that even if it is not possible to include remote files, command execution<br />

may still be possible if <strong>the</strong>re is a way to upload arbitrary files to a location<br />

on <strong>the</strong> server.<br />

The PHP configuration option allow_url_fopen can be used to prevent some<br />

file functions from accessing remote files. However, by default this option is<br />

set to 1 (meaning that remote files are allowed), so <strong>the</strong> protocols listed in Table<br />

19-8 can be used to retrieve a remote file.<br />

Table 19-8: Network Protocols That Can Be Used to Retrieve a Remote File<br />

PROTOCOL<br />

HTTP, HTTPS<br />

FTP<br />

SSH<br />

EXAMPLE<br />

http://wahh-attacker.com/bad.php<br />

ftp://user:password@wahh-attacker.com/bad.php<br />

ssh2.shell://user:pass@wahh-attacker.com:22/<br />

xterm<br />

ssh2.exec://user:pass@wahh-attacker.com:22/cmd

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

Saved successfully!

Ooh no, something went wrong!