IP & Port Scanning
Introduction
This section contains the tools to discover assets and the services running inside each of them.
Discovering assets
If the attacker needs to attack an internal network, first of all, will need to discover which hosts are active on that network. For doing so, we can use several tools.
Ping scan with Nmap pings each machine to check if it is active. However, if there are machines configured to not respond to pings, they will not appear (Machines with windows defender enabled).
The Arp-scan tool uses the Address Resolution Protocol (ARP) to identify all active network assets.
Another alternative would be to scan the top X ports of all the machines on a network, waiting for some to respond so we know a device is active.
Obtain the top X TCP ports based on Nmap.
Ports scanners tools:
Finally, another method much slower and less intrusive is sniffing the traffic. However, it will only detect the devices that send ARP requests or replies over the network, requiring a ton of time to notice the whole network.
Scanning assets
Once the attackers know the assets to analyse, they need to scan which ports have opened. This can be done with Nmap.
TCP Ports
Obtaining all TCP listening ports.
UDP Ports
Obtaining UDP listening ports.
Port information gathering
Then, for each TCP or UDP listening port, the attacker needs to identify the running service and version and extra information about them.
Simple vulnerability scanning
Nmap also provides scripts for detecting vulnerabilities in concrete services.
Detecting the Operating System
A simple way to detect the installed operating system is by checking the TTL of a ping. If the TTL is around 60, there is a high chance it is Linux; meanwhile, if the TTL is around 128, the system can be Windows.
Nonetheless, Nmap has built-in scripts to detect the operative system and version.
Massive host scanning
Imagine that you have a huge scope like a /16 network, which is a total of 65536 hosts. For those cases, you can use automated tools like Nessus or be very organised while scanning hosts.
The best option is the have each host separated by folders; so that every result of scans, tools, exploits, etc. are stored in the same host's folder. The problem is that when scanning a whole network con Nmap, the result is stored in one huge file. Hence, as a solution, with the script massScan.sh, you will obtain the scans in this structure.
This way, you can easily obtain which hosts have port 80 open with this command.
Finally, with the script massScan_depth.sh, you can make a scan more in-depth about each open port, knowing more information about each service. The results will be stored like this.
Nmap cheatsheet
Windows environment
As a first approach, the attacker can use Enum4linux for enumerating information from Windows and Samba systems.
Last updated