Skip to content

Instantly share code, notes, and snippets.

@rxerium
Created February 13, 2024 19:59
Show Gist options
  • Save rxerium/3e1640d79f2e4060610eb07ff2e08fc3 to your computer and use it in GitHub Desktop.
Save rxerium/3e1640d79f2e4060610eb07ff2e08fc3 to your computer and use it in GitHub Desktop.
Script to find online hosts on the network then check for ports / services running on online hosts
#!/bin/bash
echo "script starting..."
# installs nmap
apt update
apt install nmap -y
echo "nmap has been installed"
# finds hosts that are online on the network and outputs it to a online-hosts.txt file in the current dir
nmap -sn 192.168.1.0/24 -oG - | awk '/Up$/{print $2}' > online-hosts.txt
# runs nmap again to find open ports
nmap -iL online-hosts.txt -p- -oN port-scan-results.txt
echo "script complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment