Phase 05.01 · Living in the Session

Meterpreter & Session Management

Exploitation gets you a foothold. Post-exploitation is everything you do once you are standing on it. The session you landed — almost always a Meterpreter session — is your home base on the target: a live, interactive channel that runs entirely in memory. This lesson teaches you how to manage those sessions, the commands that turn a single foothold into real reach, and the discipline that keeps your access alive long enough to finish the job.

00

From exploit to session

In the exploitation phase you fired a payload at a vulnerable service and caught a connection back. That connection is a Meterpreter session — the advanced, dynamically extensible payload that ships with Metasploit. It is not a program sitting on the target's disk. It is code injected into the memory of a running process, speaking a custom protocol back to your console. Everything you are about to do happens from that session.

Two facts about Meterpreter shape every decision in this phase. First, it lives in memory: there is no executable dropped to disk for antivirus to scan or for an investigator to find later, which makes it quieter than a traditional implant. Second, because it is borrowing a host process to exist, it dies when that process dies. If the exploited service crashes, gets patched, or simply gets closed by the user who owns it, your session evaporates — and with it, your access. That single fragility is the reason stability is a theme you will hear repeated throughout this lesson.

Post-exploitation is the work, not the win. A shell is a starting line, not a finish line. The value of an engagement comes from what you learn and reach after the exploit lands — the privileges you escalate, the data you can prove you reached, the path you can map to the next host. Treat the session as a place you have to operate from, not a trophy.
Lesson
05.01
Phase
Post-Exploitation
Runs in
Memory · not disk
01

Managing sessions in msfconsole

A real engagement is rarely one shell. You may land footholds on several hosts, and you need to move between them without losing any. Meterpreter and msfconsole are built for exactly this — sessions are objects you can park, list, and resume at will.

The mental model is a switchboard. Each session is a separate, persistent line to a separate machine; backgrounding and interacting are how you switch between them. An operator on a live engagement often juggles several sessions at once — running enumeration on one host while staging the next move on another — and the sessions command is the control panel for all of it.

Name and note as you go. The moment you have more than two sessions, a plain ID list stops telling you which host is which. Keep your own running notes — session ID, hostname, the user you landed as, and what you have already done there — so you never act on the wrong machine. Disciplined record-keeping is the difference between an operator and a person with a lot of open windows.
02

The core Meterpreter command set

Once you are interacting with a session, you have a built-in toolkit that works the same way regardless of how you got in. These are the commands you will reach for first on almost every host. Learn what each one tells you or does — the goal of early post-exploitation is to answer "where am I, who am I, and how do I stay here?"

CommandWhat it does
sysinfoFingerprints the host — operating system, architecture, hostname, domain. Your first question on any new session: what is this machine?
getuidReports the user account the session is running as. Tells you immediately whether you landed as a low-privilege service account or something with real power.
psLists running processes with their PIDs, owners, and architecture. The map you read before choosing where to migrate.
migrateMoves the implant out of its current host process and into another one — a more stable or more innocuous process. The single most important stability command (see below).
getsystemAttempts automatic privilege escalation to SYSTEM on Windows using known local techniques. Fast to try; not guaranteed — manual priv-esc is the next lesson.
hashdumpDumps local password hashes from the host (requires sufficient privilege). The raw material for cracking and for credential reuse against other systems.
screenshotCaptures the target's current desktop. Strong, undeniable proof for a report — and sometimes a window full of useful information.
download / uploadMoves files between the target and your machine — pull evidence and loot down, push tools up.
shellDrops you out of Meterpreter into a native OS command shell (cmd.exe or a Unix shell) when you need to run host commands directly.

Of all of these, migrate earns special attention. When your payload first lands, it lives inside whatever process the exploit happened to compromise — frequently something fragile, short-lived, or owned by a user who could close it at any second. If that process exits, your session dies with it. Migrating moves your foothold into a sturdier, more permanent host — a long-running system service, for example — so a crash in the original exploited process no longer costs you access. Done well, it also blends in: a session running inside an ordinary, expected process draws far less attention than one parked in something that has no business being there. Stabilize first, then operate.

03

Post modules: the rest of the arsenal

The built-in commands cover the essentials, but they are only the surface. Metasploit ships hundreds of post/ modules — purpose-built scripts that automate the deeper work of post-exploitation against a session you already hold. Where getuid answers one question, a post module can sweep an entire host for you.

The pattern is consistent. From inside a session, run a module against it with run post/<module>. The modules are organized by platform and purpose, so the path tells you what you are getting:

One module deserves a special mention before the next lesson: the local exploit suggester. Run run post/multi/recon/local_exploit_suggester against a session and Metasploit checks the host's OS and patch level against its catalog of local privilege-escalation exploits, then hands you a shortlist of the ones likely to work. It will not do the escalation for you, but it turns "I need to get higher privileges somehow" into a concrete, ranked set of options — the natural bridge into the privilege-escalation material that follows.

Read before you run. A post module is still code you are executing on someone else's machine. Use info to see what a module does, what it touches, and what options it needs before you fire it — both so you get a useful result and so you understand exactly what footprint you just left behind.
04

A look ahead: pivoting and good habits

A compromised host is rarely the destination — it is a doorway. The machine you landed on can usually see other systems that were never reachable from where you started: an internal subnet, a database server, a domain controller sitting behind the perimeter. Meterpreter can turn your single foothold into a route into that hidden network, tunneling your traffic through the compromised host so the tools on your machine can reach the systems beyond it.

That capability — pivoting — is how a single compromised workstation becomes a path to the crown jewels, and it gets a full treatment in the lateral-movement lesson. For now, know that the session you stabilized here is the launch point for it.

Close every session on the same discipline that makes all of this defensible:

With a stable session in hand and a clear picture of the host, the next step is to climb: turning the foothold you have into full control of the machine. That is Windows privilege escalation.