Page cover

Host discovery

Host discovery means visualizing the target network architecture and structure using the discovered hosts and network devices.

Network Monitoring

This is a very basic script that runs nmap every day using default ports and then uses ndiff to compare the results.

We can then take the output of this script and use it to notify our team of new ports discovered daily.

#!/bin/bash
mkdir /opt/nmap_diff
d=$(date +%Y-%m-%d)
y=$(date -d yesterday +%Y-%m-%d)
/usr/bin/nmap -T4 -oX /opt/nmap_diff/scan_$d.xml 10.100.100.0/24 >
/dev/null 2>&1
if [ -e /opt/nmap_diff/scan_$y.xml ]; then
/usr/bin/ndiff /opt/nmap_diff/scan_$y.xml /opt/nmap_diff/scan_$d.xml >
/opt/nmap_diff/diff.txt
fi

Remote Discovery

You can use nmap, masscan or unicorn scan for this:

nmap -sn -T4 -oG 192.168.1.1/24 | grep “Status: Up” | cut -f 2 -d ‘ ‘ > LiveHosts.txt
nmap –PE –sn -n 10.50.96.0/23 –oX /root/Desktop/scan.xml

The -PE enables ICMP Echo request host discovery (Ping scan)

The -sn option means only do a host discovery and not a port scan

Masscan is the fastest host discovery tool available, even faster than nmap.

Extracting Live IPs from Nmap Scan

Simple Port Knocking

DNS lookups, Zone Transfers & Brute-Force

Local Discovery

Netdiscover

Discover live hosts in LAN and get the internal IP address and MAC address of live hosts in the network.

It can be used in both active and passive mode.

Options:

Active Mode (Run as an ARP scanner)

Multiple Ranges from a File

Passive Mode (Run as an ARP sniffer)

Parsable Outputs

Responder

A great discovery tool for Active Directory Environments

Bettercap

Advanced MitM and sniffer tool.

Traceroute

Discovers the route that packets take between two system in the network.

It helps us to construct network architecture diagrams and it is included in most if not all OSs.

Windows:

Linux:

Linux traceroute

Linux traceroute sends packets to target with varying TTLs in the IP header. by default sends UDP packets with incrementing destination ports starting from port 33434 going up by one port for each probe packet sent ( each hope measured three times ).

Here are some of the most used options:

Windows traceroute

Sends ICMP echo request messages to target, starting with small TTLs.

Some useful options:

Web based traceroute services

Instead of tracing from your address to target various websites allow you to trace from them to the target.

So you can traceroute from around the world. by domain name or IP address. this is very useful in seeing if you are being shunned during a test.

Network Mapping

Traceroute

For best performance and mapping the network hops use traceroute with these three options and compare the results:

For an all in one command you can use this chain of commands:

This will run a traceroute with multiple methods and combine the results for better view.

Using this method we can minimize the chance of lost hopes in the route ( the * signs).

Here is the bash script you can use with the target domain or IP as an argument to perform the same task:

Zenmap

you can also use Zen map for network mapping which is a GUI for Nmap tool and can be downloaded from here.

Last updated