干货生产力工具

Dropbox Hosts文件IP地址获取脚本

2014-06-22  本文已影响3514人  doc001

因为众所周知的原因,Dropbox不能用了。不开心。幸好Yannis Xu提供了一种方法,可用于获取Dropbox所需要的一些域名的真实IP地址(点我)。原作者没有提供完整的脚本,在这里将其补充完整。

#!/usr/bin/python
# -*- coding: utf-8 -*-  

def GetLists(subdomain,start,end):
    ret = []
    for i in xrange(int(start),int(end)+1):
        ret.append(subdomain+str(i)+'.dropbox.com')
    return ret

def GetDlClientLists():
    return GetLists('dl-client',1,999)

def GetDlDebugLists():
    return GetLists('dl-debug',1,40)

def GetClientLists():
    return GetLists('client',1,99)

def GetNotifyLists():
    return GetLists('notify',1,10)

hosts = []
hosts.extend([
        'dropbox.com',
        'www.dropbox.com',
        'forums.dropbox.com',
        'dl.dropboxusercontent.com',
        'd.dropbox.com',
        'client-lb.dropbox.com'
        ])
hosts.extend(GetDlClientLists())
hosts.extend(GetDlDebugLists())
hosts.extend(GetClientLists())
hosts.extend(GetNotifyLists())

import subprocess
for h in hosts:
    cmd = 'nslookup -vc ' + h + ' 8.8.8.8'
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

    valid = False
    for line in p.stdout.readlines():
        if line.startswith('Non-authoritative answer:'):
            valid = True
        elif valid and line.startswith('Address:'):
            ip = line.replace('Address: ','').replace('\n','')
            print ip + ' ' + h
上一篇下一篇

猜你喜欢

热点阅读