Reconnaissance and Scanning

Passive Reconnaissance

This section focuses on the very first part of a penetration test: Passive Reconnaissance. This is where you use all the tools and resources at your disposal to gather up all of the information you can on your target, without interacting with the target in anyway (no scanning).

For more tools and resources on intelligence gathering outside of the below frameworks, please see the OSINT section under Cyber Intelligence.

After your passive reconnaissance phase, the next step is active scanning of your target. This usually involves port scanning and scanning for any vulnerabilities that your target might have, preferably with out them noticing. Active scanning does have direct interaction with your target and does run the risk of being detected. There are ways to subtle scan your target and not draw too much attention. This can include slowing the rate of your scanning or performing them in such a way as to not create a full connection request that would trigger any defensive alerts.

pageOSINT

For ease of collection, there are many Recon Frameworks available that can gather intel from multiple sources and leverage multiple tools. They are a great way to save time on your Recon tasks.

Note: Many Recon Frameworks have both passive and active reconnaissance capabilities.

pageRecon Frameworks

Active Recon and Scanning

The following section will contain scanning tools and resources such as port scanners, vulnerability scanners, and so much more!

Attack Surface Mapping and Discovery

Attack Surface Mapping is the process of discovering, identifying, and analyzing all potential attack vectors on an organization’s IT infrastructure. This helps to identify vulnerabilities and threats to the system, as well as helping to decide how best to protect the system from malicious attack and exploitation. Attack surface mapping involves analyzing the assets and services available on a network, determining the boundaries of the system, and looking for potential attack vectors and vulnerabilities.

The first step in attack surface mapping is asset discovery. This involves gathering information about the system, including the hardware, software, and services that are running on the network. This includes both internal and external assets, such as web applications, databases, and other services. This information can be gathered manually, or with the help of automated tools.

The next step is to identify the attack vectors. Attack vectors are the various methods and techniques attackers can use to gain access to the network and its services. These include physical access, remote access, phishing attacks, malware, and social engineering. Once the attack vectors have been identified, the security team can then analyze them to determine the potential for exploitation.

The third step is to analyze the attack vectors and identify any vulnerabilities. This involves looking for any weaknesses in the system that could be exploited by an attacker. This can include weak passwords, unpatched software, and insecure configurations. Once the vulnerabilities have been identified, the security team can then decide on the best course of action to protect the system from potential attacks.

Many Recon Frameworks can be excellent for Attack Surface Management.

pageRecon Frameworks

Host/Asset discovery

Once on or apart of a target network we can perform a more detailed round of enumeration and discovery. By directly interacting with local network applications, host discovery can be used to identify vulnerable systems, services, and network topology.

Once the active devices on the network have been identified, the penetration tester can move on to the next steps in the penetration test process, such as vulnerability analysis and exploitation.

Host discovery can be performed by a few handy tools as well as command to enumerate hosts via various services.

nmap --script broadcast-dhcp-discover

Responder is a great tool for spoofing various network protocols but can also be used in "analyze" modes.

  • BROWSER mode: inspect Browse Service messages and map IP addresses with NetBIOS names

  • LANMAN mode: passively map domain controllers, servers and workstations joined to a domain with the Browser protocol

  • LLMNR, NBTNS, MDNS modes: inspect broadcast and multicast name resolution requests

The following command will enable the analyze modes and will give interesting information like:

  • Domain Controller, SQL servers, workstations

  • Fully Qualified Domain Name (FQDN)

  • Windows versions in used

  • The "enabled" or "disabled" state of protocols like LLMNR, NBTNS, MDNS, LANMAN, BROWSER

// Some code

https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/responder-20-owning-windows-networks-part-3/

Port-Scanning

Port Scanning is a security penetration test that involves the use of software to identify open ports on a network and the services running on those ports. It is an important part of a security assessment because it can uncover security vulnerabilities that may otherwise be overlooked.

During a port scan, the software sends packets to each port on the target system and listens for a response. Depending on the response, the software can determine whether a port is open or closed. If a port is open, the software can also determine the service running on it. This information can help the tester identify any vulnerable services that can be exploited.

Port Scanning can help determine if there are any unauthorized access points, such as open ports or services running without authentication. It can also help determine if any services are running outdated versions of software that could be vulnerable to exploits.

Port status and other details can be gathered via manual requests, or through port scanning tools.

The tool NMAP has long been the standard for port scanning is an essential tool for all security testers to know.

pageNMAP
Masscan

This is an Internet-scale port scanner. It can scan the entire Internet in under 5 minutes, transmitting 10 million packets per second, from a single machine.

# sudo apt install masscan 
# sudo masscan -p [port(s)] [IP CIDR] 
  • -oL [log file]

  • -e specify interface

  • --rate rate of packet transmission

  • --router-ip - specify the IP address for the appropriate gateway

UnicornScan

Unicornscan is an attempt at a User-land Distributed TCP/IP stack. It is intended to provide a researcher a superior interface for introducing a stimulus into and measuring a response from a TCP/IP enabled device or network.

Other Tools
  • WebMap - Nmap Web Dashboard and Reporting

  • Scantron - Scantron is a distributed nmap and Masscan scanner comprised of two components. The first is a console node that consists of a web front end used for scheduling scans and storing scan targets and results. The second component is an engine that pulls scan jobs from the console and conducts the actual scanning.

  • Scanless - This is a Python 3 command-line utility and library for using websites that can perform port scans on your behalf.

  • naabu - A fast port scanner written in go with a focus on reliability and simplicity. Designed to be used in combination with other tools for attack surface discovery in bug bounties and pentests

  • RustScan - The Modern Port Scanner. Find ports quickly (3 seconds at its fastest). Run scripts through our scripting engine (Python, Lua, Shell supported).

  • knocker - Knocker is a new, simple, and easy to use TCP security port scanner written in C, using threads. It is able to analyze hosts and the network services which are running on them.

  • unimap - Scan only once by IP address and reduce scan times with Nmap for large amounts of data.

Manual Port Checks

Netcat banner grab

nc -v 10.10.10.10 port

Telnet banner grab

telnet 10.10.10.10 port
Probe Response CheatSheet
  • Open port: SYN --> SYN/ACK --> RST

  • Closed port: SYN --> RST/ACK

  • Filtered port: SYN --> [NO RESPONSE]

  • Filtered port: SYN --> ICMP message

For more detailed identification of running appications, even if they are running on a non-standard port, we can use Application Detection tools to enumerate these.

AMAP - Attempts to identify applications even if they are running on a different port than normal.

$ amap -d $ip <port>

DNS Recon

DNS reconnaissance is the process of gathering information about a domain by querying various DNS records. DNS reconnaissance is often used to identify hosts, subdomains, and services associated with a domain. It can also provide insight into the network infrastructure, such as the type of DNS servers being used and the type of records they are responding with.

DNS Enumeration tools can give detail not just on DNS services related to your target, but also be used to identify other assets such as related domains and IP addresses.

