-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathiptracker.sh
212 lines (187 loc) · 9.63 KB
/
iptracker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
banner() {
clear
printf "\e[0m\n"
function print_centered {
[[ $# == 0 ]] && return 1
declare -i TERM_COLS="$(tput cols)"
declare -i str_len="${#1}"
[[ $str_len -ge $TERM_COLS ]] && {
echo "$1";
return 0;
}
declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
[[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
filler=""
for (( i = 0; i < filler_len; i++ )); do
filler="${filler}${ch}"
done
printf "%s%s%s" "$filler" "$1" "$filler"
[[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
printf "\n"
return 0
}
#printf "\e[1;33m _______ _ \e[0m\e[1;32m _____ \e[0m\n"
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
printf "${RED}"
printf "${GREEN}"
print_centered "IP Tracker v1.1"
##echo -e "\e[1;31m ---IP Tracker--- \e[0m"
printf "${BLUE}"
print_centered "Coded by WhiteDevil"
printf "${RED}"
##printf "${GREEN} - Coded ${RED}by ${BLUE}WhiteDevil -${RED} \n"
print_centered "Disclaimer:"
print_centered "This is only meant for educational purpose."
print_centered "Do not Use This To Harm Others."
print_centered "I Am Not Responsible For The Misuse Of The Script."
}
menu() {
printf "\e[0m\n"
printf "\e[0m\e[1;31m [\e[0m\e[1;37m01\e[0m\e[1;31m]\e[0m\e[1;33m Find my IP: \e[0m\n"
printf "\e[0m\e[1;31m [\e[0m\e[1;37m02\e[0m\e[1;31m]\e[0m\e[1;33m Track an Ip: \e[0m\n"
printf "\e[0m\e[1;31m [\e[0m\e[1;37m00\e[0m\e[1;31m]\e[0m\e[1;33m Exit: \e[0m\n"
printf "\e[0m\n"
read -p $' \e[1;31m[\e[0m\e[1;37m~\e[0m\e[1;31m]\e[0m\e[1;92m Select An Option \e[0m\e[1;96m: \e[0m\e[1;93m\en' option
if [[ $option == 1 || $option == 01 ]]; then
myipaddr
elif [[ $option == 2 || $option == 02 ]]; then
useripaddr
elif [[ $option == 0 || $option == 00 ]]; then
sleep 1
printf "\e[0m\n"
printf "\e[0m\n"
exit 1
else
printf " \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\e[1;93m You have selected an Invalid option \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\n"
sleep 1
banner
menu
fi
}
myipaddr() {
myipaddripapico=$(curl -s "https://ipapi.co//json" -L)
myipaddripapicom=$(curl -s "http://ip-api.com/json/" -L)
myip=$(echo $myipaddripapico | grep -Po '(?<="ip":)[^,]*' | tr -d '[]"')
mycity=$(echo $myipaddripapico | grep -Po '(?<="city":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
myregion=$(echo $myipaddripapico | grep -Po '(?<="region":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mycountry=$(echo $myipaddripapico | grep -Po '(?<="country_name":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mylat=$(echo $myipaddripapicom | grep -Po '(?<="lat":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mylon=$(echo $myipaddripapicom | grep -Po '(?<="lon":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mytime=$(echo $myipaddripapicom | grep -Po '(?<="timezone":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mypostal=$(echo $myipaddripapicom | grep -Po '(?<="zip":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
myisp=$(echo $myipaddripapico | grep -Po '(?<="org":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
myasn=$(echo $myipaddripapico | grep -Po '(?<="asn":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mycountrycode=$(echo $myipaddripapico | grep -Po '(?<="country_code":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mycurrency=$(echo $myipaddripapico | grep -Po '(?<="currency":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mylanguage=$(echo $myipaddripapico | grep -Po '(?<="languages":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
mycalling=$(echo $myipaddripapico | grep -Po '(?<="country_calling_code":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
banner
printf "\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Ip Address \e[0m\e[1;96m:\e[0m\e[1;92m $myip\e[0m\n"
printf " \e[0m\e[1;93m City \e[0m\e[1;96m:\e[0m\e[1;92m $mycity\e[0m\n"
printf " \e[0m\e[1;93m Region \e[0m\e[1;96m:\e[0m\e[1;92m $myregion\e[0m\n"
printf " \e[0m\e[1;93m Country \e[0m\e[1;96m:\e[0m\e[1;92m $mycountry\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Latitude \e[0m\e[1;96m:\e[0m\e[1;92m $mylat\e[0m\n"
printf " \e[0m\e[1;93m Longitude \e[0m\e[1;96m:\e[0m\e[1;92m $mylon\e[0m\n"
printf " \e[0m\e[1;93m Time Zone \e[0m\e[1;96m:\e[0m\e[1;92m $mytime\e[0m\n"
printf " \e[0m\e[1;93m Postal Code \e[0m\e[1;96m:\e[0m\e[1;92m $mypostal\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m ISP \e[0m\e[1;96m:\e[0m\e[1;92m $myisp\e[0m\n"
printf " \e[0m\e[1;93m ASN \e[0m\e[1;96m:\e[0m\e[1;92m $myasn\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Country Code \e[0m\e[1;96m:\e[0m\e[1;92m $mycountrycode\e[0m\n"
printf " \e[0m\e[1;93m Currency \e[0m\e[1;96m:\e[0m\e[1;92m $mycurrency\e[0m\n"
printf " \e[0m\e[1;93m Languages \e[0m\e[1;96m:\e[0m\e[1;92m $mylanguage\e[0m\n"
printf " \e[0m\e[1;93m Calling Code \e[0m\e[1;96m:\e[0m\e[1;92m $mycalling\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m GOOGLE Maps \e[0m\e[1;96m:\e[0m\e[1;94m https://maps.google.com/?q=$mylat,$mylon\e[0m\n"
sleep 5
printf "\e[0m\n"
printf " \e[0m\e[1;91m[\e[0m\e[1;97m01\e[0m\e[1;91m]\e[0m\e[1;93m Return To Main Menu\e[0m\n"
printf " \e[0m\e[1;91m[\e[0m\e[1;97m02\e[0m\e[1;91m]\e[0m\e[1;93m Exit\e[0m\n"
printf "\e[0m\n"
read -p $' \e[1;31m>>\e[0m\e[1;96m \en' mainorexit1
if [[ $mainorexit1 == 1 || $mainorexit1 == 01 ]]; then
banner
menu
elif [[ $mainorexit1 == 2 || $mainorexit1 == 02 ]]; then
printf "\e[0m\n"
printf "\e[0m\n"
exit 1
else
printf " \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\e[1;93m Invalid option \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\n"
sleep 1
banner
menu
fi
}
useripaddr() {
banner
printf "\e[0m\n"
printf "\e[0m\n"
printf "\e[0m\n"
read -p $' \e[1;31m[\e[0m\e[1;37m~\e[0m\e[1;31m]\e[0m\e[1;92m Input IP Address \e[0m\e[1;96m: \e[0m\e[1;93m\en' useripaddress
ipaddripapico=$(curl -s "https://ipapi.co/$useripaddress/json" -L)
ipaddripapicom=$(curl -s "http://ip-api.com/json/$useripaddress" -L)
userip=$(echo $ipaddripapico | grep -Po '(?<="ip":)[^,]*' | tr -d '[]"')
usercity=$(echo $ipaddripapico | grep -Po '(?<="city":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
useregion=$(echo $ipaddripapico | grep -Po '(?<="region":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
usercountry=$(echo $ipaddripapico | grep -Po '(?<="country_name":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userlat=$(echo $ipaddripapicom | grep -Po '(?<="lat":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userlon=$(echo $ipaddripapicom | grep -Po '(?<="lon":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
usertime=$(echo $ipaddripapicom | grep -Po '(?<="timezone":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userpostal=$(echo $ipaddripapicom | grep -Po '(?<="zip":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userisp=$(echo $ipaddripapico | grep -Po '(?<="org":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userasn=$(echo $ipaddripapico | grep -Po '(?<="asn":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
usercountrycode=$(echo $ipaddripapico | grep -Po '(?<="country_code":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
usercurrency=$(echo $ipaddripapico | grep -Po '(?<="currency":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
userlanguage=$(echo $ipaddripapico | grep -Po '(?<="languages":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
usercalling=$(echo $ipaddripapico | grep -Po '(?<="country_calling_code":)[^},]*' | tr -d '[]"' | sed 's/\(<[^>]*>\|<\/>\|{1|}\)//g')
banner
printf "\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Ip Address \e[0m\e[1;96m:\e[0m\e[1;92m $userip\e[0m\n"
printf " \e[0m\e[1;93m City \e[0m\e[1;96m:\e[0m\e[1;92m $usercity\e[0m\n"
printf " \e[0m\e[1;93m Region \e[0m\e[1;96m:\e[0m\e[1;92m $useregion\e[0m\n"
printf " \e[0m\e[1;93m Country \e[0m\e[1;96m:\e[0m\e[1;92m $usercountry\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Latitude \e[0m\e[1;96m:\e[0m\e[1;92m $userlat\e[0m\n"
printf " \e[0m\e[1;93m Longitude \e[0m\e[1;96m:\e[0m\e[1;92m $userlon\e[0m\n"
printf " \e[0m\e[1;93m Time Zone \e[0m\e[1;96m:\e[0m\e[1;92m $usertime\e[0m\n"
printf " \e[0m\e[1;93m Postal Code \e[0m\e[1;96m:\e[0m\e[1;92m $userpostal\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m ISP \e[0m\e[1;96m:\e[0m\e[1;92m $userisp\e[0m\n"
printf " \e[0m\e[1;93m ASN \e[0m\e[1;96m:\e[0m\e[1;92m $userasn\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m Country Code \e[0m\e[1;96m:\e[0m\e[1;92m $usercountrycode\e[0m\n"
printf " \e[0m\e[1;93m Currency \e[0m\e[1;96m:\e[0m\e[1;92m $usercurrency\e[0m\n"
printf " \e[0m\e[1;93m Languages \e[0m\e[1;96m:\e[0m\e[1;92m $userlanguage\e[0m\n"
printf " \e[0m\e[1;93m Calling Code \e[0m\e[1;96m:\e[0m\e[1;92m $usercalling\e[0m\n"
printf "\e[0m\n"
printf " \e[0m\e[1;93m GOOGLE Maps \e[0m\e[1;96m:\e[0m\e[1;94m https://maps.google.com/?q=$userlat,$userlon\e[0m\n"
sleep 5
printf "\e[0m\n"
printf " \e[0m\e[1;91m[\e[0m\e[1;97m01\e[0m\e[1;91m]\e[0m\e[1;93m Return To Main Menu\e[0m\n"
printf " \e[0m\e[1;91m[\e[0m\e[1;97m02\e[0m\e[1;91m]\e[0m\e[1;93m Exit\e[0m\n"
printf "\e[0m\n"
read -p $' \e[1;31m>>\e[0m\e[1;96m \en' mainorexit2
if [[ $mainorexit2 == 1 || $mainorexit2 == 01 ]]; then
banner
menu
elif [[ $mainorexit2 == 2 || $mainorexit2 == 02 ]]; then
printf "\e[0m\n"
printf "\e[0m\n"
exit 1
else
printf " \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\e[1;93m Invalid option \e[1;91m[\e[0m\e[1;97m!\e[0m\e[1;91m]\e[0m\n"
sleep 1
banner
menu
fi
}
banner
menu