Created
July 11, 2012 10:18
-
-
Save miekg/3089460 to your computer and use it in GitHub Desktop.
Create trace from zonefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/miekg/dns" | |
"flag" | |
"github.com/miekg/pcap" | |
"os" | |
) | |
func main() { | |
// -o origin <file>, -t4 targetIP, -s4 srcip, -t6, -s6 | |
m := new(dns.Msg) | |
for x := range dns.ParseZone(os.Stdin, "", "") { | |
if x.Error != nil { | |
println(x.Error.Error()) | |
continue | |
} | |
if x.Error == nil { | |
switch t := x.RR.Header().Rrtype; t { | |
case dns.TypeRRSIG: | |
fallthrough | |
case dns.TypeNSEC: | |
fallthrough | |
case dns.TypeNSEC3: | |
continue | |
default: | |
if x.RR.Header().Name[0] == '*' { // Wildcard name | |
m.SetQuestion("wild" + x.RR.Header().Name[1:], t) | |
} else { | |
m.SetQuestion(x.RR.Header().Name, t) | |
} | |
if _, ok := m.Pack(); ok { | |
p := new(pcap.Packet) | |
p = p | |
println(m.String()) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment