A Bash-based solution for automated network host discovery and comprehensive scanning.
This script streamlines network monitoring by automatically detecting new hosts, performing detailed scans, and enriching results with vendor information. Designed for regulated environments where loud network scans are authorized.
- Host Discovery: Identifies live hosts via ARP scanning and Nmap ping sweep (
-sn
). - Deep Inspection: Executes advanced Nmap scans (
-A
) to enumerate open ports, running services, OS details, and version info. - Vendor Enrichment: Resolves MAC addresses to vendor names using the macvendors.com API.
- Incremental Updates: Maintains
networkIPs.txt
andoutput.txt
to skip already-scanned hosts and results. - Continuous Monitoring: Runs in a loop with a randomized sleep interval, ideal for real-time network oversight.
Ensure the following tools are installed and that the script runs with root privileges:
- nmap: Network exploration and security auditing tool.
- arp-scan: Fast ARP-based host discovery utility.
- curl: Command-line HTTP client for vendor lookups.
- bash: Unix shell and scripting language.
Install dependencies on Debian/Ubuntu:
sudo apt update && sudo apt install -y nmap arp-scan curl bash
-
Clone the repository:
git clone https://github.com/getintogit1/ScanMyNet.git cd network-scanner-automation
2. Grant execution permissions:
```bash
chmod +x network-scanner.sh
sudo ./network-scanner.sh <target-network>
<target-network>
: A CIDR range (e.g.,192.168.1.0/24
) or the keywordlocal
to scan the primary network interface.
Example:
sudo ./network-scanner.sh 192.168.0.0/24
Upon execution, the script generates/updates:
- networkIPs.txt: Discovered host IP addresses.
- output.txt: Tab-separated summary (
IP
,MAC
,PORT
,STATE
,SERVICE
,VERSION
). - output_with_vendor.txt: Same summary with an appended
VENDOR
column.
- Scan Interval: Defaults to a random delay between 20–140 seconds. Modify the
sleep
command in themain
function to customize. - Network Interface: Auto-detected via the
ip
command. Override by setting theinterface
variable manually. - API Rate Limiting: The vendor lookup delays 3 seconds per request to respect macvendors.com rate limits. Replace or optimize as needed.
- Privilege Check: Verifies execution as root (required for ARP and OS detection).
- Argument Validation: Ensures a target network is specified.
- ARP Scan: Uses
arp-scan
to discover new hosts, appending unique IPs tonetworkIPs.txt
. - Ping Sweep: Executes
nmap -sn
when no previous IP list exists. - Detailed Scan: Runs
nmap -A
against IPs fromnetworkIPs.txt
, parsing results intooutput.txt
. - Vendor Lookup: Retrieves vendor names for MAC addresses, producing
output_with_vendor.txt
. - Loop: Continuously repeats discovery and scanning until terminated.
This project is distributed under the MIT License.
Disclaimer: Use this script responsibly. Loud network scans can disrupt network operations and may violate acceptable use policies. Always obtain proper authorization before scanning any network.