Skip to content

Instantly share code, notes, and snippets.

@FranklyFuzzy
Last active April 15, 2024 20:50
Show Gist options
  • Save FranklyFuzzy/08ab19d95970561079581e77dbafca44 to your computer and use it in GitHub Desktop.
Save FranklyFuzzy/08ab19d95970561079581e77dbafca44 to your computer and use it in GitHub Desktop.
Extract uniq IPs from file and perform whois look up
#!/bin/bash
# Check if an input file is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <input_file>"
exit 1
fi
input_file="$1"
# Extract unique IP addresses from the file
unique_ips=$(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" "$input_file" | sort -u)
# Perform nslookup for each IP
for ip in $unique_ips; do
#echo "IP: $ip"
whois -h whois.cymru.com " -v $ip"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment