-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain2ip.py
36 lines (31 loc) · 876 Bytes
/
domain2ip.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
34
35
36
import socket
import sys
iname = "domains.txt"
oname = "ips.txt"
if (len(sys.argv) > 1):
iname = sys.argv[1]
if (len(sys.argv) > 2):
oname = sys.argv[2]
f = open(iname, "r")
gg = open(oname, "w")
for tracker in f:
if (len(tracker.strip()) > 5):
protocol = tracker[:6]
domain = ""
port = ""
full = ""
if (protocol == "udp://"):
pos = tracker.find('/', 6)
if (pos != -1):
full = tracker[6:pos]
else:
full = tracker[6:]
dpos = full.find(':')
domain = full[:dpos]
port = full[dpos+1:]
try:
ln = socket.gethostbyname(domain) + ":" + port
gg.write(ln)
gg.write('\n')
except:
print "Kaand ", domain