Postexploitation

13 min read2,505 words

Post-Exploitation

This is one of the most important phases of professional penetration testing because getting initial access is not the end of the assessment.

The real questions are:

What can I do with this access? How far can the compromise go? What sensitive assets are reachable? How can I prove the impact safely?

Everything below should be performed only on systems you own or are explicitly authorized to test.

1. What Is Post-Exploitation?

Post-exploitation is the phase after you have obtained authorized access to a system.

Example:

Recon ↓ Scanning ↓ Vulnerability Assessment ↓ Exploitation ↓ Initial Access ↓ POST-EXPLOITATION ↓ Privilege Escalation ↓ Credential Discovery ↓ Lateral Movement ↓ Data/Asset Discovery ↓ Impact Validation ↓ Cleanup ↓ Report

You already learned Privilege Escalation separately.

Post-exploitation is broader.

2. Initial Access ≠ Full Compromise

Suppose you obtain a shell:

www-data@server:~$

You have access.

But you don't yet know:

  • Who am I?
  • What permissions do I have?
  • What operating system is this?
  • What network am I connected to?
  • What other machines can I reach?
  • What credentials are exposed?
  • What applications are installed?
  • What sensitive data exists?
  • Is this system connected to a domain?
  • Can this machine provide access to another system?

So the next phase is situational awareness.

3. The Post-Exploitation Mindset

Think:

ACCESS ↓ UNDERSTAND ↓ ENUMERATE ↓ MAP ↓ VALIDATE ↓ ESCALATE ↓ PIVOT ↓ PROVE IMPACT ↓ CLEAN UP

The key principle:

Don't immediately start running random commands.

First understand the environment.

4. Step 1 — Identify Yourself

Linux

whoami
id
groups

Example:

uid=33(www-data) gid=33(www-data) groups=33(www-data)

You now know:

User: www-data Privilege: Low

Windows

whoami
whoami /all
whoami /groups

This can reveal:

  • Username
  • Domain
  • Groups
  • Privileges
  • Security identifiers

5. Step 2 — Identify the Operating System

Linux

uname -a
cat /etc/os-release
hostname

Windows

systeminfo
hostname

You want to determine:

OS Version Architecture Hostname Patch level Domain membership

6. Step 3 — Understand the Network

This is extremely important.

Linux

ip addr
ip route
ss -tulpn

Windows

ipconfig /all
route print
netstat -ano

You may discover:

Interface ↓ IP address ↓ Subnet ↓ Gateway ↓ DNS ↓ Internal networks ↓ Other reachable systems

7. Example Network Discovery

Imagine you obtain:

IP: 10.10.10.25 Subnet: 10.10.10.0/24 Gateway: 10.10.10.1 DNS: 10.10.10.10

You now know this machine belongs to:

10.10.10.0/24

This can become important during authorized lateral-movement testing.

8. Step 4 — Process Enumeration

Find running processes.

Linux

ps aux

or:

ps -ef

Windows

tasklist

PowerShell:

Get-Process

You are looking for:

  • Security software
  • Databases
  • Web servers
  • Backup software
  • Custom applications
  • Administrative tools
  • Scripts
  • Services running as privileged users

9. Step 5 — Service Enumeration

Linux

systemctl list-units --type=service

Windows

sc query

PowerShell:

Get-Service

Ask:

Which services are running?

Then:

Which services run with high privileges?

Then:

Can the current user influence them?

This connects directly to Privilege Escalation.

10. Step 6 — Find Installed Software

Debian/Ubuntu

dpkg -l

RPM-based systems

rpm -qa

Windows

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*

Why is this useful?

Because applications may have:

  • Vulnerable versions
  • Weak configurations
  • Exposed credentials
  • Interesting configuration files

11. Step 7 — Search for Sensitive Information

This is a major post-exploitation activity.

You may encounter:

Passwords API keys Tokens SSH keys Database credentials Configuration files Cloud credentials Application secrets Backup credentials Environment variables

Common Linux locations worth reviewing within scope:

/etc /opt /var/www /home /usr/local

Also examine application configuration files.

For example:

.env config.php settings.py application.yml database.yml

But remember:

Finding a credential does not automatically mean you should use it.

First determine whether the credential is within the authorized scope and whether using it is necessary to demonstrate impact.

12. Environment Variables

Linux:

env

or:

printenv

Windows:

set

PowerShell:

Get-ChildItem Env:

Sometimes applications store secrets in environment variables.

Example:

DATABASE_HOST=... DATABASE_USER=... DATABASE_PASSWORD=... API_KEY=...

This is a common security issue in poorly configured applications.

13. Shell History

Linux shells may store command history.

For example:

history

Depending on the shell:

cat ~/.bash_history

Potentially sensitive information can sometimes appear there.

However, professional testing should avoid unnecessarily exposing or copying secrets.

14. SSH Keys

Linux systems may contain SSH configuration under:

~/.ssh/

Potential files include:

authorized_keys known_hosts config id_rsa id_ed25519

Conceptually:

Private Key ↓ Authentication ↓ Remote System

A discovered private key can potentially represent another access path.

