Git Product home page Git Product logo

cve-2022-0847-dirtypipe-exploits's Introduction

Dirty Pipe

CVE-2022-0847-DirtyPipe-Exploits

A collection of exploits and documentation for penetration testers and red teamers that can be used to aid the exploitation of the Linux Dirty Pipe vulnerability.

About The Vulnerability

  • Dirty Pipe (CVE-2022-0847) is a local privilege escalation vulnerability in the Linux kernel that could potentially allow an unprivileged user to do the following:
    • Modify/overwrite arbitrary read-only files like /etc/passwd.
    • Obtain an elevated shell.

Affected versions

DirtyPipe Vulnerability Scanner

Compiling the exploit

  • An automated compiler bash script has been provided to you to automate the compilation of both exploits.
  • In order to compile the exploit succesfully, you will need to have GCC installed.
sudo apt-get install gcc
  • After installing GCC, you can run the 'compile.sh" script as follows:
chmod +x compile.sh
./compile.sh

Exploit-1 - Modifying/overwriting read only files

  • This repo contains 2 exploits, the 'exploit-1.c' exploit can be used to modify or overwrite arbitrary read only files.
  • This exploit is a proof of concept that was developed by Max Kellermann and has been modified to change the root password in the /etc/passwd file, consequently providing you with access to an elevated shell.

Running the exploit binary

  • The exploit code has already been configured to replace the root password with the password "piped" and will take a backup of the /etc/passwd file under /tmp/passwd.bak. Furthermore, the exploit will also provide you with an elevated root shell and will restore the original passwd file when done.
./exploit-1

Exploit-2 - Hijacking SUID binaries

  • This exploit can be used to inject and overwrite data in read-only SUID process memory that run as root.

Finding SUID binaries

find / -perm -4000 2>/dev/null

Running the exploit binary

./exploit-2 /usr/bin/sudo

Important Note

  • I do not claim credit/ownership/disclosure of the vulnerability and all corresponding exploits hosted in this GitHub repo.
  • All the credit goes to the awesome Max Kellerman, you can check out the official disclosure here: https://dirtypipe.cm4all.com/

Credits

cve-2022-0847-dirtypipe-exploits's People

Contributors

alexisahmed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cve-2022-0847-dirtypipe-exploits's Issues

Compile error

exploit-1.c: In function 'prepare_pipe':
exploit-1.c:49:41: error: 'F_GETPIPE_SZ' undeclared (first use in this function)
const unsigned pipe_size = fcntl(p[1], F_GETPIPE_SZ);
^~~~~~~~~~~~
exploit-1.c:49:41: note: each undeclared identifier is reported only once for each function it appears in
exploit-1.c: In function 'main':
exploit-1.c:96:2: error: unknown type name 'loff_t'; did you mean 'lloff_t'?
loff_t offset = 4; // after the "root"
^~~~~~
lloff_t
exploit-1.c:106:8: error: unknown type name 'loff_t'
const loff_t next_page = (offset | (PAGE_SIZE - 1)) + 1;
^~~~~~
exploit-1.c:107:8: error: unknown type name 'loff_t'
const loff_t end_offset = offset + (loff_t)data_size;
^~~~~~
exploit-1.c:107:38: error: 'loff_t' undeclared (first use in this function); did you mean 'lloff_t'?
const loff_t end_offset = offset + (loff_t)data_size;
^~~~~~
lloff_t
exploit-1.c:107:45: error: expected ',' or ';' before 'data_size'
const loff_t end_offset = offset + (loff_t)data_size;
^~~~~~~~~
exploit-1.c:146:19: warning: implicit declaration of function 'splice'; did you mean 'stime'? [-Wimplicit-function-declaration]
ssize_t nbytes = splice(fd, &offset, p[1], NULL, 1, 0);
^~~~~~
stime
exploit-2.c: In function 'prepare_pipe':
exploit-2.c:102:44: error: 'F_GETPIPE_SZ' undeclared (first use in this function)
const unsigned pipe_size = fcntl(p[1], F_GETPIPE_SZ);
^~~~~~~~~~~~
exploit-2.c:102:44: note: each undeclared identifier is reported only once for each function it appears in
exploit-2.c: In function 'hax':
exploit-2.c:143:22: warning: implicit declaration of function 'splice'; did you mean 'stime'? [-Wimplicit-function-declaration]
ssize_t nbytes = splice(fd, &offset, p[1], NULL, 1, 0);
^~~~~~

Exploits not working on "vulnerable" machine.

Hi,

After watching your video on this exploit I wanted to see if it would work on the bandit machines from the overthewire challenges. Even though the dirty pipe checker says its vulnerable since the version is 5.15.0, when I run exploit 1 it says system() function failed and when I run exploit 2 it says /tmp/sh: permission denied. I've included a screenshot below. Any idea what's causing this? This machine should be vulnerable but its not working so did the guys from bandit labs somehow fix this without updating the kernel?

Thx!
Knipsel

Compile Issue for F_GETPIPE_SZ

exploit-1.c: In function 'prepare_pipe':
exploit-1.c:49:48: error: 'F_GETPIPE_SZ' undeclared (first use in this function)
49 | const unsigned pipe_size = fcntl(p[1], F_GETPIPE_SZ);
| ^~~~~~~~~~~~
exploit-1.c:49:48: note: each undeclared identifier is reported only once for each function it appears in
exploit-2.c: In function 'prepare_pipe':
exploit-2.c:102:44: error: 'F_GETPIPE_SZ' undeclared (first use in this function)
102 | const unsigned pipe_size = fcntl(p[1], F_GETPIPE_SZ);
| ^~~~~~~~~~~~
exploit-2.c:102:44: note: each undeclared identifier is reported only once for each function it appears in

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.