Skip to content

Instantly share code, notes, and snippets.

@bmuskbytewolf
Last active August 4, 2021 20:39
Show Gist options
  • Save bmuskbytewolf/95855d29d1e3b78080211855cba80a83 to your computer and use it in GitHub Desktop.
Save bmuskbytewolf/95855d29d1e3b78080211855cba80a83 to your computer and use it in GitHub Desktop.
Port discovery without NMAP
#!/bin/bash
subnet="192.168.30"
top10=(20 21 22 23 25 80 110 139 443 445 3389)
for host in {1..255}; do
for port in "${top10[@]}"; do
(echo > /dev/tcp/"${subnet}.${host}/${port}") > /dev/null 2>&1 && echo "Host ${subnet}.${host} has ${port} open" || echo "Host ${subnet}.${host} has ${port} closed"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment