1 - Enumeration

When we need to perform an internal test for the entire company, it is helpful to know all the systems that are online and available for us to work with
The most effective host discovery method is to use ICMP (Ping) requests
Example:
terminal
$ sudo nmap 10.129.2.0/24 -sn --reason -PE -A -oA tnet | grep for | cut -d" " -f5
  • sn : Do not scan ports
  • oA : Saves the results in all formats
  • PE : Send ICMP echo requests
  • -reason: Shows the reason why the host is online
  • A : Performs service detection, OS detection, traceroute, and uses default scripts to scan the target (Aggressive)

Port States

  • Open: This indicates that a connection has been established with the scanned port. These connections can be TCP connections or UDP datagrams
  • Closed: When the port is shown as closed, the TCP protocol indicates that the packet we received contains an RST flag
  • Filtered: Nmap cannot correctly identify whether the scanned port is open or closed because no response is returned
  • Unfiltered: This port state only occurs during a TCP-ACK scan and means that the port is accessible
  • Open\|Filtered: If we do not receive a response for a specific port, Nmap will set it to this state. This indicates that a firewall or packet filter may be protecting the port
  • Closed\|Filtered: It does not know whether the port is closed or filtered by a firewall

Categories

  • Category: Description
  • auth: Determination of authentication credentials.
  • broadcast: The scripts used for host discovery through broadcasting can automatically add discovered hosts to the remaining scans
  • brute: Runs scripts that attempt to log in to the respective service by brute-forcing credentials
  • default: Default scripts run using the -sC option
  • discovery: Assessment of accessible services
  • dos: These scripts are used to check services for denial-of-service vulnerabilities and are used less often because they can damage services
  • exploit: This category of scripts attempts to exploit known vulnerabilities for the scanned port
  • external: Scripts that use external services for further processing
  • fuzzer: This uses scripts to identify vulnerabilities and unexpected packet handling by sending different fields, which can take a long time
  • intrusive: Intrusive scripts that could negatively affect the target system
  • malware: Checks whether any malware infects the target system
  • safe: Defensive scripts that do not perform intrusive or destructive access
  • version: Extension for service detection
  • vuln: Identification of specific vulnerabilities
terminal
$ sudo nmap <target> --script <category>
sudo nmap <target> --script <script-name>,<script-name>

Firewall

To bypass the firewall, the most recommended option is to use the -D (Decoy) flag, which generates several random IP addresses
  • D RND:5 : RND means random, 5 IPs
  • -disable-arp-ping : Disables the sending of ARP packets
  • -mtu <num_paquetes> : Send a number of packets
  • -randomize-hosts: Scan ports in a different order
  • -source-port <puerto>: Choose which port we attack from. For example, if port 53 on the target machine is filtered, we can attack from our own port 53