dns.resolve结果列表

时间:2015-08-25 12:59:50

标签: python python-2.7 dns dnspython

我创建了一个简单的dns.query函数,我试图将结果添加到列表或潜在的字典中。但是我无法弄清楚如何实现它,我已经尝试过list.append(子域,项目),我尝试过使用join函数,我试图使用更新函数。

任何指针都会受到赞赏。

ORIGINAL

def get_brutes(subdomain):
    targets = []
    try:
        myResolver = dns.resolver.Resolver()
        myResolver.nameservers = ['8.8.8.8']
        myAnswers = myResolver.query(subdomain)
        for item in myAnswers.rrset:
            targets.append(subdomain,item)  

    except Exception as e:
        pass
    return targets

FIX

def get_brutes(subdomain):
    targets = []
    try:
        myResolver = dns.resolver.Resolver()
        myResolver.nameservers = ['8.8.8.8']
        myAnswers = myResolver.query(subdomain)
        for item in myAnswers.rrset:
            targets.append(subdomain + ' ' + str(item))

    except Exception as e:
        pass
    return targets

0 个答案:

没有答案