Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 37 ยท Meterpreter and Post-exploitation

Meterpreter Commands and File System Work

A tour of core Meterpreter commands for system facts, files and processes, with read-only sample output and a Python stand-in for a command dispatcher.

Once a session is open (Meterpreter Overview), you work through a small command language. Knowing it matters in two ways: testers need it for authorized assessments, and defenders need to know which actions are noisy and what logs they leave.

All sample output below is invented, from a lab with documentation-range IP addresses. The real tool is not available in the browser, so the runnable parts model the logic.

Getting your bearings

Typing help prints every command in groups. The first ones people use:

TEXT
meterpreter > sysinfo
Computer        : LAB-WIN10
OS              : Windows 10 (10.0 Build 19045)
Architecture    : x64
Meterpreter     : x64/windows

meterpreter > getuid
Server username: LAB\tester

meterpreter > pwd
C:\Users\tester\Desktop

sysinfo reports the host, getuid the account the agent runs as, and pwd/cd/ls behave like their shell cousins but work through the agent's own file API rather than starting cmd.exe. That is a deliberate design choice: nothing spawns a command interpreter, so logs that only track process creation see nothing.

Files

The file-system commands are the ones most often used in an assessment to prove access, for example by reading a harmless marker file placed by the client.

Command Purpose
ls, cd, pwd Browse directories
cat file Print a text file
download remote local Copy a file to the tester's machine
upload local remote Copy a file to the target
search -f *.log Find files by name pattern
edit file Open a file in a local editor
rm, mkdir, mv Change the file system
TEXT
meterpreter > search -f scope-proof.txt -d C:\Users
Found 1 result...
    C:\Users\tester\Desktop\scope-proof.txt (28 bytes)
meterpreter > cat scope-proof.txt
ENGAGEMENT-2026-LAB-PROOF

In a real engagement, agree in the scope document what you may read and copy. A proof file planted by the client is far better evidence than real data, and it keeps sensitive information out of your report.

Processes

ps lists processes with PID, name, architecture and user. migrate PID moves the agent into another process, which keeps it alive if the original program closes, and getpid shows where it currently lives. kill PID ends a process. Defenders note that migration involves writing into another process's memory, a loud event for endpoint-protection software.

Python A command dispatcher stand-in

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Evidence and tidiness

A professional keeps a log of every command. In msfconsole the spool command writes the console to a file, and Meterpreter has -c options on many commands for scripting. If you modify anything on a client system (creating a file, changing a setting), note it so it can be reverted. The stand-in below writes a timestamp-free audit line per command, which is a good habit even for a toy.

Python Record an action log

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Defender's checklist

  • Enable process-creation and PowerShell logging; unusual parent-child chains stand out.
  • Monitor for new network connections from user-space programs to rarely seen hosts.
  • Protect files with least-privilege permissions, so a compromised low-privilege account cannot read much.
  • Keep file integrity monitoring on sensitive directories.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command tells you the account the agent runs as?

    getuid prints the server username; sysinfo reports the host and OS.
  2. 2. Why does Meterpreter use its own file API instead of starting cmd.exe?

    No command interpreter process is created, so logs that track process creation see fewer events.
  3. 3. What is a good proof of access during an engagement?

    A planted marker proves access without touching real data.
  4. 4. Why record every command you run?

    An audit trail backs up findings and lets the client undo modifications.

Summary

  • sysinfo, getuid, pwd, ls, cat, search, download and upload cover most basic work.
  • The agent uses its own APIs rather than spawning a shell.
  • ps and migrate deal with processes; migration is noisy.
  • Log every action and every change for the report.
  • Defenders rely on process, network and file-integrity monitoring.

Next: Post-exploitation Modules