Home

Awesome

Static Badge GitHub last commit (branch) Static Badge Static Badge License

:star: Star us on GitHub — to show your support!

<p align="left"> <img width="100%" src="https://github.com/TH3xACE/res/blob/main/SK/sk-logo.gif" alt="logo"/> </p>

Twitter LinkedIn

:bulb: Best Viewed in Dark Mode :)

<a name="intro"></a>

Introduction

SUDO_KILLER is a tool geared towards cyber security practitioners (pentesters, security auditors, system admins, CTF players and Infosec students), facilitating privilege escalation within Linux environments. It focuses on vulnerabilities tied to SUDO usage, including misconfigurations in sudo rules, version-based weaknesses (CVEs and other vulnerabilities), and risky binary deployments (GTFOBINS). These weak points can be exploited to gain ROOT-level privileges or impersonate other users.

SUDO_KILLER provides a catalog of potential commands and local exploits for manual privilege elevation. Importantly, it refrains from automated exploitation, requiring users to carry out the exploitation process themselves as per its intended usage.

<a name="check"></a>

Checks

Below is a list of checks that are perform by SUDO_KILLER

[!WARNING] The check list above is NOT exhaustive.

<a name="usage"></a>

Usage

To get started with SUDO_KILLER, you can either git clone or download the zip. If you want to practice and/or test it, there is a vulnerable testing enviroment (using docker). See the related video which provides an overview on how to setup the docker and run SUDO_KILLER. Several scenarios can be setup in the docker environment and can be used for testing different misconfigurations or flaws. Alternatively, you can run it on the system to be audited to check for misconfigurations and/or flaws related to sudo.

./SUDO_KILLERv<version>.sh -c -a -e -r report.txt -p /tmp

