Chapter 05: Reconnaissance and Intelligence Gathering Flashcards
Asset Discovery
The act of finding devices that have been moved between locations or added without proper process and authorization
Ensures that you always know what’s on your network
Active Reconnaissance
Active recon uses host scanning tools to gather information about systems, services, and vulnerabilities
It doesn’t involve exploitation, but it can provide information about vulnerabilities that can be exploited
Preventing System Issues With Your Scan
Some services may not tolerate scan traffic well, and others may fill their logs or set off security alarms when you scan
Always make sure you have permission from the appropriate authority at your company before conducting active recon–secure youre “Get out of jail free” card
Also touch base with system and network admins to ensure the scans don’t have unintended impact
Scanning systems that belong to someone else without permission is illegal too
Active Scans and Network Topology
As an active scan traverses a network range, it can assess information contained in the responses it receives
This can help you make educated guesses about the topology of the network based on the TTL of the packet it receives, traceroute information, and responses from network and security devices
Topology information can be flawed and may not always match the actual design of the target network because:
* Security and network devices can use differences in the TTL and traceroute information
* Firewalls can make devices invisible to scans
* Wired vs wireless networks
* Virtual networks and environments
* On-premises vs cloud infrastructure
Pinging Hosts
The most basic form of discovery that you can do, with the ping command
It sends an ICMP echo request to a remote IP—if the system receives, it replies with an echo which indicates it’s up and running
A lack of response doesn’t always mean the host is down, because many firewalls block ping requests or individual systems might be configured to ignore ICMP packets
hping
An open source spoofing tool that provides a pentester with the ability to craft network packets to exploit vulnerable firewalls and IDS/IPS
Features
Host/Port Detection and Firewall Testing
Sends a SYN or ACK packet to conduct detection and testing
hping3 -S -p80 -c1 192.168.1.1
* Send 1 SYN packet to port 80 at this IP
hping3 -A -p80 -c1 192.168.1.1
* Send 1 ACK packet to port 80 at this IP
Timestamping
Used to determine the system’s uptime
hping3 -c2 -S –tcp-timestamp 192.168.1.1
* Send 2 SYN packets to port 80 at this IP to determine uptime
Traceroute
Uses arbitrary packet formats, like as a probing DNS ports using TCP or UDP, to perform traces when ICMP is blocked on a given network
Fragmentation
Attempts to evade detection by IDS/IPS and firewalls by sending fragmented packets across the network for later reassembly
* Not effective against modern OS and network appliances
* Can work on some legacy systems or ICS / SCADA
DoS
Can be used to perform flood based DoS attacks from randomized source IPs
* Not effective against modern OS and network appliances
* Can work on some legacy systems or ICS / SCADA
Port Scanners
Tools designed to send traffic to remote systems and then gather responses that provide information about the systems and the services they provide
One of the most frequently used tools when gathering information about a network and the devices connected to it
Because of this, they’re usually the first step in active recon
Common port scanner features:
* Host discovery
* Port scanning and service identification
* Device fingerprinting
* Service version identification
* OS identification
Common Ports and Services
Ports 0-1023 are well-known ports, or system ports
Ports from 1024-49151 are registered ports and assigned by IANA when requested—many are also used arbitrarily for services
Ports 49152-65535 are dynamic ports
Since ports can be manually assigned, simply assuming that a service running on a given port matches the common usage isn’t a smart move
Many SSH and HTTP/S servers are run on alternate ports, either to allow multiple web services to have unique ports or to avoid port scanning that targets 22 and 80/443
Scanning Viewpoint
Your scanning viewpoint for active recon makes a huge difference in the information gathered
Internal scans from a trusted system or network will provide much more information than an external scan of a well-secured network
If you’re attempting to replicate a specific scenario, like scanning by an external attacker who has no access to an internal system, your scanning viewpoint should match
OS Fingerprinting
OS fingerprinting is when you identify an OS based on the network traffic that it sends
It’s typically done with TCP/IP stack fingerprinting techniques that focus on comparing responsese to TCP and UDP packets sent to remote hosts
Differences in how OS and versions of OS respond, what TCP options they support, what order they send packets in, and other details provide a solid guess at what OS the remote system is running
Device Fingerprinting
The collection and correlation of information about a device like the software, services, and OS it runs that allows it to be uniquely identified as a specific type or version of a device
Particularly useful for identifying printers and other networked devices, but can also be used to identify workstations, servers, or any other network connected device if enough unique or typical information can be discovered
Devices that are firewalled and don’t respond to probes can still be fingerprinted given access to their ntwork traffic and to network device logs that are available
Service and Version Identification
Identifying services provides information about potential vulnerabilities and verifies that the service responding on a given port matches the serice that typically uses the port
Service identification is usually done one of two ways:
1. Connecting and grabbing the banner
2. Connection information provided by the service or by comparing its responses to the signatures of known services
Nmap
The most commonly used CLI port scanner that provides a broad range of capabilities, like multiple scan modes built to bypass firewalls and other network protection devices
Additionally, it also provides support for OS fingerprinting, service identification, and more
Default nmap Behavior
* Ping and send TCP ACK packet to ports 80 and 443
* This determines if a host is there and detected, and if so, it will do a port scan against that host to determine what services are running
Nmap Discovery Scan Options:
* -sn: Host discovery
* -sL: List scan to list IPs from supplied target range and perform reverse DNS query to discover any host names associated with the IPs
* -PS: TCP SYN ping to prove specific ports from the given list using a TCP SYN instead of ICMP to conduct the ping
* –scan-delay [TIME]: Sparse scanning issues probes with significant delays to become stealthier and avoid detection by IDS/IPS
* -Tn: Scan timing issues probes with using a timing pattern, with n being the pattern to utilize (n = 0 to 5 / slowest to fastest)
* -sI: TCP idle scan is another stealth method that makes it appear that another machine (a zombie) started the scan to hide the true identity of the scanning machine
* -f or –mtu: Fragmentation is a technique that splits the TCP header of each probe between multiple IP datagrams to make it hard for an IDS/IPS to detect
* Send nmap to files with -oN for normal files, -oX for XML, and -oG for grepable files
Nmap Service Discovery Options
* -sS: TCP SYN conducts a half-open scan by sending a SYN packet to identify the port state without sending an ACK packet afterwards
* -sT: TCP Connect conducts a three way handshake scan by sending a SYN packet to identify the port state and then sending an ACK once the SYN-ACK is received
* -sN: Null Scan conducts a scan by sending a packet with the header bit set to zero, this will flag IDS/IPS
* -sF: FIN Scan conducts a scan by sending an unexpected FIN packet, this will flag IDS/IPS
* -sX: Xmas Scan conducts a scan by sending a packet with the FIN, PSH, and URG flags set to one, lights up like a Christmas tree and will surely get you caught
* -sD: UDP Scan conducts a scan by sending a UDP packet to the target and waiting for a response or timeout
* -p: Port Range conducts a scan by targeting the specified ports instead of the default of the 1k most commonly used ports
Nmap Fingerprinting Scans
* -sV: An intensive port scan that gives basic versioning information
* -A: Another intensive port scan, but is way more intense and discovers more data and information like protocol, app name and version, OS type and version, host name, and device type
* -O: Detect OS version
Indicators of a Windows Host
When scanning, these are indicators that you’re dealing with a remote Windows host:
* Port 135: msrpc (MS Remote Procedure Call)
* Port 139: netbios-ssn (NetBIOS)
* Port 445: microsoft-ds (MS domain services)
* ICSLAP (used for MS internal proxying)
* WSDAPI (Web Services on Devices API, a MS devices API)
Angry IP Scanner
Multiplatform port scanner with a GUI
Unlike nmap, Agnry IP Scanner doesn’t provide dtailed identification for services and OS, but you can turn on different modules called “fetchers” to find ports, TTL, filtered ports, and more
When running Angry IP, configure the ports scanned under Preferences, otherwise no port information will be returned
Requires Java to run, which can be an issue because a lot of systems won’t have Java installed for security reasons