Skip to content

New GTFOBin: getent for extracting privileged NSS entries via SUID #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thegreatmhn
Copy link


description: |
getent is a command-line utility used to fetch entries from administrative databases
configured in the system’s Name Service Switch (NSS), such as passwd, group, hosts,
and critically, shadow. While most of these databases are readable by regular users,
the shadow database is highly sensitive, containing hashed passwords for all system
accounts, including root.

Under normal circumstances, getent requires root privileges to access the shadow database.
However, if the getent binary has the SUID bit set, a low-privileged user can abuse it to
retrieve password hashes, thus violating the integrity of the authentication system.

The attacker can extract these hashes and then perform offline cracking using tools like
john or hashcat. This is a stealthy and shell-less method of privilege escalation that
works in restricted environments and minimal systems where only core utilities exist.

This abuse works without invoking an interactive shell, interpreter, or script engine, and
relies purely on the logic of getent and the SUID bit — making it a candidate for
inclusion in GTFOBins under the suid vector.

Example:

./getent shadow root
# root:$6$saltsalt$abc...xyz:19429:0:99999:7:::

---
description: |
  `getent` is a command-line utility used to fetch entries from administrative databases 
  configured in the system’s Name Service Switch (NSS), such as `passwd`, `group`, `hosts`, 
  and critically, `shadow`. While most of these databases are readable by regular users, 
  the `shadow` database is highly sensitive, containing hashed passwords for all system 
  accounts, including `root`.

  Under normal circumstances, `getent` requires root privileges to access the `shadow` database. 
  However, if the `getent` binary has the SUID bit set, a low-privileged user can abuse it to 
  retrieve password hashes, thus violating the integrity of the authentication system.

  The attacker can extract these hashes and then perform offline cracking using tools like 
  `john` or `hashcat`. This is a stealthy and shell-less method of privilege escalation that 
  works in restricted environments and minimal systems where only core utilities exist.

  This abuse works without invoking an interactive shell, interpreter, or script engine, and 
  relies purely on the logic of `getent` and the SUID bit — making it a candidate for 
  inclusion in GTFOBins under the `suid` vector.

  Example:
  ```bash
  ./getent shadow root
  # root:$6$saltsalt$abc...xyz:19429:0:99999:7:::
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant