Skip to content

Instantly share code, notes, and snippets.

@illuzian
Last active September 14, 2020 00:04
Show Gist options
  • Save illuzian/ebc32f154d96476cf623a6bf0c301211 to your computer and use it in GitHub Desktop.
Save illuzian/ebc32f154d96476cf623a6bf0c301211 to your computer and use it in GitHub Desktop.
One liner to perform multiple whois or whois and ptr/reverse lookups against multiple targets froma file.
# One liner. The input file should contain one entry per line.
# `grep -i -E '(OrgName|Country)'` can be removed to show all of the whois output or modified to select preferred items.
cat lookupips.txt | while read ip; do echo $ip; whois -H $ip | grep -i -E '(OrgName|Country)'; done
# Same but includes a ptr lookup - change 1.1.1.1 to whichever server you want to use or remove to use your local server.
cat lookupips.txt | while read ip; do echo $ip; nslookup $ip 1.1.1.1 | grep -o -E 'name = .*$'; whois -H $ip | grep -i -E '(OrgName|Country)'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment