本文整理汇总了Python中dnslib.DNSRecord.send方法的典型用法代码示例。如果您正苦于以下问题:Python DNSRecord.send方法的具体用法?Python DNSRecord.send怎么用?Python DNSRecord.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnslib.DNSRecord
的用法示例。
在下文中一共展示了DNSRecord.send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_dns_packet
# 需要导入模块: from dnslib import DNSRecord [as 别名]
# 或者: from dnslib.DNSRecord import send [as 别名]
def handle_dns_packet(self, query: DNSRecord, answer: DNSRecord):
if query.q.qname.matchSuffix(self.suffix):
try:
local_a = DNSRecord.parse(query.send(self.address, port=self.port))
for rr in local_a.rr:
answer.add_answer(rr)
return True
except:
pass
finally:
return True
示例2: query_over_tcp
# 需要导入模块: from dnslib import DNSRecord [as 别名]
# 或者: from dnslib.DNSRecord import send [as 别名]
def query_over_tcp(self, domain, type=None):
if type is None:
types = [1, 28]
else:
types = [type]
ips = []
for t in types:
query_time = 0
for server_ip in self.dns_server.public_list:
query_time += 1
if query_time > 3:
break
try:
d = DNSRecord(DNSHeader())
d.add_question(DNSQuestion(domain, t))
a_pkt = d.send(server_ip, 53, tcp=True, timeout=1)
p = DNSRecord.parse(a_pkt)
if len(p.rr) == 0:
xlog.warn("query_over_tcp for %s type:%d server:%s return none",
domain, t, server_ip)
continue
for r in p.rr:
ip = str(r.rdata)
if "." in ip and g.ip_region.check_ip(ip):
cn = g.ip_region.cn
else:
cn = "XX"
ips.append(ip+"|"+cn)
break
except Exception as e:
xlog.warn("query_over_tcp %s type:%s server:%s except:%r", domain, type, server_ip,e)
if ips:
g.domain_cache.set_ips(domain, ips, type)
return ips
示例3: p
# 需要导入模块: from dnslib import DNSRecord [as 别名]
# 或者: from dnslib.DNSRecord import send [as 别名]
def p(*s):
if args.debug:
print(*s)
uncaught = 0
exceptions = []
address,_,port = args.server.partition(':')
port = int(port or 53)
if args.query == 'google.com' and args.type == 'A':
packet = bytearray(binascii.unhexlify(b'55838180000100100000000006676f6f676c6503636f6d0000010001c00c000100010000012b00043efca994c00c000100010000012b00043efca998c00c000100010000012b00043efca9b7c00c000100010000012b00043efca99dc00c000100010000012b00043efca9acc00c000100010000012b00043efca9bbc00c000100010000012b00043efca9a3c00c000100010000012b00043efca9a8c00c000100010000012b00043efca9b1c00c000100010000012b00043efca9a7c00c000100010000012b00043efca999c00c000100010000012b00043efca9a2c00c000100010000012b00043efca9b6c00c000100010000012b00043efca9b2c00c000100010000012b00043efca9adc00c000100010000012b00043efca99e'))
else:
question = DNSRecord(q=DNSQuestion(args.query,getattr(QTYPE,args.type)))
packet = bytearray(question.send(address,port,tcp=args.tcp))
original = DNSRecord.parse(packet)
p("Original:")
p(original.toZone(prefix=" | "))
for f in (fuzz_delete,fuzz_add,fuzz_change):
for i in range(args.number):
try:
fuzzed_pkt = f(packet)
fuzzed = DNSRecord.parse(fuzzed_pkt)
if original != fuzzed:
diff = original.diff(fuzzed)
p("[%s:parsed ok] >>> %d Diff Errors" % (fname(f),len(diff)))
p(pprint.pformat(diff))