External network penetration testing simulates an internet-based (usually unauthenticated) threat actor, with the goal of identifying vulnerabilities on externally exposed assets, accessing data, and breaching the network perimeter. The methodologies involved are in many ways similar to those involved in network penetration testing generally, but with key differences that relate to unique features of the external network perimeter’s attack surface, threat modeling, and the resulting security posture.
Network enumeration is the first real engagement we have with a target in an external penetration test, our digital “first impression.” In this phase, we're mapping the exposed surface of a network from the outside in, looking for anything that might allow us to gain a foothold into the target environment, compromise key external infrastructure, or expose sensitive data. There are many ways to go about this, among them various methods of identifying potential entry points, misconfigurations, forgotten subdomains, and other attack surfaces that may afford opportunities for exploitation.
When enumerating external environments, there are two key principles to keep in balance – gathering as much information as possible, and organizing that information in such a way that it is both digestible and usable. Having tons of information is not particularly useful if it does not paint a clear picture of the external attack surface and if it takes you down rabbit holes that do not lead anywhere interesting. Having an efficient workflow and a set of tools that work well together is crucial in painting this cohesive picture that will allow the greatest chance of discovery and exploitation of significant vulnerabilities.
For a first step, a port scan using Nmap or Masscan can get us started with manual triage while we await more comprehensive enumeration and scans. With the smaller scope of most external network perimeters, it likely won’t take very long to scan all TCP ports within the initial scoped range, so it is rarely necessary to perform initial host discovery to reduce scanning time:
# Scan top 100 TCP ports and grab banners—this can be used for a quick first pass on larger engagements:
nmap --top-ports=100 -sV --open -iL scope.txt -oA top100tcp -v
# Scan all TCP ports using Nmap:
nmap -p- -iL scope.txt -sV --open -oA alltcpports -v
# Scan top 100 UDP ports with Nmap:
nmap –top-ports=100 -iL scope.txt -sU -oA top100udp -v
# Scan all TCP ports using Masscan:
masscan -p- --rate 10000 -iL scope.txt -oG masscan.grp
Subdomain enumeration is a great way to expand the attack surface and find high-value targets that may have been neglected or forgotten. Each subdomain represents a potentially distinct service or system, and while the main site might be locked down, that legacy dev instance tucked under test.old.example.com might not be. This can be done using both open-source data and brute-forcing DNS requests using a wordlist of common subdomain prefixes. Some common useful tools are Subfinder, a stealthy tool that uses a variety of passive enumeration methods to find subdomains, and Gobuster, a quick active enumeration tool for—among other things—subdomain brute-forcing.
#
subfinder -d example.com -o subfinder_subdomains.txt
# Sublist3r works in a similar manner:
sublist3r -d example.com -o subdomains.txt
# Gobuster is an active enumeration tool that can quickly brute-force subdomains.
gobuster dns -do example.com -w wordlist.txt -t 50
Traditional DNS enumeration is only one method of discovering external assets. Certificate Transparency (CT) logs are among the richest sources of external reconnaissance available. Every publicly trusted TLS certificate issued by a certificate authority is recorded in one or more publicly searchable transparency logs. Because organizations frequently obtain certificates for staging systems, VPN gateways, mail servers, APIs, and development environments, CT logs often reveal hostnames that are otherwise absent from public DNS records or search engine indexes. Searching these logs can significantly expand the attack surface and frequently uncovers forgotten or poorly maintained systems. Some of the standard subdomain enumeration tools also include CT logs as resources, but you can also search CT logs manually using the crt.sh web UI, or query the API using command line native tools like curl and jq (to parse the JSON output), as shown below.
curl -s "https://crt.sh/?q=%25.example.com&output=json" | tr -d '\n' | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u
Open-source intelligence gathering can be a powerful tool to leverage to gain initial access, either directly or as part of a larger attack chain. One of the best ways to gain access externally is password spraying external login portals such as Microsoft 365 or VPN portals. For password spraying, a large number of usernames are tried against a small selection of high-probability passwords sequentially, to minimize risk of lockouts and detection. The greater the number of valid usernames gathered, the greater the probability of initial access.
The best source of probable company usernames is social media such as LinkedIn and marketing databases such as ZoomInfo. There are various tools that can scrape these sites and format them into common formats such as first.last, flast, etc. One of my favorites is linkedin2username, which rapidly scrapes LinkedIn and outputs all common username formats. Two useful features are used below, the keyword search and “geoblast,” both of which can bypass the usual limits on LinkedIn search results to net sometimes thousands of results. Another useful tip to maximize valid users is to send LinkedIn contact requests to employees of the company ahead of the pentest, which if accepted will provide more in-network results and fewer anonymous profiles.
linkedin2username.py -c 'targetcorp' -k 'sales,human,developer,manager,information,account,technology'
linkedin2username.py -c 'targetcorp' -g
Vulnerability scanning is an indispensable method for finding those “low-hanging fruit” vulnerabilities such as known remote code execution vulnerabilities and common misconfigurations that can quickly result in access if present. It allows for rapid triage of findings, which will help us best determine where to direct our manual efforts in later phases of the test. It also allows us to cover many bases at once with minimal effort and ensure that certain vulnerability classes aren’t overlooked. There are many vulnerability scanning tools available, but we typically use Nessus and Nuclei. Nessus tends to be slightly better for finding network service vulnerabilities, and Nuclei is better for finding web-based vulnerabilities.
A full tutorial on the use of Nessus is out of the scope of this guide, but some quick tips on setting up scans are in order. For both external and internal network testing, either an Advanced Scan or Basic Network Scan is a good starting platform. The latter starts with an already useful configuration but can also be highly customized. Setting up the scope and name of the scan is relatively straightforward:
Here are some useful modifications to the basic scan settings, and settings to remember. By default, only a subset of ports are scanned, so depending on the size of the network scope (usually small and manageable in external engagements) you will probably want to extend the range to all ports. You can select “all ports,” or “custom” and then set the port range manually. I usually select “custom” in order to modify other port scanner settings:
If you select a custom scan, other port scan configuration options are available, such as the type of TCP packets the scanner will send. The default is a SYN scan, and for most external engagements this is the best option, but it bears mentioning that legacy firewalls will sometimes hold connections open for a significant time awaiting the completion of a full TCP handshake, and this can cause denial of service conditions in poorly designed networks. This is mostly relevant in large internal networks with many legacy systems, but it is worth considering. If you suspect this is the case, you can uncheck SYN and instead select TCP, as follows:
UDP scans can also be enabled. This is worth doing, but if scope is large, it will significantly increase scan times, so careful selection of common UDP ports is warranted.
On the Assessment tab, I usually select “scan for known web vulnerabilities” both to decrease scan time and to avoid more intrusive fuzzing techniques, which in many cases also result in false positives.
Lastly, for deeper configuration options, the “custom” option under the Advanced tab can be selected. I recommend checking the following options, which will make the scan less intrusive and burdensome on the target network while still retaining thorough coverage. The additional SSH disclaimer prompt response simply makes enumeration of SSH servers more thorough:
Additionally:
If you have credentials, you can enter them into the “Credentials” tab for credentialed scanning. This is of course unlikely at the beginning of an external engagement, but a scan may be repeated if credentials are obtained during the engagement:
You can also set the credential scanner to enumerate Active Directory. This is usually not relevant externally, but internal AD infrastructure exposed to the internet is not unheard of, surprisingly.
There are many more settings that can be tweaked to various purposes, but these settings will serve well for most network penetration testing situations.
If you have a list of live web endpoints, a useful next step is to start poking around for hidden files and directories. These can often expose login panels, admin dashboards, backups, staging environments, or even source code. One can find all sorts of things exposed in this manner. On one memorable external engagement, I found a SOAP API exposed without authentication that included arbitrary read-write access to files on the host operating system as a feature, allowing me to upload a webshell and obtain remote code execution. Nessus will sometimes find directory listings and do limited directory enumeration, but for more in-depth enumeration, specialized tools are warranted. Again, there are two routes one can go down here—searching open-source records for indexed URLs, or brute-forcing directories. Below are some examples of both:
#Waybackurls searches archived web content for urls that may no longer be indexed:
cat domains.txt | waybackurls > urls.txt
cat example.com | waybackurls | anew urls.txt
#Getallurls is an extended version, which works similarly
cat domains.txt | getallurls > urls.txt
#Gobuster is a fast brute-forcing tool for, among other things, web content:
gobuster dir -u https://example.com -w wordlist.txt -o gobuster_results.txt
Enumerating virtual hosts (vhosts) is often an important part of external attack surface mapping. Virtual hosting allows multiple web sites or applications to be hosted on a single web server. If you only browse to the IP address or the primary hostname, you may sometimes miss additional attack surface. Modern web servers frequently use the HTTP Host header to determine which website to serve.
Different vhosts may have different authentication mechanisms, technologies, or vulnerabilities, and administrative portals, development environments, staging systems, APIs, or forgotten applications may exist on undiscovered vhosts. Sometimes, innocuous-looking hosts may harbor critical systems, which would go unchecked without vhost enumeration. The most common method we can use to enumerate a server for vhosts is a dictionary attack against the Host header. Many fuzzing tools exist that can do this. Gobuster, for example, has its own vhost module:
gobuster vhost -u https://target-ip -w subdomains.txt
Once you have a list of web endpoints, a useful next step is to perform a web flyover using a tool that emulates a browser, visiting the URL and taking a screenshot of any application that is listening. In this way, login portals, out-of-date software, and exposed API functionality can be quickly uncovered. It often pays to do multiple rounds of flyovers. First, after initially amassing some target DNS hostnames or IP addresses, and then again after more in-depth web enumeration is performed. There are several tools that can be used, of which I prefer Eyewitness:
eyewitness -f subdomains.txt -d ew-out --timeout 14 --delay 5 --threads 10
#You can also export results from Nessus or Nmap as XML and feed it to Eyewitness:
eyewitness -x scan_results.nessus --timeout 20 --delay 5 -d ext-ip-ew
Combining all of the previous steps—checking for web content on non-standard ports, checking enumerated subdomains against scoped IPs to find vhosts, performing endpoint enumeration, then performing flyovers—can vastly increase the overall attack surface, which may harbor vulnerabilities.
As mentioned previously, Nuclei is another vulnerability scanning platform that is especially proficient at finding web vulnerabilities. It is modular and extensible, with many custom vulnerability discovery templates available online. As your iterative process of enumeration uncovers more hosts and services or web endpoints, it is good practice to run additional vulnerability scans, and to try different tools and settings to compare results and ensure that nothing falls through the cracks. Nuclei can be used simply and easily to run generic scans using default templates, or scans can be customized in any number of ways to run using single templates, categories of templates, or by tags. We’ll mostly stick to some simple examples here.
# Scan a single web endpoint:
nuclei -u https://dev.targetcorp.com
# Scan another single network service:
nuclei -u <target-IP>:<target-port>
# Scan a list of IPs or URLs:
nuclei -l targets-list.txt
# Attempt to fingerprint services and automatically assign templates:
nuclei -l targets-list.txt -as
# List templates
nuclei -tl
# List templates by tag:
nuclei -tl -tags cve,misconfiguration
# Scan using only templates in selected template directories and subdirectories:
nuclei -l targets-list.txt -t http/cves -t network/cves
# Scan using templates with given tags:
nuclei -l targets-list.txt -tags misconfiguration,exposure
Now comes the juncture where we shift from enumeration into active exploitation attempts. Credential attacks are the most common method of external access available to both penetration testers and attackers, and credential vulnerabilities are among the hardest to remediate. No matter what policy is implemented, it seems that humans are highly skilled at getting around them to select weak passwords. There are two common methodologies I often use in an attempt to gain credential access, password spraying and credential stuffing.
Password spraying involves trying a single high-probability password against the entire list of probable users. Often we select variations of strings like <CompanyName><YEAR>, <Welcome><YEAR>, <Password><Number>, and similar variants involving seasons, months, local sports teams, company-related terms, etc. This is a game of probability. The more valid users you have collected, the more likely it is that at least one of them has selected one of these very common patterns.
Credential stuffing makes use of open-source credential breach data. We search for company employees with breached accounts. Sometimes these breached accounts are company accounts themselves, and sometimes they are accounts on third-party services, for which a user has signed up using a company email. In the latter case, it is still possible that the same password, or a guessable variant, has been reused in a target company account. There are several options for obtaining breached credentials, but the platform I have been using recently is Flare.io.
For executing password spraying and credential stuffing attacks against Microsoft endpoints, there are many tools, but I prefer o365spray. This tool integrates the functions of tenant enumeration, username validation, and spraying/stuffing into one Swiss Army knife of password attacks. For alternative endpoints such as web VPN portals and administrative panels, Burp Suite’s Intruder is the most flexible and adaptable tool that can be used to perform attacks against almost anything web-based.
o365spray --validate --domain example.com
o365spray --enum -U usernames.txt --domain example.com
For gathering credentials, Flare gives us several options. We can use credits to perform persistent lookups against various keywords--referred to as selectors--such as email addresses or domains. Typically, however, the most useful and credit-efficient method for external network penetration tests is to perform a “Global Search” for an email domain in the “Credentials” tab:
For spraying attacks with scraped usernames, the following are some typical commands:
o365spray --spray -U usernames.txt -p 'Targetcorp2026!' --domain targetcorp.com
# To reduce lockouts, limiting the threads and increasing and randomizing the sleep time can help:
o365spray --spray -U usernames.txt -p 'Targetcorp2026!' --domain targetcorp.com --rate 1 --sleep 10 --jitter 29
# For even greater stealth, there are proxying tools that can rotate IPs through either the AWS or the Tor network. Sometimes, conditional access policies are region-based, so here proxies are also useful. To use a proxy:
o365spray --spray -U usernames.txt -p 'Targetcorp2026!' --domain targetcorp.com –proxy http://myproxy.com
# To specifically use FireProx
o365spray --spray -U usernames.txt -p 'Targetcorp2026!' --domain targetcorp.com –proxy-url <aws_api_url>
For attacks using colon-separated credential pairs, such as those obtained from Flare or similar tools:
o365spray --spray --paired breached-userpass-colonseparated.txt --domain example.com
To perform any sort of password attack in Burp, the first step is to capture the login request via the Proxy->Intercept module, then right-click on the request and send the request to the Intruder module to set up the configuration for the attack.
Once in the Intruder tab, highlight the contents of whatever the “user” field is called for the application in question, and click the “add” button. This will create a parameter wherein Burp will insert its payloads. For a simple password spray attack, the “Sniper” attack configuration is used. This will insert all items from a list of usernames you provide into the user parameter in sequence. Now, simply add your list of enumerated usernames into the payload configuration and start the attack:
To perform a credential stuffing attack using Burp, we must change our Intruder settings. Instead of a single parameter and a single list of payloads, we will use two of each—one for usernames and another for passwords. They will be interpolated in parallel, i.e., the first lines from each list will be included in the respective user and password parameters as a pair, then the second lines in each, and so forth. The proper Burp attack configuration to select for this is “Pitchfork.” We then add payload parameters for both the user and password fields, then we add two payload sets, one corresponding to each parameter. The first payload set in this case will be the usernames:
The second payload set will of course be the passwords to be paired with each username:
Public source code repositories often provide valuable reconnaissance opportunities. Organizations frequently publish open-source projects or inadvertently expose internal repositories containing configuration files, API endpoints, infrastructure details, or sensitive credentials. Even when no secrets are immediately exposed, source code often reveals application architecture, authentication mechanisms, hidden endpoints, cloud resource names, and internal naming conventions that greatly assist subsequent testing, assuming these assets are within scope.
Secret-scanning tools can rapidly identify exposed API keys, authentication tokens, private keys, cloud credentials, and other sensitive material committed to public repositories. Likewise, archived repositories, release artifacts, GitHub Actions workflows, package registries, and project documentation frequently contain valuable intelligence that would otherwise remain undiscovered through network enumeration alone. Tools and techniques include Trufflehog, Gitleaks, GitHub code search, and GitHub dorks. Trufflehog is the most versatile, and can be run locally on a cloned repository or against a web-hosted git repository.
# Run trufflehog against a Github org (optionally limit results to verified for large orgs):
trufflehog github --org targetcorp –-results=verified
#Run trufflehog against a single repo on the web:
trufflehog git https://github.com/targetcorp/somerepo
#Run trufflehog against a locally downloaded Git repo, from parent directory:
trufflehog git file://somerepo
In fact, Trufflehog is far more than simply a Git repository scanning tool. It can be used to extract secrets from many types of storage structures including filesystems, AWS s3 or GCS buckets, Jenkins instances, Docker images, and more. For a comprehensive overview of its capabilities, refer to the Trufflehog documentation.
Speaking of S3 buckets, such cloud infrastructure is often an important and sometimes overlooked part of the external attack surface. Amazon S3 buckets, as well as Azure Blob Storage containers and Google Cloud Storage buckets, occasionally expose source code, backups, credentials, customer data, or other sensitive information through overly permissive access controls. References to bucket names frequently appear throughout public source code, JavaScript files, DNS records, or application responses, making targeted enumeration worthwhile. If you, for instance, have collected a list of buckets from these previous enumeration steps, you can then pass these to a tool like S3Scanner to find open buckets, then run Trufflehog against any you identify.
# Search for public S3 buckets:
s3scanner scan -bucket-file buckets.txt
# Search for public S3 buckets, then enumerate all objects:
s3scanner scan -bucket-file buckets.txt -enumerate
# Scan a GCP bucket:
s3scanner -bucket somebucket -provider gcp -enumerate
# Enumerate a bucket for secrets using Trufflehog:
trufflehog s3 --bucket=somebucket --results=verified,unknown
Entra ID, and Microsoft 365 (M365) infrastructure generally, is becoming a more and more integral part of the external attack surface. Entra ID serves as the identity provider for Microsoft 365, Azure, SaaS applications, VPNs, and many federated services. Compromising a single Entra account can potentially provide access to email, SharePoint, Teams, Azure resources, enterprise applications, and on-premises Active Directory environments through hybrid identity configurations. Entra can often be abused to escalate privileges directly, as well as indirectly, as SharePoint, email inboxes, and OneDrive instances are often found to contain plaintext credentials visible to low-privileged users. In the case of initial credential access, this is often the logical next step.
Let’s assume you’ve gotten a set of valid Microsoft credentials from password attacks, but MFA is required to log in to M365. There are a whole range of alternative Microsoft login endpoints that may have legacy authentication enabled, which doesn’t support MFA. A tool like MFASweep quickly checks each of these endpoints.
git clone https://github.com/dafthack/MFASweep.git
cd MFASweep/
import-Module ./MFASweep.ps1
Invoke-MFASweep
Assuming you can authenticate to Microsoft Graph API with your credentials, GraphRunner is a veritable Swiss Army Knife of Entra ID enumeration and exploitation. There are far too many attack vectors to cover everything here, and it is recommended that you research these further, but several enumeration techniques and high-value exploit chains are worth briefly mentioning. Initial recon involves determining both global and user-specific permission settings and enumerating users and security groups.
Some initial things to look out for are the ability to invite guests to the tenant, dynamic group membership rules, and groups that the user can update. The exploitation potential for the latter is obvious if the user can update groups that have additional permissions. Dynamic groups and the ability to invite external users present interesting privilege escalation opportunities, depending upon the conditional logic of the dynamic membership rule. If membership in a dynamic administrative group is, for example, conditional upon the user principal name, and you can invite guest users to the tenant, then you can invite a user with a name that matches the rule, and thereby become an administrator.
import-Module ./GraphRunner.ps1
List-GraphRunnerModules
#Authenticate to MS Graph and retrieve tokens, check access, or refresh tokens:
Get-GraphTokens
Invoke-CheckAccess -Tokens $tokens
Invoke-RefreshGraphTokens
#Basic recon + user permission enumeration
Invoke-GraphRecon -Tokens $tokens
Invoke-GraphRecon -Tokens $tokens -PermissionEnum
#Enumerate Entra ID users and groups:
Get-AzureADUsers -Tokens $tokens
Get-SecurityGroups -Tokens $tokens
#Get groups updatable by current user or dynamic membership rules.
Get-UpdatableGroups -Tokens $tokens
Get-DynamicGroups -Tokens $tokens
#Invite guest user to tenant (useful with dynamic group exploits or for persistence)
Invoke-InviteGuest -Tokens $tokens
#Add user to group
Invoke-AddGroupMember -Tokens $tokens
If we can escalate privileges or obtain exposed credentials from Entra, we may obtain the holy grail of external network pentesting—obtaining internal network access. Certain Entra groups may have VPN access, or plaintext credentials for AD accounts or for other services may be observed in emails or in OneDrive or SharePoint.
All of these tools and techniques are each powerful in themselves, but what ultimately makes for an effective penetration test is how they are combined into an iterative workflow that involves cycles of enumeration and exploitation, speedy automated scanning, triage, and in-depth manual review. As the test progresses, new discoveries and insights will be made, and the attack surface will expand, requiring that we sometimes revisit earlier steps to ensure that good coverage is achieved. Then, an understanding of severity, exploitability, and real-world threat modeling aids in triage to prioritize the highest-value systems and vulnerabilities for manual review and potential exploitation. This sort of understanding is gained largely by experience and by improving one’s general knowledge of the always-evolving technologies in use on the network perimeter, as well as keeping abreast of newly disclosed vulnerabilities. By keeping all these factors in mind, we can use our limited time more wisely and ultimately spend that time discovering and exploiting more significant vulnerabilities.