Optional arguments: </br>-c : includes CVE checks</br> -a : includes CVEs related to third party apps/devices </br> -i : import (offline mode) from extract.sh </br> -e : include export of sudo rules / sudoers file </br> -r : report name (save the output) </br> -p : path where to save export and report </br> -s : supply user password for sudo checks (If sudo rules is not accessible without current user's password) </br> -h : help

[!NOTE] It is worth noting that when using the -c argument, two types of check are provided one for which the CVE identified is solely based on the current sudo version being used and another where the requirements are also checked. Very often, a sudo version might be vulnerable but some pre-requisites might be needed for a successful exploitation.

[!NOTE] Providing password: If a password is needed to run sudo -l then the script will not work if you don't provide a password with the argument -s.

<a name="docker"></a>

Docker (Vulnerable testing environment)

<p align="left"> <img width="25%" src="https://github.com/TH3xACE/res/blob/main/SK/docker.gif" alt="-dockerlogo"/> </p>

A range of Docker containers is made available to offer a deliberately vulnerable environment for testing and hands-on experimentation with SUDO_KILLER as well as with the vulnerabilities.

service docker start 
docker pull th3xace/sudo_killer_demo3
docker run --rm -it th3xace/sudo_killer_demo3
(This docker is only to test the CVE-2019-18634 (pwfeedback))
service docker start 
docker pull th3xace/sudo_killer_demo2
docker run --user 1000 --rm -it th3xace/sudo_killer_demo2

Why is it possible to run "sudo -l" without a password?

By default, if the NOPASSWD tag is applied to any of the entries for a user on a host, you will be able to run "sudo -l" without a password. This behavior may be overridden via the verifypw and listpw options.

However, these rules only affect the current user, so if user impersonation is possible (using su), sudo -l should be launched from this user as well.

Sometimes the file /etc/sudoers can be read even if sudo -l is not accessible without password.

<a name="scenarios"></a>

Scenarios

To switch scenario (To prevent conflicts between the different scenarios) on the docker (demo3):

switchScenario <scenario_number>

Available scenarios: 0 to 10
All Scenarios 0 : Conflict might occur!
Scenario 1: [2,3] CVE - Rules
Scenario 2: [4] Excessive permissions
Scenario 2: [5] Excessive permissions (Authentication required)
Scenario 3: [6] User Impersonation
Scenario 4: [7] Common Misconfiguration (Change owner)
Scenario 4: [8,11] Common Misconfiguration (Wildcard)
Scenario 5: [13] Missing scripts from sudo rules
Scenario 6: [17] Dangerous Environment Variables
Scenario 7: [18] Dangerous binaries (gtfobins)
Scenario 8: [19] Recursive Impersonation test
Scenario 9: [20] Environment Path Hijacking
Scenario 10: [21] App Specific sudo vuln/misconfig
Scenario 11: [5] Excessive permissions (Authentication required)
Scenario 12: [16] Backdooring sudo (Credentials Capture)

<a name="videos"></a>

Videos - Demo

Setup and exploitation

The playlist can be found here: https://www.youtube.com/watch?v=Q8iO9mYrfv8&list=PLQPKPAuCA40FMpMKWZLxQydLe7rPL5bml

[!IMPORTANT] Quick videos on how to properly do the testing on the provided docker.

<details open> <summary> (click to expand) Usage : How to setup and use the provided testing environment (docker) </summary> <br /> <p align="center"> <a href="#"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide1.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/VjXiLhmOmHs"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide2.JPG" alt="apis"/> </a> </p> <p></p> </p> </details>

[!WARNING] The video list below is not exhaustive, to have access to all the videos, please check the playlist link.

<details open> <summary> Several videos are provided below with different scenarios of exploitation. </summary> <br /> <p align="center"> <a href="https://youtu.be/rg6FxPuP8sQ"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide3.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/BBtoBrZdAKk"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide9.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/XiLsS9v3hy8"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide10.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/eBfIotMsDiI"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide11.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/a68dAmgeJnA"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide12.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/CILd01m2GBs"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide13.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/4xectsHBfCQ"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide14.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/11q5pzGJxvk"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide15.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/BbPBxXy4rKY"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide16.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/sfkxoR2a99o"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide17.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/SV2KPd4CA8A"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide18.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/6Lt-wKZmH9c"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide19.JPG" alt="apis"/> </a> </p> </details>

<a name="CVEs"></a>

CVEs

<details open> <summary> (click to expand) CVEs related to SUDO that SUDO_KILLER detects (including pre-requisites): </summary> <br /> <p align="center"> <a href="https://youtu.be/THS_bn4MOQY"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide4.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/6VkZaj3FDiE"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide5.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/LhqbExt5oq0"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide7.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/AJSSRrGt-Dw"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide8.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/elwGRlN7aCI"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide6.JPG" alt="apis"/> </a> &nbsp; </p> </details> <details open> <summary> (click to expand) Recent CVEs of 3rd party apps/devices related to sudo that SUDO_KILLER detects (including pre-requisites): </summary> <br /> <p align="center"> <a href="https://youtu.be/CP0S_7aZHxA"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide27.JPG" alt="apis"/> </a> &nbsp; </p> </details>

<a name="sk-tools"></a>

SK-Tools

Version 3 of SUDO_KILLER now includes a list of tools that can be used to achieve several tasks. The scripts are located at SUDO_KILLERv3/SUDO_KILLER/SK-Tools/

<details open> <summary> (click to expand) Usage : SK-Tools </summary> <br /> <p align="center"> <a href="https://youtu.be/Oc1yuploiME"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide20.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/aoofrCyb6KA"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide21.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/gUDuZVwVWyU"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide22.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/7VqNCgYvEa0"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide23.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/AG1o6s4dEF0"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide24.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/woF68JmJ33c"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide25.JPG" alt="apis"/> </a> </p> <p align="center"> <a href="https://youtu.be/R3_u-G5AyUw"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide26.JPG" alt="apis"/> </a> &nbsp; <a href="https://youtu.be/Vpr00SxIVgo"> <img width="39%" src="https://github.com/TH3xACE/res/blob/main/SK3/Slide28.JPG" alt="apis"/> </a> </p> </details> </br>

Capturing Credentials via sudo redirect (SK-credHarvest2.sh)

The script SK-credHarvest2.sh from SK-Tools allow to perform a credential capture by creating a fake sudo via alias then re-direct to real sudo. Actually works only for bash (not working/implemented for ZSH or else for now)configured linux.

The displayed message when asking for credential when using sudo differs from the version being used. It is possible to choose between two options (differ based on OS version). Example of the displayed message (new and old)

[!TIP] (new) [sudo] password for user: <br /> (old) Password:

For All Users (auser): When you have root privilege or excessive rights on users' home and you want an easy way to gather credentials:

./SK-credHarvest2.sh auser <new|old> ; source /home/*/.bashrc

For the currrent user (cuser):

./SK-credHarvest2.sh cuser <new|old> ; source /home/<currentuser>/.bashrc

[!CAUTION] TO STOP the credential harvesting: run the same script again with same argument

output: the log /tmp/sk-crds.log will contains the credentials

Alias' Audit (SK-alias-report.sh)

You will either need root privilege, access to a backup of sudoers or read access to /etc/sudoers.

Usage: ./SK-alias-sudoers.sh -p <sudoers_path> -k <keyword> [-u] [-r] [-m] [-c] | [-a]
  where -u: user | -r: runas | -m: host | -c: command | -a: all

Bruteforce/Password Spray via su (SK-su-BruteForce.sh)

Using su to bruteforce password and password spray with concurrency, timeout and sleep.

Usage: ./SK-su-BruteForce.sh [-h|--help] [-m|--module MODULE] [-u|--user USER|-uf|--userfile USERFILE] [-p|--password PASSWORD|-pf|--pwdfile PASSFILE] [-c|--concurrent CONCURRENT] [-s|--sleep SLEEP] [-t|--timeouts TIMEOUTS]

Module: Password Bruteforce : pwdbf
Example: ./SK-su-BruteForce.sh -m "pwdbf" -u user -pf password.txt -c 5 -s 0.005 -t 0.9

Module: Password Spray : pwdspr
Example: ./SK-su-BruteForce.sh -m pwdspr -uf users.txt -p password -c 5 -s 0.005 -t 0.9 

Module: User:Password Bruteforce : usrpwdbf
Example: ./SK-su-BruteForce.sh -m usrpwdbf -uf users-pwd.txt  -c 5 -s 0.005 -t 0.9 

Search for backup of the file sudoers (SK-search-sudoers.sh)

Find possible sudoers backup files in /mnt/ /opt/ /etc/ /etc/ /home/ /app*/ and any additional one parse as argument

Usage: ./SK-search-sudoers.sh /tmp/

Update dangerous bins - GTFOBINS (SK_dbins_update.sh)

To update the dangerous bins, go to dbins/update and run ./SK_dbins_update.sh. Make sure you have internet connection.

Usage: ./SK_dbins_update.sh

Binary Relative Path (SK-relative-path.sh)

Looking for binaries with relative path that be abused! if there is no secure_path set.

sudo -l
<..snip..>
(root) SETENV: NOPASSWD: /opt/support/purge.sh
<..snip..>

Usage: ./SK-relative-path.sh /opt/support/purge.sh

<a name="contribute"></a>

Contributing

SUDO_KILLER is an open-source project and highly appreciate any contributions. Whether you are helping us fix bugs, proposing new features, improving our documentation or spreading the word - we would love to have you as a contributor. Please reach me on twitter or Linkedin if you have any suggestions, feedback or want to contribute, you can also create a Pull Request. I am looking for contribution on the sudo CVEs related to 3rd party (I have a list of about 175) and any help would be appreciated.

<a name="stars"></a>

Stargazers over time

Thank you all for your support!

Stargazers over time

<a name="support"></a>

Support

<a href="https://www.patreon.com/TH3xACE"> <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"> </a>

<a name="credits"></a>

Credits

I crafted the script independently, leveraging online resources from GitHub and other sources in the wild. Acknowledgments are also due to the creators/publishers of exploits associated with the CVEs. You can trace back their details and references in the exploit itself, as well as in the accompanying notes when the tool is executed. Notable recognition extends to Vincent Puydoyeux, whose inspiration spurred the development of this tool, and Koutto, for invaluable assistance in handling Docker intricacies and enhancing the tool's functionality. Additionally, a heartfelt thank you goes out to Emilio Pinna (norbemi) and Andrea Cardaci (cyrus_and) for their invaluable contributions to GTFO Bins, which significantly influenced this project's development.

<a name="disclaimer"></a>

Disclaimer

This script is for educational purpose ONLY. Do not use it without permission of the owner of the system you are running it in. The usual disclaimer applies, especially the fact that me (TH3xACE) is not liable for any damages caused by direct or indirect use of the information or functionality provided by this project. The author (TH3xACE) or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using these programs you accept the fact that any damage (dataloss, system crash, system compromise, etc.) caused by the use of the script is not the author responsibility.

<a name="license"></a>

License

SUDO_KILLER is licensed under the MIT license, proper credits is expected whenever used. Please consider to donate for any commercial use.