Again:

Don't automatically use discovered credentials or keys. Validate whether doing so is necessary and authorized.

15. Credential Discovery

Credentials can appear in:

Configuration files Environment variables Scripts Logs History Backups Source code Password managers Application databases Memory Credential stores

The professional approach is:

Find ↓ Identify owner ↓ Determine scope ↓ Determine privilege ↓ Assess exposure ↓ Safely validate ↓ Document

16. Credential Reuse

One of the most important concepts.

Suppose you discover:

User: alice Password: ********

You shouldn't immediately assume:

“This gives me access everywhere.”

Instead determine:

Credential ↓ Where is it valid? ↓ Local? ↓ Application? ↓ Database? ↓ SSH? ↓ Domain?

Credential reuse can turn one compromised system into multiple compromised systems.

17. Lateral Movement

Lateral movement means moving from one compromised system/account to another system within the authorized environment.

Example:

Internet ↓ Web Server ↓ Application Server ↓ Internal Server ↓ Domain Controller

Or:

CLIENT01 ↓ SERVER01 ↓ DATABASE01

The goal in a penetration test is to determine whether segmentation and access controls actually prevent this.

18. Common Lateral Movement Paths

Depending on the environment:

Windows

  • SMB
  • RDP
  • WinRM
  • Remote services
  • Domain credentials

Linux

  • SSH
  • Application credentials
  • Shared keys
  • Administrative interfaces

Enterprise environments

  • Active Directory
  • VPN
  • Internal web applications
  • Databases
  • Management systems

19. Pivoting

Pivoting is different from simple lateral movement.

Imagine:

Kali │ │ Internet-facing access ▼ Compromised Server │ │ Internal network ▼ Internal Network │ ├── Server A ├── Server B └── Database

Your compromised server becomes a pivot point.

Your testing machine may not directly reach the internal systems, but the compromised host can.

20. Pivoting Concept

Without pivot:

Kali ─────────X──────── Internal Server

With pivot:

Kali │ ▼ Compromised Host │ ▼ Internal Server

This is important in real penetration tests because external access does not necessarily expose the entire internal network.

21. Data Discovery

Post-exploitation often involves determining:

What valuable assets could an attacker access?

Examples:

  • Customer records
  • Source code
  • Database information
  • Internal documents
  • Credentials
  • Financial records
  • Intellectual property

But a professional pentester should not download huge amounts of sensitive information simply to prove access.

Instead:

Collect the minimum evidence necessary.

For example:

Found: Customer database Proof: Database name + table names + one synthetic/test record Impact: Sensitive customer data is accessible

That's usually better than copying the entire database.

22. Data Staging

Attackers may prepare data for exfiltration.

Conceptually:

Sensitive Data ↓ Collection ↓ Staging Area ↓ Exfiltration

In a penetration test, actual exfiltration should be tightly controlled and explicitly authorized.

Often you can demonstrate the issue using:

  • File names
  • Metadata
  • Small synthetic samples
  • Hashes
  • Test records

rather than real sensitive data.

23. Persistence

Persistence means maintaining access after the original access mechanism disappears.

Examples conceptually include:

Scheduled tasks Services Startup mechanisms SSH keys Web shells Accounts Registry mechanisms

However, persistence can create significant operational risk.

Therefore professional pentesting generally follows:

Only establish persistence when explicitly authorized.

And if required:

Create ↓ Document ↓ Test ↓ Remove ↓ Verify removal

24. Backdoors vs Professional Testing

A real attacker may attempt to leave hidden access.

A professional pentester should never casually leave:

Backdoor Hidden account Persistent malware Unauthorized scheduled task Unknown service

Instead, persistence testing should be:

  • Explicitly approved
  • Minimal
  • Documented
  • Reversible
  • Removed after testing

25. Defense Evasion

Attackers may try to avoid detection.

Examples conceptually:

Log manipulation Process hiding Security-tool evasion Timestamp manipulation Obfuscated payloads

For professional testing, this should only be performed when the engagement explicitly includes adversary simulation/red-team objectives.

Normal vulnerability assessment usually doesn't require destructive or stealthy evasion.

26. Command & Control

You may hear:

C2 — Command and Control

Conceptually:

Attacker Infrastructure │ │ C2 channel ▼ Compromised Host │ ▼ Commands / Results

Common legitimate red-team/C2 frameworks exist for adversary simulation.

But the important conceptual understanding is:

A C2 channel allows an operator to manage compromised systems remotely.

For normal pentesting, you don't need to build a sophisticated C2 infrastructure just to prove a vulnerability.

27. Post-Exploitation in Active Directory

This connects directly to the previous topic.

Example:

Compromised Workstation ↓ Identify Domain ↓ Identify Current User ↓ Find Domain Groups ↓ Find Accessible Systems ↓ Identify Credentials/Tokens ↓ Lateral Movement ↓ Privilege Escalation ↓ High-Privilege Account

Tools such as BloodHound can help visualize relationships.

28. Windows Token Concept

Windows uses security tokens to represent:

  • User identity
  • Groups
  • Privileges
  • Security context

Conceptually:

User ↓ Security Token ↓ Access Check ↓ Resource

This is why:

whoami /all

is so useful.

It gives insight into the security context of your session.

29. Linux Capabilities

Linux capabilities divide certain privileged operations into more granular permissions.

For example:

getcap -r / 2>/dev/null

You might discover a binary with an interesting capability.

The security question becomes:

Can this capability allow the current user to perform an operation they normally shouldn't?

This connects post-exploitation with privilege escalation.

30. Containers

Modern environments frequently use:

  • Docker
  • Kubernetes
  • Containers

After gaining access to a container, ask:

Am I inside a container? ↓ What privileges does it have? ↓ What mounts exist? ↓ What network access exists? ↓ Are secrets exposed? ↓ Is the container isolated properly?

Useful initial checks:

cat /proc/1/cgroup
ls /
mount

Again, only perform escape testing in an authorized lab.

31. Cloud Post-Exploitation

Cloud environments introduce another dimension.

Potential assets include:

IAM identities Access keys Metadata services Storage buckets Secrets Roles Service accounts Cloud APIs

The attack chain can become:

Compromised Application ↓ Cloud Credential ↓ IAM Permissions ↓ Cloud Resources ↓ Sensitive Data

This is why least privilege is extremely important.

32. Evidence Collection

A professional pentester needs evidence.

Capture:

Timestamp Host Username Finding Command/result Screenshot Relevant logs Affected asset Impact

Example:

Finding: Sensitive API key exposed in application configuration. Host: 10.10.10.20 User: www-data Evidence: Configuration file contains an active test credential. Impact: Application-level credential exposure. Recommendation: Move secret to secure secret management and rotate credential.

33. Cleanup

This is one of the most important professional responsibilities.

After testing:

Remove test accounts Remove temporary files Remove payloads Remove test services Remove persistence Restore configuration Remove temporary keys Close tunnels Stop test processes

Then verify:

Environment ↓ Before testing ↓ During testing ↓ After cleanup ↓ No unintended changes

34. Cleanup Checklist

Before closing the engagement:

  • Remove test accounts
  • Remove temporary credentials
  • Remove test files
  • Remove shells
  • Remove persistence
  • Remove scheduled tasks
  • Remove temporary firewall changes
  • Close tunnels
  • Stop listeners
  • Restore configurations
  • Verify system health

35. Complete Post-Exploitation Workflow

Your professional workflow should look like:

INITIAL ACCESS │ ▼ ┌─────────────────┐ │ Identify User │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Identify System │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Network Mapping │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Process/Service │ │ Enumeration │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Credential / │ │ Secret Discovery│ └────────┬────────┘ ▼ ┌─────────────────┐ │ Privilege │ │ Escalation │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Lateral Movement│ └────────┬────────┘ ▼ ┌─────────────────┐ │ Data / Asset │ │ Discovery │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Impact Proof │ └────────┬────────┘ ▼ ┌─────────────────┐ │ Cleanup │ └────────┬────────┘ ▼ REPORT

36. Practical Lab 🔬

Build a small lab:

Kali │ ▼ WEB-SERVER 10.10.10.20 │ ┌───────┴────────┐ │ │ DATABASE INTERNAL SERVER SERVER

Start with an intentionally vulnerable application.

Your exercise:

Phase 1 — Initial access

Obtain authorized lab access.

Phase 2 — Identify

whoami id hostname uname -a

Phase 3 — Network

ip addr ip route ss -tulpn

Phase 4 — Processes

ps aux

Phase 5 — Services

systemctl list-units --type=service

Phase 6 — Secrets

Inspect the application's test configuration.

Phase 7 — Privilege

Look for an authorized privilege-escalation path.

Phase 8 — Internal access

Determine whether the compromised server can reach another lab system.

Phase 9 — Impact

Find a controlled test asset.

Phase 10 — Cleanup

Remove everything you changed.

37. Example Attack Chain

Imagine your lab produces:

Public Web Application ↓ Web Vulnerability ↓ www-data ↓ Application Configuration ↓ Database Credential ↓ Database Access ↓ Sensitive Test Data ↓ Privilege Escalation ↓ Root

That is much more valuable than simply saying:

“I found SQL injection.”

You demonstrated an attack chain and business impact.

38. Post-Exploitation vs Privilege Escalation

Don't confuse them.

Privilege EscalationPost-Exploitation
Increase privilegesUnderstand and leverage access
Low → high privilegeBroad phase after access
SUID, sudo, servicesEnumeration, credentials, pivoting, impact
Linux/WindowsLinux/Windows/AD/cloud
One part of attackLarger lifecycle

Privilege escalation is often inside post-exploitation.

39. Professional Mindset 🧠

When you get a shell, don't think:

“I got shell!”

Think:

Who am I? ↓ What can I access? ↓ What can I modify? ↓ What networks can I reach? ↓ What secrets exist? ↓ What identities exist? ↓ What other systems are reachable? ↓ What is the highest-impact path? ↓ What is the minimum evidence needed? ↓ How do I clean up?

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy