Dirty COW - Privilege Escalation (CVE-2016-5195)
This project demonstrates a privilege escalation using the Dirty COW vulnerability in a virtual machine with Ubuntu Server 16.04.1 and kernel 4.4.0-31-generic.
🔧 Environment
- Victim machine: Ubuntu 16.04.1 vulnerable (student without privileges)
- Attacker machine: Kali Linux with Docker installed
🐮 Vulnerability
Dirty COW (CVE-2016-5195) is a race condition in the memory subsystem of the Linux kernel. It allows an unprivileged user to modify read-only files and escalate privileges to root.
- Verified the vulnerable kernel on the victim machine (uname -a)
- Prepared the Docker environment on Kali with Ubuntu 16.04.1
- Created the dirty.cpp file with the exploit code (Exploit-DB ID: 40847)
- Compiled the binary inside the container with g++
- Exited the container and copied the binary to Kali
- Transferred the binary to the victim machine using scp
- On the victim machine, I gave it execute permissions and ran it:
- The exploit returned a root password (dirtyCowFun) and I accessed as root with that root account.
✅ Result
The exploit was successful. Root access was obtained from a limited user.
📁 Repository contents
- dirty: compiled binary of the exploit
- README.md: this explanatory file