The professional obligation
It is tempting to treat the moment you reach domain admin — or whatever the agreed objective was — as the finish line. It is not. Reaching the goal proves the attack path exists; the engagement is only finished when the environment has been returned to its original state. Everything you did to get in and move around left residue, and that residue is now your responsibility.
Think about what you actually leave behind during an engagement: payloads dropped on disk, post-exploitation tools staged in temp directories, accounts you created so you could come back, scheduled tasks and services planted for persistence, configuration files you edited to weaken a control. Each of those is a live weakness that did not exist before you arrived. A test that walks away leaving them in place is not a successful test — it is negligent, and it can become the exact breach it was meant to prevent. A real attacker who finds your forgotten backdoor account inherits all of your access for free.
You can only remove what you tracked
Cleanup does not begin at the end of the engagement. It begins on the first day, with a discipline that has nothing to do with attacking: note-taking. You cannot reliably remove an artifact you have forgotten you created, and after days of pivoting through dozens of hosts, you will forget — unless you wrote it down at the moment you did it.
Keep a running activity log and update it as you work, not from memory afterward. Every time you change the state of a target, record it: the host, the timestamp, what you did, and — critically — how to undo it. That means logging every file you upload, every account you create, every service or scheduled task you add, every configuration you edit, and every key you plant. The log is the raw material for everything that follows.
- Write it as you go. A change recorded the instant you make it is reliable; a change reconstructed from memory at the end of a long engagement is a guess.
- Record the reversal, not just the action. "Created user svc-backup on DC01" is a start; "… remove with net user svc-backup /delete" is what actually gets you to a clean state.
- One log, one source of truth. The activity log doubles as evidence for the report and as the master list you check artifacts off against during teardown.
What to remove
Your activity log will be specific to the engagement, but the categories of artifact are predictable. Everything you introduced falls into one of a handful of buckets, and each bucket has a known place it lives and a known way to remove it. Walk every category below against your log — if you created it, it comes back out.
| Artifact | Where it lives | Remove |
|---|---|---|
| Tools & payloads | Temp directories, user profiles, web roots, staging folders — uploaded binaries, scripts, and implants/beacons. | Delete every dropped file and kill any running implant process. Verify nothing relaunches on reboot. |
| Created accounts | Local users, domain accounts, added group memberships — anything you created to gain or keep access. | Delete the accounts and undo any group additions. Confirm no orphaned logins remain. |
| Persistence | Registry Run keys, scheduled tasks, services, cron jobs, and entries added to ~/.ssh/authorized_keys. | Remove each mechanism you planted and confirm it does not survive a restart. |
| Modified configs | Edited config files, weakened policies, disabled defenses, firewall or registry tweaks. | Restore the original value from your log or a backup — never leave a control loosened. |
| Test data | Files, records, or markers you wrote to prove access or stage an action. | Delete anything you authored. Leave the data you only read exactly as it was. |
Notice the asymmetry: you remove what you added and restore what you changed, but you do not touch what was already there. The goal is a perfect rollback — the environment ends in the same state it started, no richer and no poorer for your having been in it.
Do not cover your tracks
Here is the single most important distinction in this entire lesson, and the one that defines what it means to be a professional rather than a criminal. A real attacker, having done their damage, deletes the logs — clears event records, wipes shell history, scrubs anything that proves they were there — because their goal is to remain unseen. A penetration tester does the exact opposite: you leave the logs intact.
This is not a small stylistic difference. It is the line that separates the two roles entirely. The defender's logs, alerts, and audit records are not your mess to clean — they are the output of the test. They are the evidence that the engagement happened. They are how the blue team measures what they actually detected and what slipped past. If you wipe them to "tidy up," you have destroyed the most valuable product of the whole exercise: an honest record of what the organization's defenses did and did not catch.
Keep the two ideas cleanly separated in your head. Cleanup means removing the artifacts you introduced. Covering tracks means erasing the traces of the activity itself. You do the first and you never do the second. When in doubt, ask: "Am I removing something I added, or am I hiding something I did?" The first is your duty; the second is the thing you were hired to expose in others.
Verify and hand back
Walking your activity-log checklist is not the same as proving it worked. Cleanup ends with verification: go back and confirm that each artifact is actually gone, not just that you ran the removal command. Check that deleted accounts no longer authenticate, that dropped files are absent, that scheduled tasks and services do not reappear after a reboot, and that every configuration you touched has been restored to its original value. An artifact you tried to remove but did not is more dangerous than one you forgot, because you have crossed it off the list.
Then hand the environment back deliberately. Deliver two things to the client: a clean environment, and a cleanup summary — a short record stating what you introduced, that you removed it, and the artifacts you intentionally left in place. Because remember, you did leave traces on purpose: the logs, the alerts, the detections. Those are not loose ends — they are precisely the material the defenders now study.
That completes the Post-Exploitation phase. You have learned to escalate, move laterally, establish persistence, harvest credentials and evidence of impact, and — just as importantly — to dismantle all of it and leave cleanly. Next, the track turns outward to the most exposed surface most organizations own: the Web & Database Attacks phase, where the target is the application and the data behind it.