Penetration Testing Field Notes: From First Scan to Report

6 min read188 courses on OnlySecurity

An internal penetration test is a structured attempt to do what a real intruder would do once inside a network, with the owner’s permission and under agreed limits. Tools change every few years. The order of the work changes far less. This article walks through one assessment from the first conversation to the final report, in the order the work usually runs, and links a guide for each stage. Test only networks and systems you own or are authorised to assess. Practise every technique in a lab first, and expect each guide to end with how defenders detect and stop it, because that is the half of the work the client is paying for.

Start with scope and rules of engagement

Nothing technical happens before the paperwork. NIST SP 800-115, the Technical Guide to Information Security Testing and Assessment, divides penetration testing into four phases (planning, discovery, attack and reporting) and notes that this is one example among many acceptable groupings. Reporting runs alongside the other three, and the attack phase loops back to discovery whenever a foothold opens up more of the network. No testing happens in the planning phase: the rules are identified, management approval is finalised and documented, and the testing goals are set. Appendix B of the same document is a Rules of Engagement template, with sections for scope, the test schedule, incident handling, the target systems and data handling. The Penetration Testing Execution Standard (PTES), written by a group of practitioners, splits the same lifecycle into seven sections, from pre-engagement interactions through intelligence gathering, threat modelling, vulnerability analysis, exploitation and post exploitation to reporting. Its main page was last edited in August 2014.

Write down what is in scope, which address ranges and domains, the testing window, who to call if something breaks, which actions are off limits (denial of service, social engineering, production data) and how findings and captured credentials will be stored and destroyed. If a step could crash a service, the agreement should say whether it is allowed. A technique you cannot name in the rules is a technique you should ask about first.

Discovery and enumeration

Discovery is where you learn what exists. Nmap is still the standard starting point, and Nmap scanning: host discovery, port scans, timing and output covers how it decides a host is up, what its six port states mean and how fast is too fast. Choosing and running NSE scripts covers the Nmap Scripting Engine, including the script categories that separate a harmless read from a script that can crash a service. For the outside view, finding your own exposed cameras, databases and devices with Shodan and Censys shows how to read what those search engines have already recorded about the address ranges, domains and certificates that belong to you, without sending those systems a packet yourself.

Name resolution and NTLM

A Windows network left at its defaults can leak authentication material in ordinary background traffic. LLMNR, NBT-NS and mDNS poisoning with Responder explains why a Windows host that cannot resolve a name asks the local network, and what answering that question yields. WPAD and UNC path injection covers two more ways a Windows host offers the signed-in user’s NTLM response without prompting them. NTLM relay, from MultiRelay to ntlmrelayx then shows why an intercepted logon does not have to be cracked to be useful, because it can be passed to another server while it happens, and why SMB signing stops the classic version.

Active Directory

Once you hold any domain credential, Active Directory becomes the map. From CrackMapExec to NetExec explains the successor tool and which old commands carry over. Dumping domain password hashes covers NTDS.dit, shadow copies and DCSync, including how to handle that output as sensitive engagement data. Kerberos silver tickets explains how a forged service ticket works, where it stops and how to detect it.

Access, shells and tooling

Getting code to run is a different skill from finding the way in. Shell listeners and upgrading to a fully interactive TTY explains listeners, why a raw shell is a poor terminal and how to fix that. Metasploit and msfvenom in a lab builds a target you control and runs the framework workflow against it. PowerShell Empire today, and macro phishing after Microsoft’s internet macro block covers command and control frameworks and why the old Office macro route changed. Transferring files during an assessment covers moving tools in and evidence out, and keeping a record of every transfer.

Moving through the network

A foothold is rarely on the network you were asked to test. SSH port forwarding, SOCKS proxies and proxychains covers pivoting with nothing but an SSH login. Pivoting with sshuttle, Meterpreter routes and Ligolo-ng compares the options for when a SOCKS proxy is not enough.

Privilege escalation

A standard user account is seldom the end goal. Windows privilege escalation: stored credentials and missing patches covers the two causes behind much of it. Linux kernel privilege escalation explains how to work out whether a kernel is exposed without exploiting it, and why a kernel exploit is the riskiest route to root and needs written permission on a client system.

Web applications

Internal networks run web applications too. Web server and SQL injection scanning with Nikto and sqlmap covers what scanners can and cannot find. Testing for cross-site scripting, and what Content Security Policy changes explains how to test by output context rather than with payload lists. IIS web.config upload attacks shows how a file upload feature can turn into a configuration feature. Burp Suite extensions worth installing covers the maintained extensions and which work in the Community Edition.

Practise the whole path in a lab

A lab is where you make mistakes cheaply. Build a small domain you own, with a domain controller, a couple of member servers and a workstation, on an isolated network, and work through the stages in order. The Network and Active Directory Ultimate Course runs one internal test of a fictional client from scoping to the report, in a lab you build and own, through Nmap, NetExec, BloodHound CE and credential theft and its detection, with a practical task for every topic and a capstone.

The report is the deliverable

The client does not receive your shell. They receive a document, and a good one is specific: what was found, where, how it was reached, how serious it is and what to change. Keep your notes from the first scan, because NIST SP 800-115 notes that written logs are usually kept, and periodic reports made, during the discovery and attack phases, not only a report at the end. For structure, tooling and a repeatable template, see Writing a Pentest Report (with SysReptor and Ghostwriter).

Detection and defence, from the defender’s side

Each guide closes with how the activity looks in logs or on the network and which settings stop it. The pattern repeats across the series: most of these techniques rely on settings and habits that can be changed (name resolution fallbacks left on, SMB signing not required, credentials left where a standard user can read them, missing patches, flat networks, unrestricted outbound traffic), and a defender who changes them removes whole classes of finding at once. Reading the series from that side is as useful as reading it as a tester.

Where to go next

KSEC ARK was started by Kai Castledine in 2015 (kaicastledine.co.uk); the series covers the same topics with current tools and a detection and defence section in each.

Start at the discovery stage if you are new to the field, or at name resolution if you already scan comfortably. Then build the lab and follow the Network and Active Directory Ultimate Course from end to end.

This article replaces the KSEC ARK notes first published in 2015.

More from this author