python ip反查询_利用ip反查指定域名

1.[利用ip反查指定域名代码][Python]代码

#!/usr/bin/python2.7

# -*- coding:utf-8 -*-

import urllib,urllib2

import re

import subprocess

import sys

output=''

def html(html):

#print str

response=urllib2.urlopen(html)

return str(response.readlines())

def getpage(html):

pattern=re.compile("\.\.\.\s(\d+)",re.S)

#print html

p=pattern.findall(html)

#print '页数为:'+p[0]

if len(p)==0:

print '无查询结果'

exit()

else:

return int(p[0])

def getAllDomain(html):

#print html

pattern1=re.compile("t

domain=pattern1.findall(html)

result=[]

i=0

#print domain

for pp in domain:

result.append(pp)

i+=1

return result

def nslookup(domain):

ns=subprocess.Popen('nslookup '+domain,shell=True,stdout=subprocess.PIPE)

ns_result=ns.stdout.read()

#print ns_result

#如果nslookup输出不一样需要修改正则,正则不会写,很多疏漏,简单写下能实现就行

re_domain=re.compile("Name:\t([\s\S\w\W]*?)\nAddress:([\s\S\w\W]*?)\n", re.S)

return re_domain.findall(ns_result)

def nslookupThread(allDomain):

for d in allDomain:

r=nslookup(d)

#跳过未查询到的

if len(r)==0:

continue

for i in range(len(r)):

x=r[i][0].strip()

y=r[i][1].strip()

#print '%s:%s' % (x,y)

#提取解析到此ip的域名

if cmp(y,ip)==0:

print x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值