Automatic Linux privesc via exploitation of low-hanging fruit

Traitor

Automatically exploit low-hanging fruit to pop a root shell. Linux privilege escalation made easy!

Traitor packages up a bunch of methods to exploit local misconfigurations and vulnerabilities (including most of GTFOBins) in order to pop a root shell.

Demo

It'll exploit most sudo privileges listed in GTFOBins to pop a root shell, as well as exploiting issues like a writable docker.sock. More routes to root will be added over time too.

Usage

Run with no arguments to find potential vulnerabilities/misconfigurations which could allow privilege escalation. Add the -p flag if the current user password is known. The password will be requested if it's needed to analyse sudo permissions etc.

traitor -p

Run with the -a/--any flag to find potential vulnerabilities, attempting to exploit each, stopping if a root shell is gained. Again, add the -p flag if the current user password is known.

traitor -a -p

Run with the -e/--exploit flag to attempt to exploit a specific vulnerability and gain a root shell.

traitor -p -e docker:writable-socket

Getting Traitor

Grab a binary from the releases page, or use go:

CGO_ENABLED=0 go get -u github.com/liamg/traitor/cmd/traitor

If the machine you're attempting privesc on cannot reach GitHub to download the binary, and you have no way to upload the binary to the machine over SCP/FTP etc., then you can try base64 encoding the binary on your machine, and echoing the base64 encoded string to | base64 -d > /tmp/traitor on the target machine, remembering to chmod +x it once it arrives.