DNS Enumeration Tools
  • dnsdumpster - A tool to perform DNS reconnaissance on target networks. Among the DNS information got from include subdomains, mx records, web application firewall detection and more fingerprinting and lookups

  • dnscan - dnscan is a python wordlist-based DNS subdomain scanner.

  • dnsenum - Dnsenum is a multithreaded perl script to enumerate DNS information of a domain and to discover non-contiguous ip blocks.

  • dnsmap - dnsmap scans a domain for common subdomains using a built-in or an external wordlist

  • dnstracer - determines where a given Domain Name Server (DNS) gets its information from for a given hostname, and follows the chain of DNS servers back to the authoritative answer.

  • Lepus - A tool for enumerating subdomains, checking for subdomain takeovers and perform port scans - and boy, is it fast!

  • Knock - Knockpy is a python3 tool designed to enumerate subdomains on a target domain through dictionary attack.

  • altdns - a DNS recon tool that allows for the discovery of subdomains that conform to patterns.

  • assetfinder - A tool to find domains and subdomains potentially related to a given domain.

  • fierce - Fierce is a semi-lightweight scanner that helps locate non-contiguous IP space and hostnames against specified domains. It’s really meant as a pre-cursor to nmap, unicornscan, nessus, nikto, etc, since all of those require that you already know what IP space you are looking for.

  • cansina - a Web Content Discovery Application. Help you making requests and filtering and inspecting the responses to tell apart if it is an existing resource or just an annoying or disguised 404.

  • Sublist3r - Sublist3r is a python tool designed to enumerate subdomains of websites using OSINT. It helps penetration testers and bug hunters collect and gather subdomains for the domain they are targeting. Sublist3r enumerates subdomains using many search engines such as Google, Yahoo, Bing, Baidu and Ask. Sublist3r also enumerates subdomains using Netcraft, Virustotal, ThreatCrowd, DNSdumpster and ReverseDNS. This tool can do both scraping and Bruteforce which makes it a nice combined tool. The downside how ever is the wordlist cannot be specified.

  • dnsx - dnsx is a fast and multi-purpose DNS toolkit allow to run multiple DNS queries of your choice with a list of user-supplied resolvers.

  • massdns - A high-performance DNS stub resolver for bulk lookups and reconnaissance (subdomain enumeration)

    • Due to how many requests sent, we should use a list of resolvers to not get our connection banned. More on rate limiting here: https://github.com/blechschmidt/massdns#rate-limiting-evasion

    • shuffledns - MassDNS wrapper written in go that allows you to enumerate valid subdomains using active bruteforce as well as resolve subdomains with wildcard handling and easy input-output support.

  • SubDomainizer - A tool to find subdomains and interesting things hidden inside, external Javascript files of page, folder, and Github.

  • shosubgo - Small tool to Grab subdomains using Shodan api.

  • zdns - Fast CLI DNS Lookup Tool

  • aiodnsbrute - A Python 3.5+ tool that uses asyncio to brute force domain names asynchronously. This is a bruteforcer with insane speed, and a very large number of built in wordlists. Use a list of resolvers with it

  • Altdns: Altdns is a DNS recon tool that allows for the discovery of subdomains that conform to patterns. Altdns takes in words that could be present in subdomains under a domain (such as test, dev, staging), as well as a list of known subdomains.

  • Findomain: Findomain offers a dedicated monitoring service hosted in Amazon (only the local version is free), that allows you to monitor your target domains and send alerts to Discord and Slack webhooks or Telegram chats when new subdomains are found.

  • Dome - Fast and reliable python script that makes active and/or passive scan to obtain subdomains and search for open ports.

Sub-domains are subsections of larger domains used to create separate sections of a website or to organize content into different categories. Each subdomain can provide a wealth of new attack vectors and vulnerabilities to map.

Discovering Sub-Domains can involve dynamic crawling of a website, brute forcing of common sub-domain names, and then visually parsing and flying through subdomains looking for anything fun and interesting. This process is called Sub-Domain Fly-Over.

  • Aquatone - Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

  • EyeWitness - EyeWitness is designed to take screenshots of websites, provide some server header info, and identify default credentials if possible

  • Meg: Meg is a tool for fetching lots of URLs without taking a toll on the servers. It can be used to fetch many paths for many hosts, or fetching a single path for all hosts before moving on to the next path and repeating.

Vulnerability Scanning

Vulnerability scanning is a process of identifying, detecting, and assessing security vulnerabilities in a computer system. It is designed to find known and unknown security risks in a network or computer system. Vulnerability scanning helps organizations identify and address any weaknesses in their systems before they can be exploited by attackers.

A vulnerability scan usually involves using automated tools to scan a system for known vulnerabilities. The scan looks for known weaknesses, such as incorrect settings, outdated software, missing patches, or other security flaws that could be exploited by attackers. After the scan is complete, a report is generated outlining the weaknesses found and providing recommendations on how to address them.

Vulnerability scanning is an important part of a comprehensive security program, and helps organizations identify and address weaknesses before attackers can exploit them. Conversely, vulnerability scanners are often used by offensive security testers to identify weak targets for exploitation.

  • BTFM: Scanning and Vulnerabilities - pg. 11

  • Penetration Testing: Finding Vulnerabilities - pg.133

https://www.tenable.com/products/nessus/nessus-professional

The most popular vulnerability scanning tool on the web.

Commands

Web Application Scanning and Testing

Web Application Security Testing is a type of security testing that is used to identify and address security vulnerabilities in web applications. It is a process that involves testing the security of web applications for weaknesses that could potentially be exploited by attackers. The goal of this type of testing is to identify and fix any security issues that could lead to the unauthorized access, manipulation, or destruction of data, or any other malicious activity.

Dynamic application security testing (DAST) is a process used to assess the security of a web application while it is running. This type of testing can be used to identify application-level vulnerabilities, such as cross-site scripting (XSS) and SQL injection.

For testing various web applications there are a multitude of testing tools for both individual vulnerabilities, as well as comprehensive suites. The foremost of these is Burp Suite.

pageBurp SuitepageWeb App Testing FrameworkspageWeb App Scanning Utilities

...burp...

  • Photon - Incredibly fast crawler designed for OSINT.

  • URLgrab - A golang utility to spider through a website searching for additional links.

  • hakrawler - Simple, fast web crawler designed for easy, quick discovery of endpoints and assets within a web application. Also built by the Legendary Hakluke

  • gospider - This package contains a Fast web spider written in Go.

  • filebuster - Filebuster is a HTTP fuzzer / content discovery script with loads of features and built to be easy to use and fast! It uses one of the fastest HTTP classes in the world (of PERL) - Furl::HTTP. Also the thread modelling is optimized to run as fast as possible.

  • feroxbuster - feroxbuster is a tool designed to perform Forced Browsing. Forced browsing is an attack where the aim is to enumerate and access resources that are not referenced by the web application, but are still accessible by an attacker.

Misc Web App Testing Tools
  • https://www.webgap.io/ - WEBGAP remote browser isolation physically isolates you from the risks of using the internet by isolating your web browsing activity away from your local device.

  • Race-the-web - Tests for race conditions in web applications. Includes a RESTful API to integrate into a continuous integration pipeline.

  • DVCS-Ripper - Rip web accessible (distributed) version control systems: SVN, GIT, Mercurial/hg, bzr, etc.

  • Unfurl - Tool for breaking down a URL to better understand its components.Fake credit card numbers for testing payment systems

Other Scanning Utilities

SSL/TLS Scanning
  • SSL Cipher Suite Enum - Perl script to enumerate supported SSL cipher suites supported by network services (principally HTTPS).

  • sslScrape - strips hostnames form certs over port 443 connections

  • SSLYZE - TLS/SSL config analyzer

  • tls_prober - TLS Prober is a tool for identifying the implementation in use by SSL/TLS servers. It analyses the behaviour of a server by sending a range of probes then comparing the responses with a database of known signatures.

  • testssl.sh - A free command line tool which checks a server's service on any port for the support of TLS/SSL ciphers, protocols as well as some cryptographic flaws.

  • https://pentestbook.six2dez.com/enumeration/ssl-tls - List of commads to test for specific SSL/TLS Vulnerabilities.

Misc Scanning tools
  • HoneyCaught - Honeypot detection tool

  • Sniffing Bear - A modular and distributed tool developed in python to scan networks for honeypots

  • https://honeyscore.shodan.io/ - Shodan honeypot detector.

  • changeme - This package contains a default credential scanner. changeme supports the http/https, MSSQL, MySQL, Postgres, ssh and ssh w/key protocols.

  • SharpShare - Enumerate all network shares in the current domain. Also, can resolve names to IP addresses.

  • Phishious - An open-source Secure Email Gateway (SEG) evaluation toolkit designed for red-teamers.

  • firewalk - Firewalk is an active reconnaissance network security tool that attempts to determine what layer 4 protocols a given IP forwarding device will pass.

  • ftester - The Firewall Tester (FTester) is a tool designed for testing firewall filtering policies and Intrusion Detection System (IDS) capabilities.

Last updated