Skip to content

Add systemd-tmpfiles.d persistence module (issue #36) - #41

Open
Diogo-Damasceno wants to merge 1 commit into
Aegrah:mainfrom
Diogo-Damasceno:feature/tmpfiles-persistence
Open

Add systemd-tmpfiles.d persistence module (issue #36)#41
Diogo-Damasceno wants to merge 1 commit into
Aegrah:mainfrom
Diogo-Damasceno:feature/tmpfiles-persistence

Conversation

@Diogo-Damasceno

Copy link
Copy Markdown

Summary

Implements persistence via systemd-tmpfiles.d as requested in #36.

What it does

  • New setup_tmpfiles module: drops a payload file and a tmpfiles.d unit
    (f <dest> 0644 root root - <payload>) that recreates the destination file
    whenever it is deleted
    — a self-healing persistence primitive. Supports
    --default (reverse-shell ip/port written to a profile.d payload) and
    --custom (payload/dest/conf/command). Applies with
    systemd-tmpfiles --create.
  • New revert_tmpfiles module: removes the conf, the re-created file and the payload.
  • Registered --tmpfiles in the main.sh dispatch + help, in modules/common.sh
    help and the revert-all module list. panix.sh regenerated via build.sh.

Verification (real, on Arch Linux)

  • --default --ip 10.10.10.10 --port 1337 created /etc/tmpfiles.d/panix-persist.conf, /usr/local/lib/.cache/.payload and /etc/profile.d/panix-persist.sh.
  • Deleting the profile.d file + systemd-tmpfiles --create <conf> recreated it (self-heal confirmed).
  • --revert tmpfiles removed all three artifacts.
  • bash -n panix.sh clean.

Note

This is a red-team / adversary-emulation tool; the technique is documented public MITRE ATT&CK behaviour (T1053-adjacent / tmpfiles abuse). Files are written under /etc and require root, matching every other PANIX module.

Implements persistence via systemd-tmpfiles.d as requested in Aegrah#36.

- New module modules/setup_tmpfiles.sh (setup_tmpfiles): drops a payload file
  and a tmpfiles.d unit ('f <dest> 0644 root root - <payload>') that recreates
  the destination whenever it is deleted, giving a self-healing persistence
  primitive. Supports --default (reverse shell ip/port) and --custom
  (payload/dest/conf/command). Runs 'systemd-tmpfiles --create' to apply.
- New module modules/revert/revert_tmpfiles.sh (revert_tmpfiles): removes the
  conf, the re-created file and the payload.
- Registered --tmpfiles in main.sh dispatch + help, in modules/common.sh help
  and the revert-all module list.
- Regenerated panix.sh via build.sh.

Verified on Arch Linux: --default created /etc/tmpfiles.d/panix-persist.conf,
/usr/local/lib/.cache/.payload and /etc/profile.d/panix-persist.sh; deleting the
profile.d file and running 'systemd-tmpfiles --create' recreated it (self-heal);
'--revert tmpfiles' removed all three artifacts. 'bash -n panix.sh' clean.
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