This PHP script establishes a remote shell session with a server running on 127.0.0.1 (localhost) at port 1337. It provides basic functionality to execute commands on the remote server and retrieve system information.
-
System Information Display:
- Hostname
- Local IP address
- Public IP address (retrieved from
http://ifconfig.me/ip) - Operating System details
- PHP version
- System architecture
-
Remote Command Execution:
- Allows execution of shell commands via the remote shell interface.
- Outputs command results back to the remote client.
-
ASCII Art Banner:
- Displays a custom banner when a connection is successfully established.
- A PHP environment must be set up on the host machine.
- Ensure that port
1337is open and not blocked by a firewall. - The script requires an internet connection to fetch the public IP address.
- Place the script on your PHP-enabled server.
- Start a listener on the remote machine using a tool like
netcat. For example:nc -lvnp 1337
- Execute the PHP script.
- Upon connection, the script will send system information and provide a shell prompt.
- Enter any shell command in the remote shell to execute it on the host machine.
- Use the
exitcommand to terminate the session.
ipv4(): Fetches the public IP address usinghttp://ifconfig.me/ip.
$ascii: Contains ASCII art displayed upon connection.$sock: The socket connection to the remote client.
- Establishes a socket connection to
127.0.0.1on port1337. - Retrieves system details such as hostname, IP addresses, OS details, and PHP version.
- Sends the information and a shell prompt to the client.
- Continuously listens for commands from the client and executes them until
exitis received.
- Localhost Restriction: The script is currently set to connect only to
127.0.0.1. Modify this for other use cases, but be cautious. - Shell Access: Executing arbitrary shell commands poses a security risk. Use this script in controlled environments only.
- Public IP API: The script uses
http://ifconfig.me/ipto fetch the public IP address. Ensure this service is reliable and trusted.
This script is intended for educational purposes or controlled environments. Misuse of this script can lead to security vulnerabilities. Use responsibly and ensure proper authorization before executing on any system.