Created
July 4, 2017 12:17
-
-
Save T31337/d1456bd549fa42471078010f49b8d80f to your computer and use it in GitHub Desktop.
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 | |
#IP Information Gathering Script | |
ipList="ipList.txt" #IP ADDRESS LIST | |
ipData="IP_INFO.txt" #IP INFORMATION FILE | |
ip="" | |
function getIP_Data | |
{ | |
if [[ -z $ip ]]; then | |
read -p "IP ADDRESS: " ip | |
fi | |
ipinfo=$(curl ipinfo.io/$ip) | |
if [[ -f $ipData ]]; then | |
#File Exists, Lets Append A Blank Line | |
echo -e "\n" >> $ipData | |
fi | |
#Write Ip Info To File | |
echo $ipinfo >> $ipData | |
cat $ipData | |
} | |
if [[ $# -eq 1 ]]; then | |
ip="$1" | |
getIP_Data | |
exit 1 | |
fi | |
while : | |
do | |
########Main######### | |
printf "Choose from the following operations:\n" | |
printf "[1] ipInfo\n" | |
printf "[2] Mass ipInfo (iplist.txt)\n" | |
read -p "Your choice: " op | |
case $op in | |
1) | |
getIP_Data | |
break | |
;; | |
2) | |
while [ ! -f $ipList ]; do | |
read -p "Enter List File: " ipList | |
if [[ -f $ipList ]]; then | |
break | |
fi | |
done | |
while read line; do | |
ipinfo=$(curl ipinfo.io/"$line") | |
echo -e "$ipinfo\n" >> $ipData | |
done < "$ipList" | |
cat $ipData | |
break | |
;; | |
*) | |
echo "Invalid Input, Please Try Again.!" | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment