Working Through a Vulnerable Host: A Step-by-Step Guide
1. Scan for Vulnerabilities
Start by identifying potential weaknesses in the host, application, or by leveraging information leakage. Use the following tools and techniques to gather information:
- Nmap Scanning: Use Nmap to map the network and identify open ports and services.
- Virtual Host (vhost) Enumeration: Discover hidden virtual hosts to target.
- Gobuster: Perform brute-force enumeration to find directories, files, and DNS entries.
- Ping Scanning: Determine if hosts are active and responsive.
- Google Dorking: Use specialized search queries to find exposed information.
2. Determine Versions
Once you have basic information about the host and running applications, the next step is to identify the specific versions. This will help in targeting known vulnerabilities.
- Banner Grabbing: Capture banners from services to determine their versions.
- Netcat/Telnet: Use these tools to manually interact with services and identify versions.
- Shodan and Censys: Search for host information across public databases.
- Inspect Headers: Analyze HTTP or other protocol headers for version information.
- Intentional Errors: Trigger specific errors to get version details from error messages.
3. Find Exploits
With the identified versions and software, search for known vulnerabilities and exploits that can be used against the host.
- SearchSploit: Look for public exploits related to the software or versions.
- Exploit-DB: Search for publicly available exploits on Exploit Database.
- Google: Use tailored search queries to find exploits or relevant information.
- Shodan: Search for specific vulnerabilities tied to exposed services.
4. Craft Payload
Once an exploit is identified, craft a malicious payload to take advantage of it. This often involves reverse shells or similar methods to gain control.
- MSFvenom: Use Metasploit's MSFvenom tool to create custom payloads.
- SearchSploit: Modify existing exploit code for your use case.
5. Execute Payload
Deploy the crafted payload to exploit the vulnerable host and gain initial access. This step may require creativity depending on the environment and restrictions.
- Invoke-Command: Execute commands remotely on Windows systems.
- Runas: Execute programs with administrator privileges on Windows.
- Sudo: Use the sudo command to escalate privileges and run commands as root on Unix-based systems.
6. Establish Persistence
Ensure that your access to the system remains persistent in case of reboot or detection.
- Service Takeovers: Hijack services to maintain persistent access.
- Cron Jobs: Set up scheduled tasks on Unix systems to maintain control.
- Startup Scripts: Modify startup scripts so that your payload runs at boot.
7. Escalate Privileges
After gaining initial access, move from user-level access to root or administrator privileges to gain full control over the host.
- get-process: View running processes and identify exploitable ones.
- PowerUp.ps1: Use PowerShell scripts to escalate privileges on Windows systems.
- LinEnum.sh: Use this script to enumerate potential privilege escalation vectors on Linux.
- LinPEAS/WinPEAS: Automate the enumeration of privilege escalation methods on Linux or Windows.
- SUID/SGID: Exploit files with set-user-ID or set-group-ID permissions.
- sudo -l: List allowed sudo commands for the current user to find privilege escalation paths.
8. Exfiltrate Data
Once you have root or administrator access, it's time to gather and steal valuable data from the compromised system.
- Invoke-WebRequest (iwr): Use PowerShell to download or upload files.
- Curl: Transfer data to and from the host using HTTP or other protocols.
- Imagination: Get creative with how you access and extract sensitive information from the system!