Note that using **PHP** you can **read and write files, create directories and change permissions**.
You can even **dump databases**.
Maybe using **PHP** to **enumerate** the box you can find a way to escalate privileges/execute commands.
I have created a webshell that makes very easy to perform this actions: [https://github.com/carlospolop/phpwebshelllimited](https://github.com/carlospolop/phpwebshelllimited)
Apart from eval there are other ways to execute PHP code: include/require can be used for remote code execution in the form of Local File Include and Remote File Include vulnerabilities.
**eval\(\)**
assert\(\) - identical to eval\(\)
**preg\_replace\('/.\*/e',...\)** - /e does an eval\(\) on the match
**create\_function\(\)** - Create a function and use eval\(\)
**$func = new ReflectionFunction\($\_GET\['func\_name'\]\);
$func->invoke\(\);** or
**$func->invokeArgs\(array\(\)\);
serialize/unserialize**
### List of functions which accept callbacks
These functions accept a string parameter which could be used to call a function of the attacker's choice. Depending on the function the attacker may or may not have the ability to pass a parameter. In that case an Information Disclosure function like phpinfo\(\) could be used.
Most of these function calls are not sinks. But rather it maybe a vulnerability if any of the data returned is viewable to an attacker. If an attacker can see phpinfo\(\) it is definitely a vulnerability.
**phpinfo**
**posix\_mkfifo**
**posix\_getlogin**
**posix\_ttyname**
**getenv**
**get\_current\_user**
**proc\_get\_status**
**get\_cfg\_var**
**disk\_free\_space**
**disk\_total\_space**
**diskfreespace**
**getcwd**
**getlastmo**
**getmygid**
**getmyinode**
**getmypid**
**getmyuid**
### Other
**extract** - Opens the door for register\_globals attacks \(see study in scarlet\).
**parse\_str** - works like extract if only one argument is given.
putenv
**ini\_set**
**mail** - has CRLF injection in the 3rd parameter, opens the door for spam.
**header** - on old systems CRLF injection could be used for xss or other purposes, now it is still a problem if they do a header\("location: ..."\); and they do not die\(\);. The script keeps executing after a call to header\(\), and will still print output normally. This is nasty if you are trying to protect an administrative area.
**proc\_nice**
**proc\_terminate**
**proc\_close**
**pfsockopen**
**fsockopen**
**apache\_child\_terminate**
**posix\_kill**
**posix\_mkfifo**
**posix\_setpgid**
**posix\_setsid**
**posix\_setuid**
### Filesystem Functions
According to RATS all filesystem functions in php are nasty. Some of these don't seem very useful to the attacker. Others are more useful than you might think. For instance if allow\_url\_fopen=On then a url can be used as a file path, so a call to copy\($\_GET\['s'\], $\_GET\['d'\]\); can be used to upload a PHP script anywhere on the system. Also if a site is vulnerable to a request send via GET everyone of those file system functions can be abused to channel and attack to another host through your server.
**Open filesystem handler**
**fopen**
**tmpfile**
**bzopen**
**gzopen**
**SplFileObject**->\_\_construct
**Write to filesystem \(partially in combination with reading\)**