Owner
Liam Galvin
Security Engineer @form3tech
Liam Galvin
Comments
  • Docker exploit mitigation

    Docker exploit mitigation

    (Note: I would ask this in a discussion but those haven't been setup yet- so another vote for enabling those: #70)

    Sorry if this is the wrong place to ask this question - but I searched these issues, and I searched the web, and I can't find anything good on it.

    Having docker.sock writable by the docker group is extremely handy/useful. However, I don't want to allow that as it results in this root exploit.

    Is there any way to have docker.sock writable but without enabling this exploit? Is it a fundamental problem with Docker's design? Seems like a big deal...

  • Build instructions incorrect?

    Build instructions incorrect?

    Hi, I'd like to install following these instructions from the README but am not sure how to get the binary built:

    CGO_ENABLED=0 go get -u github.com/liamg/traitor/cmd/traitor
    

    This creates a go/pkg folder with a bunch of subfolders, but I have no idea where the built binary is.

    Any help greatly appreciated! Using go 1.16.8.

  • Examples of how to misconfigure boxes

    Examples of how to misconfigure boxes

    The tool looks neat, but I tried running it on a fresh Vagrant instance as an unprivileged user and didn't se emuch:

    image

    Of course, it's a stock install and there are no services running on the box, but I think it would be neat if there were some instructions on example misconfigurations that could be made on a throwaway VM for Traitor to exploit.

    If you're willing to give me a list, I'd be happy to add some examples into the README and submit a PR!

  • Exploit failed: stat /bin/phNS9hpK_xJfOc: no such file or directory

    Exploit failed: stat /bin/phNS9hpK_xJfOc: no such file or directory

    Brandon-Ross-MacBook-Pro:Desktop bros$ CGO_ENABLED=0 go get -u github.com/liamg/traitor/cmd/traitor
    Brandon-Ross-MacBook-Pro:Desktop bros$ traitor
    
    
     888                    d8b 888                    
     888                    Y8P 888                    
     888                        888                    
     888888 888d888 8888b.  888 888888 .d88b.  888d888 
     888    888P"      "88b 888 888   d88""88b 888P"   
     888    888    .d888888 888 888   888  888 888     
     Y88b.  888    888  888 888 Y88b. Y88..88P 888     
      "Y888 888    "Y888888 888  "Y888 "Y88P"  888     
        v0.0.0 | https://github.com/liamg/traitor 
     
    [+] Assessing machine state...
    [+] Checking for opportunities...
    [+][docker:writable-socket] Docker socket at /var/run/docker.sock is writable!
    [+][docker:writable-socket] System is vulnerable! Run again with '--exploit docker:writable-socket' to exploit it.
    Brandon-Ross-MacBook-Pro:Desktop bros$ traitor --exploit docker:writable-socket
    
    
     888                    d8b 888                    
     888                    Y8P 888                    
     888                        888                    
     888888 888d888 8888b.  888 888888 .d88b.  888d888 
     888    888P"      "88b 888 888   d88""88b 888P"   
     888    888    .d888888 888 888   888  888 888     
     Y88b.  888    888  888 888 Y88b. Y88..88P 888     
      "Y888 888    "Y888888 888  "Y888 "Y88P"  888     
        v0.0.0 | https://github.com/liamg/traitor 
     
    [+] Assessing machine state...
    [+] Checking for opportunities...
    [+][docker:writable-socket] Docker socket at /var/run/docker.sock is writable!
    [+][docker:writable-socket] Opportunity found, trying to exploit it...
    [+][docker:writable-socket] Building malicious docker image...
    [+][docker:writable-socket] Creating evil container...
    [+][docker:writable-socket] Starting evil container...
    [+][docker:writable-socket] Backdooring host at /bin/phNS9hpK_xJfOc from guest...
    [+][docker:writable-socket] Checking permissions...
    [+][error] Exploit failed: stat /bin/phNS9hpK_xJfOc: no such file or directory
    [+] Continuing to look for opportunities
    [+] Nothing found to exploit.
    
  • Discussions

    Discussions

    Hey @liamg let's open up Discussions on this repo (Under Settings). Some of the issues that come by are not really tangible things to write code and submit pull-requests for 😅

  • Please add a specific test skip option

    Please add a specific test skip option

    Please add an option to skip specific test or add option to force continuation of tests even if you encountered a privesc. In this way, the tool is no longer a tool used only for privesc and becomes a used audit tool as well.

  • Run the program without checking exp

    Run the program without checking exp

    image I run the program on several different computers, but there is no test vulnerability information, as shown in the figure. Is it because I don't have an exp。 Or because the server does not have vulnerabilities

  • Add support for the new CVE-2022-2588

    Add support for the new CVE-2022-2588

    • Source: https://github.com/Markakd/CVE-2022-2588 Would be cool if you can implement it, but it seems that it doesn't compile on arm64 system (or atleast not out of the box), lets see if you can do something about it
  • Add support for CVE-2022-29799 & CVE-2022-29800 (Nimbuspwn)

    Add support for CVE-2022-29799 & CVE-2022-29800 (Nimbuspwn)

    • Microsoft writeup: https://www.microsoft.com/security/blog/2022/04/26/microsoft-finds-new-elevation-of-privilege-linux-vulnerability-nimbuspwn/
    • Python PoC: https://github.com/Immersive-Labs-Sec/nimbuspwn/blob/main/nimbuspwn.py
    • Vulnerability detection (shell): https://github.com/jfrog/nimbuspwn-tools/blob/main/nimbuspwn-detector.sh
    • Golang dbus library: https://github.com/godbus/dbus
  • Add support for CVE-2022-29582 and you will not believe what will happen next!

    Add support for CVE-2022-29582 and you will not believe what will happen next!

    https://github.com/Ruia-ruia/CVE-2022-29582-Exploit this is the source. Hope it will take not much time. Thank you.

    Ah, sorry for the clickbait title, but you see, it works!

  • `kernel:CVE-2022-0847` tweak: clarity with affected versions

    `kernel:CVE-2022-0847` tweak: clarity with affected versions

    I ran v0.0.14 on a fully-patched (at least as far as apt permits) Ubuntu 22.04LTS, and got this result:

    ▀█▀ █▀█ ▄▀█ █ ▀█▀ █▀█ █▀█
    ░█░ █▀▄ █▀█ █ ░█░ █▄█ █▀▄ v0.0.14
    https://github.com/liamg/traitor
    
    [+] Assessing machine state...
    [+] Checking for opportunities...
    [+][kernel:CVE-2022-0847] Kernel version 5.15.0 is vulnerable!
    [+][kernel:CVE-2022-0847] System is vulnerable! Run again with '--exploit kernel:CVE-2022-0847' to exploit it.
    

    Checking the installed kernel version, I get this:

    $ cat /proc/version_signature
    Ubuntu 5.15.0-25.25-generic 5.15.30
    

    According to the vendor (see https://ubuntu.com/kernel for details), the mainline kernel release is the 5.15.30 part. According to NIST (see https://nvd.nist.gov/vuln/detail/CVE-2022-0847), the CVE details state that 5.15.0 to 5.15.24 are affected, with 5.15.25 and newer not affected.

    Given that Ubuntu LTS is a relatively popular choice among server operating systems – and 22.04 is the most recent LTS cut – it might be worth clarifying what kernel versions are affected by CVE-2022-0847 at a patch release level instead of minor release branch.

    Thanks for your consideration.

  • Exploit CVE-2022-0847 terminates with error

    Exploit CVE-2022-0847 terminates with error

    Hi,

    I am using the command: ./traitor --exploit kernel:CVE-2022-0847

    It seem to work, but terminates with an error: [+][error] Exploit failed: invalid password (see below).

    In /etc/passwd: traitor4242:x:1001:1001:CVE-2021-3560,,,:/home/traitor4242:/bin/bash In /etc/shadow: traitor4242:!:19092:0:99999:7::: In /etc/group: sudo:x:27:thomas,traitor4242

    Is there a reason, why it terminates with an error ? Thanks for help Thomas

    ▀█▀ █▀█ ▄▀█ █ ▀█▀ █▀█ █▀█ ░█░ █▀▄ █▀█ █ ░█░ █▄█ █▀▄ v0.0.0 https://github.com/liamg/traitor

    [+] Assessing machine state... [+] Checking for opportunities... [+][kernel:CVE-2022-0847] Kernel version 5.13.0 is vulnerable! [+][kernel:CVE-2022-0847] Opportunity found, trying to exploit it... [+][kernel:CVE-2022-0847] Attempting to set root password... [+][kernel:CVE-2022-0847] Opening '/etc/passwd' for read... [+][kernel:CVE-2022-0847] Creating pipe... [+][kernel:CVE-2022-0847] Determining pipe size... [+][kernel:CVE-2022-0847] Pipe size is 65536. [+][kernel:CVE-2022-0847] Filling pipe... [+][kernel:CVE-2022-0847] Draining pipe... [+][kernel:CVE-2022-0847] Pipe drained. [+][kernel:CVE-2022-0847] Splicing data... [+][kernel:CVE-2022-0847] Writing to dirty pipe... [+][kernel:CVE-2022-0847] Write of '/etc/passwd' successful! [+][kernel:CVE-2022-0847] Starting shell... [+][kernel:CVE-2022-0847] Please exit the shell once you are finished to ensure the contents of /etc/passwd is restored. [+][kernel:CVE-2022-0847] Setting up tty... [+][kernel:CVE-2022-0847] Attempting authentication as root... [+][kernel:CVE-2022-0847] Restoring contents of /etc/passwd... [+][kernel:CVE-2022-0847] Opening '/etc/passwd' for read... [+][kernel:CVE-2022-0847] Creating pipe... [+][kernel:CVE-2022-0847] Determining pipe size... [+][kernel:CVE-2022-0847] Pipe size is 65536. [+][kernel:CVE-2022-0847] Filling pipe... [+][kernel:CVE-2022-0847] Draining pipe... [+][kernel:CVE-2022-0847] Pipe drained. [+][kernel:CVE-2022-0847] Splicing data... [+][kernel:CVE-2022-0847] Writing to dirty pipe... [+][kernel:CVE-2022-0847] Write of '/etc/passwd' successful! [+][error] Exploit failed: invalid password [+] Continuing to look for opportunities [+] Nothing found to exploit. thomas@thomas-ThinkPad-E15:~/traitor$

A scanner/exploitation tool written in GO, which leverages Prototype Pollution to XSS by exploiting known gadgets.
A scanner/exploitation tool written in GO, which leverages Prototype Pollution to XSS by exploiting known gadgets.

ppmap A simple scanner/exploitation tool written in GO which automatically exploits known and existing gadgets (checks for specific variables in the g

Jan 9, 2023
Exploitation of CVE-2018-18925 a Remote Code Execution against the Git self hosted tool: Gogs.
Exploitation of CVE-2018-18925 a Remote Code Execution against the Git self hosted tool: Gogs.

CVE-2018-18925 Exploitation of CVE-2018-18925 a Remote Code Execution against the Git self hosted tool: Gogs. Gogs is based on the Macaron framework.

Nov 9, 2022
A FreeSWITCH specific scanning and exploitation toolkit for CVE-2021-37624 and CVE-2021-41157.

PewSWITCH A FreeSWITCH specific scanning and exploitation toolkit for CVE-2021-37624 and CVE-2021-41157. Related blog: https://0xinfection.github.io/p

Nov 2, 2022
:lock: acmetool, an automatic certificate acquisition tool for ACME (Let's Encrypt)
:lock: acmetool, an automatic certificate acquisition tool for ACME (Let's Encrypt)

acmetool is an easy-to-use command line tool for automatically acquiring certificates from ACME servers (such as Let's Encrypt). Designed to flexibly

Dec 29, 2022
Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal
Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal

Easy and Powerful TLS Automation The same library used by the Caddy Web Server Caddy's automagic TLS features—now for your own Go programs—in one powe

Jan 6, 2023
A rest application to update firewalld rules on a linux server

Firewalld-rest A REST application to dynamically update firewalld rules on a linux server. Firewalld is a firewall management tool for Linux operating

Jan 2, 2023
Tracee: Linux Runtime Security and Forensics using eBPF
Tracee: Linux Runtime Security and Forensics using eBPF

Tracee is a Runtime Security and forensics tool for Linux. It is using Linux eBPF technology to trace your system and applications at runtime, and analyze collected events to detect suspicious behavioral patterns.

Jan 5, 2023
Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices
Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices

Vuls: VULnerability Scanner Vulnerability scanner for Linux/FreeBSD, agent-less, written in Go. We have a slack team. Join slack team Twitter: @vuls_e

Jan 9, 2023
Jan 6, 2023
golang users friendly linux hacking library.
golang users friendly linux hacking library.

go-cheat users friendly linux hacking library

Nov 9, 2022
Find vulnerable versions of Log4j on Linux

log4jtool Find vulnerable versions of Log4j on Linux This tool does not change a

Jan 14, 2022
Golang Port Knocking for Linux + Windows

Vishnu(The Hidden Backdoor) RS{JOIN_REDTEAM} Taken from the Trimurit, the triple deity of supreme divinity. Vishnu is known as "The Preserver". This p

Nov 9, 2022
Scan for viruses by shelling out to clamav (streaming via stdin)

clamscan This is currently just an example program, but will eventually be a small library. ClamAV has functionality for performing a streaming scan o

Jan 12, 2022
vRealize RCE + Privesc (CVE-2021-21975, CVE-2021-21983, CVE-0DAY-?????)
vRealize RCE + Privesc (CVE-2021-21975, CVE-2021-21983, CVE-0DAY-?????)

REALITY_SMASHER vRealize RCE + Privesc (CVE-2021-21975, CVE-2021-21983, CVE-0DAY-?????) "As easy to stop as it is to comprehend." What is it? "Reality

Nov 9, 2022
Setgroups hanging bug while using golang

Setgroups hanging bug while using golang 1.16+ 1. How to reproduce 1.1 Build docker image build the test image docker build --build-arg=GOPROXY=$GOPRO

Dec 13, 2021
A project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol formatA project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format

Intro This project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format. It integrates nicely with the Telegraf execd inpu

Apr 15, 2022
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).

中文 English 愿景:为用户提供最简单、可靠、高效的分布式文件系统。 go-fastdfs是一个基于http协议的分布式文件系统,它基于大道至简的设计理念,一切从简设计,使得它的运维及扩展变得更加简单,它具有高性能、高可靠、无中心、免维护等优点。 大家担心的是这么简单的文件系统,靠不靠谱,可不

Jan 8, 2023
Webserver I built to serve Infura endpoints. Deployable via k8s and AWS EKS. Load testable via k6 tooling, and montiorable via prometheus and grafana

Infura Web Server Welcome to my verion of the take home project. I've created a webserver written in go to serve Infura api data over 3 possible data

Nov 15, 2022
Lima launches Linux virtual machines on macOS, with automatic file sharing, port forwarding, and containerd.

Lima: Linux-on-Mac ("macOS subsystem for Linux", "containerd for Mac")

Jan 8, 2023