Last active
April 15, 2024 20:50
-
-
Save FranklyFuzzy/08ab19d95970561079581e77dbafca44 to your computer and use it in GitHub Desktop.
Extract uniq IPs from file and perform whois look up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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