**Scanning and Enumeration

This lesson focuses on scanning and enumeration, crucial techniques for gathering information about a target system during a red team engagement. You'll learn how to identify open ports, discover running services, and gather valuable information to help you plan your attack strategy. We will be using common tools like Nmap to perform the tasks.

Learning Objectives

  • Understand the purpose of scanning and enumeration in a red team context.
  • Identify different types of network scans and when to use them.
  • Utilize Nmap to perform various scanning techniques to discover open ports and services.
  • Recognize common service banners and interpret the information they provide.
  • Explain the concept of enumeration and understand various enumeration techniques

Text-to-Speech

Listen to the lesson content

Lesson Content

Introduction to Scanning and Enumeration

Scanning and enumeration are the first steps a red team member takes after gaining initial access or establishing a foothold. Scanning is the process of identifying active hosts, open ports, and services running on a target network or system. Enumeration builds on this by gathering detailed information about these discovered services and systems. This information is vital for identifying vulnerabilities and planning effective attacks. Think of it like this: scanning is like looking for unlocked doors, and enumeration is like peering through the windows to see what's inside. Before starting any scan make sure to have all the necessary permissions and also any prior knowledge of the target.

Network Scanning with Nmap

Nmap (Network Mapper) is a powerful and versatile tool for network discovery and security auditing. It allows you to perform various types of scans to gather information about target systems. Here are some common Nmap scan types:

  • TCP Connect Scan (-sT): The default scan type. Establishes a full TCP connection. It's reliable but often logged by firewalls and intrusion detection systems (IDS).
  • TCP SYN Scan (-sS): Also known as a stealth scan. Sends a SYN packet (the beginning of a TCP handshake) and waits for a SYN/ACK (port open) or RST (port closed) response. It's faster and stealthier than a connect scan, but requires root/administrator privileges.
  • UDP Scan (-sU): Scans for open UDP ports. UDP is connectionless, so it's more challenging to scan. Nmap sends UDP packets and waits for an ICMP 'port unreachable' response. If it doesn't receive a response, the port is considered open or filtered (by a firewall).
  • Ping Scan (-sn): Discovers live hosts on a network without performing port scans. It sends an ICMP echo request (ping) to determine if a host is up.

Example Nmap Commands:

  • nmap <target_ip>: Basic scan, performs a TCP connect scan on common ports.
  • nmap -sS <target_ip>: TCP SYN scan (requires root).
  • nmap -sU <target_ip>: UDP scan.
  • nmap -sn <target_ip>: Ping scan (host discovery only).
  • nmap -p 1-1000 <target_ip>: Scan ports 1-1000.
  • nmap -A <target_ip>: Aggressive scan, includes OS detection, service version detection, and script scanning (use with caution).

Remember to replace <target_ip> with the actual IP address or hostname of the target. When doing scans, try to avoid unnecessary use of flags like -A or scripts unless they are specifically required, it creates more noise and is more easily detected. Always consider the impact your scan has on the target network.

Service and Version Detection

Nmap can not only identify open ports but also determine the service running on those ports and their versions. This information is crucial for identifying potential vulnerabilities. The -sV flag enables service version detection. The -O flag enables OS detection. The combination is very effective and often used.

Example: nmap -sV -O <target_ip>

When Nmap finds an open port, it will try to determine the service running on it (e.g., HTTP, SSH, FTP). It does this by analyzing the service banner - the information the service provides when a connection is made. For example, a web server might return HTTP/1.1 200 OK or Apache/2.4.41 (Unix). This information helps you identify potential vulnerabilities associated with that specific service and version.

Enumeration: Gathering More Information

Enumeration goes beyond scanning. It's the process of gathering as much information as possible about the discovered services and systems. This often involves connecting to services and interacting with them to understand their configuration and behavior. Some common enumeration techniques include:

  • HTTP Enumeration: Examining the web server's responses, looking for directory listings, checking for common files, and identifying technologies used (e.g., PHP, .NET).
  • SMB Enumeration: (Server Message Block) Gathering information about file shares, user accounts, and other network resources. Tools like smbclient and enum4linux are useful.
  • SMTP Enumeration: (Simple Mail Transfer Protocol) Identifying valid email addresses by attempting to send emails or querying the server.
  • SNMP Enumeration: (Simple Network Management Protocol) Retrieving information about network devices and their configuration (often using default community strings).

Example: Basic HTTP Enumeration Open a web browser and try browsing common directories such as /admin, /backup, or /robots.txt.

Progress
0%