Skip to content

Instantly share code, notes, and snippets.

@rightson
Last active February 17, 2024 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightson/16b02d8855aa2308a22f6d7621c67aec to your computer and use it in GitHub Desktop.
Save rightson/16b02d8855aa2308a22f6d7621c67aec to your computer and use it in GitHub Desktop.
Scanning IPv4 addresses in use
if [ "$#" -eq 0 ]; then
targets="70 71 79 91 92 93 94"
else
targets=$*
fi
echo -e "Targets to scan:\n $targets"
in_use=()
for suffix in $targets; do
ip=140.113.216.$suffix
echo -e "\n> nmap -sn $ip -oG -"
nmap -sn $ip -oG - | grep "Up"
if [ $? -eq 0 ]; then
echo "$ip is in use (nmap)"
in_use+=(\\n$ip)
fi
done
echo "------"
echo -e "IPs in use: ${in_use[*]}"#!/bin/bash
@rightson
Copy link
Author

rightson commented Feb 17, 2024

Usages:

bash scan-ipv4.sh
bash scan-ipv4.sh `seq 65 94`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment