-
Notifications
You must be signed in to change notification settings - Fork 3
/
cdnfinder.py
executable file
·65 lines (61 loc) · 1.87 KB
/
cdnfinder.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
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
import dns
import dns.message
import dns.query
CDN_PROVIDER = [
[".akamai.net", "Akamai"],
[".akamaiedge.net", "Akamai"],
[".llnwd.net", "Limelight"],
["edgecastcdn.net", "EdgeCast"],
["hwcdn.net", "Highwinds"],
[".panthercdn.com", "Panther"],
[".simplecdn.net", "Simple CDN"],
[".instacontent.net", "Mirror Image"],
[".footprint.net", "Level3"],
[".ay1.b.yahoo.com", "Yahoo"],
[".yimg.", "Yahoo"],
[".google.", "Google"],
["googlesyndication.", "Google"],
["youtube.", "Google"],
[".googleusercontent.com", "Google"],
[".internapcdn.net", "Internap"],
[".cloudfront.net", "Amazon Cloudfront"],
[".netdna-cdn.com", "MaxCDN"],
[".netdna-ssl.com", "MaxCDN"],
[".netdna.com", "MaxCDN"],
[".cotcdn.net", "Cotendo"],
[".cachefly.net", "Cachefly"],
["bo.lt", "BO.LT"],
[".cloudflare.com", "Cloudflare"],
[".afxcdn.net", "afxcdn.net"],
[".lxdns.com", "lxdns.com"],
[".att-dsa.net", "AT&T"],
[".vo.msecnd.net", "Windows Azure"],
[".voxcdn.net", "Voxel"],
[".bluehatnetwork.com", "Blue Hat Network"],
[".swiftcdn1.com", "SwiftCDN"],
[".rncdn1.com", "Reflected Networks"],
[".cdngc.net", "CDNetworks"],
[".fastly.net", "Fastly"],
[".gslb.taobao.com", "Taobao"],
[".gslb.tbcache.com", "Alimama"]
]
def finder(host):
result = None
for cdn in CDN_PROVIDER:
if cdn[0] in host:
return cdn[1]
return None
def findcdnfromhost(host, dnsip = "8.8.8.8"):
newhost = host
try:
q = dns.message.make_query(host, "A")
r = dns.query.udp(q, dnsip)
for ans in r.answer:
if "CNAME" in ans.to_text():
newhost = ans.to_text().split("CNAME ")[1][:-1]
except:
return finder(newhost)
return finder(newhost)
if __name__ == "__main__":
import sys
print findcdnfromhost(sys.argv[-1])