Metasploit › Module 7 › Lesson 3
Session Hygiene
Kill sessions, close handlers, snapshot revert — leave no lab artifacts on real OS.
Visual · msf_session_hygiene
Hygiene = kill, revert, notes secured. Original Cyberlium.
Opening
The professional leaves the lab cleaner than they found it.
sessions -K kills all; session -k <id> kills one. Stop handlers. Revert VM snapshot on $LAB target. Never migrate sessions onto your host OS or a friend's machine. chmod 600 lab notes.
1. Kill and exit
End every lab session explicitly — do not rely on reboot luck.
exit -y from msfconsole after jobs cleared.
Command guide
Try these commands — Kill and exit
═══ TOOLS & WEBSITES ═══ Browse / read these (authorized learning only — stay in YOUR lab / program scope)
Session management — https://docs.rapid7.com/metasploit/managing-sessions/ Opsec hygiene — https://attack.mitre.org/
═══ INSTALL ═══
Linux (Debian/Ubuntu): Kali: preinstalled, or: sudo apt install metasploit-framework
macOS: Prefer Kali/Linux VM — brew install metasploit (heavy)
Windows: Use Kali VM or WSL with metasploit-framework — not raw Windows host
═══ LINUX / macOS ═══
Command — copy this
grep -i never "$HOME/cyberlium-lab/t14-msf/roe.txt" 2>/dev/null || true msfconsole -q -x 'help sessions -K; exit' 2>/dev/null || echo 'Kill lab sessions; revert VM snapshot'
Primary tools to practice this lesson: msfconsole, grep. Reference sites: Session management (https://docs.rapid7.com/metasploit/managing-sessions/); Opsec hygiene (https://attack.mitre.org/). Run every command in the box — install first, then the usage lines — only on YOUR lab / program scope.
2. VM snapshot discipline
Revert $LAB victim VM to clean snapshot post-lab.
Attacker VM: remove listener configs from history if shared machine.
3. Real workstation rule
No meterpreter on daily-driver Windows/macOS for “practice.”
No persistence on real workstations — ever in this course.
4. What you ship: session hygiene checklist
Kill sessions, stop handler, revert snapshot, secure notes.
5. What you record before the next lesson
Hygiene checklist path.
6. Wrong vs right: stranger hosts vs YOUR lab VM
Worked failure — same MSF word, opposite target. Right never needs a café Wi-Fi or classmate laptop.
Wrong
Leave handler running on laptop overnight in dorm Wi-Fi.
Right
Checklist written. Next: sessions lab.
Mission: hygiene checklist
1) List kill commands. 2) Add revert snapshot step. 3) Write no-real-workstation rule.
Stuck? Ask Cyberlium AI Mentor
Ask Mentor: “sessions -K vs -k?”
Knowledge Check
APPLY: After lab you should:
Multiple choice
Knowledge Check
APPLY: True or False: Persistence on your daily PC is OK for learning.
True or False
Knowledge Check
APPLY: Notes should be:
Multiple choice