Dropbox Hosts文件IP地址获取脚本

因为众所周知的原因,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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 名词延伸 通俗的说,域名就相当于一个家庭的门牌号码,别人通过这个号码可以很容易的找到你。如果把IP地址比作一间房子...
    杨大虾阅读 20,623评论 2 56
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,860评论 18 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,005评论 25 708
  • 第二章 探索扫描(一) 作者:Justin Hutchens 译者:飞龙 协议:CC BY-NC-SA 4.0 2...
    布客飞龙阅读 2,084评论 0 7
  • 天渐渐变冷,11月份每早到操场跑步,还能坚持。现在,我却实在做不到了。但如果不锻炼,又感觉生活少了些什么。同学说学...
    rainbowYXZ阅读 269评论 0 2