The implant kept coming back through a cron entry, a service unit, and a binary on disk. The attacker shreds all three, and every enumeration of persistence locations finds nothing. This file runs that clearing, then reads the manifest that predates the attacker, restores the artifacts from the known-good backup, and gates the locations behind root-only writes.
MITRE ATT&CK T1070.009: adversaries clear artifacts of previously established persistence, removing services, deleting executables, deleting accounts, to deny defenders the evidence of how the implant kept coming back. This file runs that clearing end to end, then detects it from a manifest that predates the attacker. Two actors: the attacker, who owns the lab directory, the persistence artifacts, and the shred; and the defender, who owns the manifest reads, the restore, and every inventory in the blue phase.
Why this technique. Persistence is an anchor, and an anchor is evidence. While the implant is running, the attacker wants the anchor: the cron entry that relaunches it every five minutes, the service unit that restarts it, the binary on disk. Once the implant has moved on, or once the defender is closing in, the anchor becomes a liability. Every persistence artifact is a labeled arrow pointing at the attacker's method. Clearing them removes the arrow. The defender still finds the intrusion, but the how-it-kept-coming-back is gone, and without it the defender cannot scope the incident, cannot be sure the implant is really dead, and cannot harden the right door.
Why not hide the persistence instead. The obvious alternative is hiding inside the listing: dotfiles and deep paths. Break it on the concrete input: a sha256 inventory still lists the files, because the artifacts exist on disk for any recursive sweep. Hiding only beats a casual glance. The attacker here needs the artifact to not exist at all, because the defender's question is not "what is in this directory" but "what was here, with hashes". Clearing removes the artifact entirely, at the cost of the directory-mtime scar and the manifest gap, which the blue phase reads.
Why not timestomp the artifacts into the background. The other obvious alternative is timestomping the files into the past. Break it: you cannot timestomp a file you need gone. The bytes remain on disk for carving, and the persistence mechanism itself still works, which is the opposite of the attacker's goal once the anchor must die. Clearing is for when the persistence has done its job and the implant has moved on. Timestamps hide a file's story; clearing removes the file.
Why not clear the command history. The third alternative is clearing the shell history to hide the clearing commands. Break it: the history covers the attacker's keystrokes, not the missing files. The manifest gap is independent of what was typed. A defender with a manifest that predates the attacker does not need the attacker's keystrokes. The history is the wrong evidence to protect.
The mechanism, in one line. Persistence is a mechanism that runs the implant again after reboot or on schedule: a cron entry, a service unit, a startup script. Indicator removal is deleting or modifying artifacts the adversary's own activity created, to remove evidence of the presence or hinder defenses. A baseline manifest is a sha256 inventory of the known-good state, taken before the attacker arrives: the independent observation path, because it describes what should be here regardless of what is here now. A directory mtime is a directory's modification timestamp, updated whenever entries are added or removed: the scar deletions leave, because removing a file changes its parent directory. Terms earned, no borrowing.
The concrete case, before the abstraction. Three artifacts live in /tmp/gh016/persist: cron.d/persist launches the implant every five minutes, units/persist.service is the unit stand-in, bin/implant.sh is the inert payload, never executed. The defender's manifest holds all three hashes. shred -u removes all three, overwriting before unlinking. After: ls -R shows empty directories, grep finds no gh016 strings anywhere. The defender's manifest check reports FAILED open or read on all three. One shred, three empty directories, one manifest that refuses to agree.
Scope. T1070.009 covers clearing persistence broadly: removing services, deleting executables, modifying registries and plists, deleting accounts. This file works the Linux service-and-binary case end to end: the cron entry, the unit, the executable, the shred, the manifest detection, the backup restore, the permission gate, and the scheduled inventory. The lab runs in a disposable namespace because the attack destroys evidence by design; the backup and the manifest are the defender's earlier inventory, made before the attacker acts.
Ubuntu 24.04.5 LTS, x86-64, in a disposable namespace used only for this lab. Runs as root: the lab owns its own cron.d and unit stand-ins inside /tmp/gh016, and the permission gate in the blue phase demonstrates the refusal, not describes it. Everything the lab touches lives inside /tmp/gh016, so cleanup is a single rm.
One disposable directory, built from scratch. rm -rf /tmp/gh016 clears any earlier take; mkdir -p makes the three persistence locations and the backup directory. The three artifacts go in through heredocs. cron.d/persist is the cron.d-format entry launching the implant every five minutes. units/persist.service is the systemd unit stand-in. bin/implant.sh is the stand-in for the payload the persistence would launch: kept, never run. Then the defender's earlier inventory, made before the attacker: cp -r the known-good copies into backup, and sha256sum writes the manifest. The final ls -R proves the lab built: three locations, three files.
$ rm -rf /tmp/gh016 && mkdir -p /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin /tmp/gh016/backup && cat > /tmp/gh016/persist/cron.d/persist <<'EOF' # gh016 persistence: cron.d-format entry, runs the implant every 5 minutes */5 * * * * root /tmp/gh016/persist/bin/implant.sh EOF cat > /tmp/gh016/persist/units/persist.service <<'EOF' [Unit] Description=gh016 persistence stand-in (never enabled, never run) [Service] ExecStart=/tmp/gh016/persist/bin/implant.sh Restart=always [Install] WantedBy=multi-user.target EOF cat > /tmp/gh016/persist/bin/implant.sh <<'EOF' #!/bin/sh # Stand-in for the payload the persistence would launch: kept, never run. # The point is the mechanism, not the malware. echo "this file is never executed" exit 0 EOF chmod +x /tmp/gh016/persist/bin/implant.sh && cp -r /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin /tmp/gh016/backup/ && (cd /tmp/gh016 && sha256sum persist/cron.d/persist persist/units/persist.service persist/bin/implant.sh > manifest.txt) && echo "lab built: /tmp/gh016"; ls -R /tmp/gh016/persist lab built: /tmp/gh016 /tmp/gh016/persist: bin cron.d units /tmp/gh016/persist/bin: implant.sh /tmp/gh016/persist/cron.d: persist /tmp/gh016/persist/units: persist.service
This is what normal looks like, recorded before the clearing. cat shows the cron entry and the unit in full. Then the manifest check: (cd /tmp/gh016 && sha256sum -c manifest.txt) reports OK on all three. This is the baseline the defender trusts, and the blue phase will compare everything against it.
$ echo "--- the before view: what normal looks like ---"; cat /tmp/gh016/persist/cron.d/persist; echo; cat /tmp/gh016/persist/units/persist.service; echo "--- the defender trusts this manifest (taken before the attacker) ---"; (cd /tmp/gh016 && sha256sum -c manifest.txt) --- the before view: what normal looks like --- # gh016 persistence: cron.d-format entry, runs the implant every 5 minutes */5 * * * * root /tmp/gh016/persist/bin/implant.sh [Unit] Description=gh016 persistence stand-in (never enabled, never run) [Service] ExecStart=/tmp/gh016/persist/bin/implant.sh Restart=always [Install] WantedBy=multi-user.target --- the defender trusts this manifest (taken before the attacker) --- persist/cron.d/persist: OK persist/units/persist.service: OK persist/bin/implant.sh: OK
First the before view, then the shred, then the attacker's confirmation that enumeration finds nothing.
shred -u overwrites all three artifacts before unlinking them: the cron entry, the unit, the implant binary. shred is silent on success: the evidence is what enumeration says after. ls -R shows empty directories, with the (empty directories) marker. grep -ri gh016 finds no strings anywhere under persist. The persistence locations are still there; what made them persistence is gone.
$ echo "--- the attack: shred the persistence artifacts ---"; shred -u /tmp/gh016/persist/cron.d/persist /tmp/gh016/persist/units/persist.service /tmp/gh016/persist/bin/implant.sh; echo "--- the after view: every persistence location, enumerated ---"; ls -R /tmp/gh016/persist; echo '(empty directories)'; grep -ri gh016 /tmp/gh016/persist 2>/dev/null || echo '(no gh016 strings anywhere)' --- the attack: shred the persistence artifacts --- --- the after view: every persistence location, enumerated --- /tmp/gh016/persist: bin cron.d units /tmp/gh016/persist/bin: /tmp/gh016/persist/cron.d: /tmp/gh016/persist/units: (empty directories) (no gh016 strings anywhere)
Three echo lines, the attacker's summary: the cron entry, the unit, and the implant are gone; there is nothing left to inventory; enumeration finds nothing. The attacker is counting on no manifest existing: without a baseline, "nothing here" is indistinguishable from "nothing was ever here".
$ echo "stealth confirmed: the cron entry, the unit, and the implant are gone"; echo "there is nothing left to inventory; enumeration finds nothing"; echo "the attacker is counting on no manifest existing" stealth confirmed: the cron entry, the unit, and the implant are gone there is nothing left to inventory; enumeration finds nothing the attacker is counting on no manifest existing
The cron entry, the service unit, and the implant binary went through shred -u, and every persistence enumeration came back empty: empty directories, no strings, no artifacts. The mechanism that kept the implant coming back no longer exists on disk. The attack works because nothing independent describes what was here.
The defender does not trust the listing. The defender reads the manifest that predates the attacker: detect from the independent inventory, record before touching, restore from the known-good backup, then gate the locations and inventory the manifest on a schedule.
Here is the trap: running ls, seeing empty directories, and calling the persistence locations clean. That is trusting the same enumeration the attacker just emptied. The detection is the manifest check: sha256sum -c against the known-good inventory, while the clearing is still in effect.
ls -R shows empty directories: the naive view says clean. Then the independent path. sha256sum -c manifest.txt reports FAILED open or read on all three artifacts: the manifest describes files that no longer exist. Then the scar: stat -c '%y %n' on the persist directories shows the mtimes moved when the entries were removed, even though the directories read empty. Good versus bad, concrete: good is the manifest reporting OK; bad is missing-from-baseline plus fresh directory mtimes with no change record. The three FAILED lines in the output are the detection: the manifest names files the disk no longer has.
$ echo "--- DETECTION: the naive view first ---"; ls -R /tmp/gh016/persist; echo '(looks clean: empty directories)'; echo "--- the independent path: the manifest that predates the attacker ---"; (cd /tmp/gh016 && sha256sum -c manifest.txt) 2>&1; echo "--- the scar: directory mtimes moved when the entries were removed ---"; stat -c '%y %n' /tmp/gh016/persist /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin; echo "good: manifest OK"; echo "bad: missing-from-baseline plus fresh directory mtimes with no change record" --- DETECTION: the naive view first --- /tmp/gh016/persist: bin cron.d units /tmp/gh016/persist/bin: /tmp/gh016/persist/cron.d: /tmp/gh016/persist/units: (looks clean: empty directories) --- the independent path: the manifest that predates the attacker --- sha256sum: persist/cron.d/persist: No such file or directory persist/cron.d/persist: FAILED open or read sha256sum: persist/units/persist.service: No such file or directory persist/units/persist.service: FAILED open or read sha256sum: persist/bin/implant.sh: No such file or directory persist/bin/implant.sh: FAILED open or read sha256sum: WARNING: 3 listed files could not be read --- the scar: directory mtimes moved when the entries were removed --- 2026-09-21 23:18:56.199479176 +0000 /tmp/gh016/persist 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/cron.d 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/units 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/bin good: manifest OK bad: missing-from-baseline plus fresh directory mtimes with no change record
The manifest diff and the directory mtimes go into evidence.txt BEFORE anything is touched: restoring disturbs the scene, so the evidence is recorded first. Then the restore: cp the three artifacts back from the known-good backup the manifest describes, chmod +x the implant back to executable, and sha256sum -c reports OK on all three. The manifest is the truth; the backup is the recovery. The tell closes only when every hash checks.
$ echo "--- record the evidence BEFORE touching anything ---"; ((cd /tmp/gh016 && sha256sum -c manifest.txt); stat -c '%y %n' /tmp/gh016/persist /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin) > /tmp/gh016/evidence.txt 2>&1; cat /tmp/gh016/evidence.txt; echo "--- restore from the known-good backup the manifest describes ---"; cp /tmp/gh016/backup/cron.d/persist /tmp/gh016/persist/cron.d/persist && cp /tmp/gh016/backup/units/persist.service /tmp/gh016/persist/units/persist.service && cp /tmp/gh016/backup/bin/implant.sh /tmp/gh016/persist/bin/implant.sh && chmod +x /tmp/gh016/persist/bin/implant.sh && (cd /tmp/gh016 && sha256sum -c manifest.txt) --- record the evidence BEFORE touching anything --- sha256sum: persist/cron.d/persist: No such file or directory persist/cron.d/persist: FAILED open or read sha256sum: persist/units/persist.service: No such file or directory persist/units/persist.service: FAILED open or read sha256sum: persist/bin/implant.sh: No such file or directory persist/bin/implant.sh: FAILED open or read sha256sum: WARNING: 3 listed files could not be read 2026-09-21 23:18:56.199479176 +0000 /tmp/gh016/persist 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/cron.d 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/units 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/bin --- restore from the known-good backup the manifest describes --- persist/cron.d/persist: OK persist/units/persist.service: OK persist/bin/implant.sh: OK
ls -R shows the files back in their locations. Then the sweep: the attack cleared the lab, but a real attacker takes every door, so the defender checks the other persistence locations. grep -ri gh016 /etc/cron.d /etc/cron.daily finds nothing in system cron; the systemd units hold no gh016 units. The attack only cleared the lab; the sweep names the doors the attacker did not take, which is how the defender knows the scope.
$ echo "--- confirm the restore ---"; ls -R /tmp/gh016/persist; echo "--- persistence sweep: the other doors the attacker could have taken ---"; grep -ri gh016 /etc/cron.d /etc/cron.daily 2>/dev/null || echo 'no gh016 in system cron'; ls /etc/systemd/system 2>/dev/null | grep -i gh016 || echo 'no gh016 systemd units' --- confirm the restore --- /tmp/gh016/persist: bin cron.d units /tmp/gh016/persist/bin: implant.sh /tmp/gh016/persist/cron.d: persist /tmp/gh016/persist/units: persist.service --- persistence sweep: the other doors the attacker could have taken --- no gh016 in system cron no gh016 systemd units
chmod 755 on the persist directories, root-owned: only root writes the persistence locations. The demonstration: su -s /bin/sh nobody tries the attacker's rm as the unprivileged user, and the kernel refuses it: rm: cannot remove '/tmp/gh016/persist/cron.d/persist': Permission denied. The gate raises the required privilege to root before the technique can run. D3FEND D3-SCP: System Configuration Permissions names exactly this shape: restricting system configuration modifications to the principals that need them.
$ echo "--- PREVENTION: the permission gate ---"; chmod 755 /tmp/gh016/persist /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin; su -s /bin/sh nobody -c 'rm /tmp/gh016/persist/cron.d/persist' 2>&1; echo "(refused: only root writes the persistence locations)" --- PREVENTION: the permission gate --- rm: cannot remove '/tmp/gh016/persist/cron.d/persist': Permission denied (refused: only root writes the persistence locations)
cat shows the manifest: three paths, three hashes, the whole inventory in three lines. The scheduled check is one command: (cd /tmp/gh016 && sha256sum -c manifest.txt), and after the restore it reports OK on all three. The tell is any FAILED or missing entry. D3FEND D3-CI: Configuration Inventory is the inventory discipline behind the manifest, and D3-FIM: File Integrity Monitoring is the change-detection shape the scheduled check implements.
$ echo "--- PREVENTION: the manifest is the inventory ---"; cat /tmp/gh016/manifest.txt; echo "the scheduled check runs: (cd /tmp/gh016 && sha256sum -c manifest.txt)"; (cd /tmp/gh016 && sha256sum -c manifest.txt); echo "the tell is any FAILED or missing entry" --- PREVENTION: the manifest is the inventory --- f739c786f26322d541ec61d2c0d9626a1d36427d5425c4e58a2c5bd1b2340279 persist/cron.d/persist 0978f032fc00aa0ea9d643a64163588f1f9e4dcb08a91f021e3c4af69a927e46 persist/units/persist.service 281b63811945f5af8520f9d5deaa98c6a673a932a05c34a196cdd514c05b2eb6 persist/bin/implant.sh the scheduled check runs: (cd /tmp/gh016 && sha256sum -c manifest.txt) persist/cron.d/persist: OK persist/units/persist.service: OK persist/bin/implant.sh: OK the tell is any FAILED or missing entry
The summary, in the defender's own words: the listing said clean, the manifest said cleared. The evidence was recorded, the artifacts were restored from backup, every hash checks. The gate refused the unprivileged delete, and the manifest is the scheduled inventory.
$ echo "detection verified: the listing said clean, the manifest said cleared"; echo "the evidence was recorded, the artifacts were restored from backup, every hash checks"; echo "the gate refused the unprivileged delete, and the manifest is the scheduled inventory" detection verified: the listing said clean, the manifest said cleared the evidence was recorded, the artifacts were restored from backup, every hash checks the gate refused the unprivileged delete, and the manifest is the scheduled inventory
The listing said clean and the manifest said cleared, and the manifest was right: three missing artifacts, three fresh directory mtimes. The evidence was recorded before anything was touched, the artifacts were restored from the known-good backup with every hash verified, and the other persistence locations swept clean. The permission gate refused the unprivileged delete, and the manifest check is the scheduled inventory.
rm -rf /tmp/gh016 removes the lab; ls confirms the directory is gone. The namespace dies with the session regardless; the cleanup keeps the record honest.
$ rm -rf /tmp/gh016; ls /tmp | grep gh016 || echo "lab gone" lab gone
Three moves, in order: record and restore from backup, inventory the manifest on a schedule, gate the locations behind root-only writes. Each is one way, not the way.
Proven first against the live clearing: record the manifest diff and the directory mtimes before touching anything, restore the cleared artifacts from the known-good backup the manifest describes, verify every hash, sweep the other persistence locations: system cron, systemd units. A real sweep names every other door: rc.local, profile.d, authorized_keys, and on other platforms the registry and the plist.
$ echo "--- record the evidence BEFORE touching anything ---"; ((cd /tmp/gh016 && sha256sum -c manifest.txt); stat -c '%y %n' /tmp/gh016/persist /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin) > /tmp/gh016/evidence.txt 2>&1; cat /tmp/gh016/evidence.txt; echo "--- restore from the known-good backup the manifest describes ---"; cp /tmp/gh016/backup/cron.d/persist /tmp/gh016/persist/cron.d/persist && cp /tmp/gh016/backup/units/persist.service /tmp/gh016/persist/units/persist.service && cp /tmp/gh016/backup/bin/implant.sh /tmp/gh016/persist/bin/implant.sh && chmod +x /tmp/gh016/persist/bin/implant.sh && (cd /tmp/gh016 && sha256sum -c manifest.txt) --- record the evidence BEFORE touching anything --- sha256sum: persist/cron.d/persist: No such file or directory persist/cron.d/persist: FAILED open or read sha256sum: persist/units/persist.service: No such file or directory persist/units/persist.service: FAILED open or read sha256sum: persist/bin/implant.sh: No such file or directory persist/bin/implant.sh: FAILED open or read sha256sum: WARNING: 3 listed files could not be read 2026-09-21 23:18:56.199479176 +0000 /tmp/gh016/persist 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/cron.d 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/units 2026-09-21 23:18:56.224479176 +0000 /tmp/gh016/persist/bin --- restore from the known-good backup the manifest describes --- persist/cron.d/persist: OK persist/units/persist.service: OK persist/bin/implant.sh: OK $ echo "--- confirm the restore ---"; ls -R /tmp/gh016/persist; echo "--- persistence sweep: the other doors the attacker could have taken ---"; grep -ri gh016 /etc/cron.d /etc/cron.daily 2>/dev/null || echo 'no gh016 in system cron'; ls /etc/systemd/system 2>/dev/null | grep -i gh016 || echo 'no gh016 systemd units' --- confirm the restore --- /tmp/gh016/persist: bin cron.d units /tmp/gh016/persist/bin: implant.sh /tmp/gh016/persist/cron.d: persist /tmp/gh016/persist/units: persist.service --- persistence sweep: the other doors the attacker could have taken --- no gh016 in system cron no gh016 systemd units
Honest limit. shred overwrites before unlinking, so carving recovers nothing: the backup's integrity IS the evidence chain, and the backup must be protected before the attacker arrives, not after. The manifest says WHAT was cleared, not WHEN it was cleared: file-watch audit logs are the production backstop for the when. Stated, not shown: audit is not functional inside the lab namespace. Restoring disturbs the scene, so evidence.txt is recorded first and treated as the record.
The scheduled form of the phase-blue read: sha256sum -c against the known-good manifest on a timer. The tell is FAILED or missing, especially at persistence locations.
$ echo "--- PREVENTION: the manifest is the inventory ---"; cat /tmp/gh016/manifest.txt; echo "the scheduled check runs: (cd /tmp/gh016 && sha256sum -c manifest.txt)"; (cd /tmp/gh016 && sha256sum -c manifest.txt); echo "the tell is any FAILED or missing entry" --- PREVENTION: the manifest is the inventory --- f739c786f26322d541ec61d2c0d9626a1d36427d5425c4e58a2c5bd1b2340279 persist/cron.d/persist 0978f032fc00aa0ea9d643a64163588f1f9e4dcb08a91f021e3c4af69a927e46 persist/units/persist.service 281b63811945f5af8520f9d5deaa98c6a673a932a05c34a196cdd514c05b2eb6 persist/bin/implant.sh the scheduled check runs: (cd /tmp/gh016 && sha256sum -c manifest.txt) persist/cron.d/persist: OK persist/units/persist.service: OK persist/bin/implant.sh: OK the tell is any FAILED or missing entry
Honest limit. The manifest must predate the attacker: an attacker who arrives before the first inventory is invisible to it. The poll interval sets the detection floor: a clearing and a re-creation between polls is missed. A location that is not inventoried is a door left open, so the manifest must cover every persistence location the platform offers, or the attacker simply takes the uncovered one.
The durable form: persistence locations are root-owned and writable only by root. Without write access the clearing, like the planting, is refused at the gate, as demonstrated above. Service managers and configuration management can enforce the ownership continuously.
$ echo "--- PREVENTION: the permission gate ---"; chmod 755 /tmp/gh016/persist /tmp/gh016/persist/cron.d /tmp/gh016/persist/units /tmp/gh016/persist/bin; su -s /bin/sh nobody -c 'rm /tmp/gh016/persist/cron.d/persist' 2>&1; echo "(refused: only root writes the persistence locations)" --- PREVENTION: the permission gate --- rm: cannot remove '/tmp/gh016/persist/cron.d/persist': Permission denied (refused: only root writes the persistence locations)
Honest limit. An attacker who already runs as root can chmod the locations back: the gate raises the required privilege, it does not end the game. This is why the inventory in step 2 is the backstop for the gate, not the other way around: the gate stops the unprivileged, the manifest catches the privileged.
The clearing was detected from the manifest, recorded, and restored from backup with every hash verified; the manifest is checked on a schedule with every persistence location covered; the locations are root-owned so the unprivileged delete is refused. The listing still says clean to whoever only reads listings. The manifest does not agree.
When the listing says clean and the manifest says cleared, the manifest is the truth: inventory what was here, not what is here.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1070.009: Clear Persistence
shred(1) (the overwriting removal)
sha256sum(1) (the manifest check)
stat(1) (the directory-mtime scar)
crontab(5) (the cron persistence form)
systemd.service(5) (the unit persistence form)
D3FEND D3-CI: Configuration Inventory
D3FEND D3-FIM: File Integrity Monitoring
D3FEND D3-SCP: System Configuration Permissions
The next file runs code that was never a file.