-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_ip.py
33 lines (30 loc) · 1.01 KB
/
find_ip.py
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
from sys import argv
from socket import gethostbyname, gaierror, getnameinfo, gethostbyaddr
from os import system
from termcolor import colored
from re import search
def get_ips(name):
ip_list = []
ips = ""
for i in range(0, 10):
ip_list.append(colored(gethostbyname(name), "green"))
ip_list = list(set(ip_list))
for ip in ip_list:
ips += ip + ", "
return ips[:-2]
argv.pop(0)
n = len(argv)
system("cls||clear")
for domain_name in argv:
domain_name = domain_name.replace("https://", "")
domain_name = domain_name.replace("http://", "")
try:
search('[a-zA-Z]', domain_name).group(0)
print(domain_name, " --> ", get_ips(domain_name))
except gaierror:
print(domain_name, " --> ", colored("Invalid host", "red"))
except AttributeError:
try:
print(domain_name, " --> ", colored(getnameinfo((domain_name, 0), 0)[0], "green"))
except AttributeError:
print(domain_name, " --> ", colored("Invalid ip", "red"))