POC is working
This commit is contained in:
parent
ca0cad0d5d
commit
aef1004a9d
|
@ -185,8 +185,14 @@ func (f *fingerprint) setString(str string) {
|
|||
f.CheckingDisabled = s == strings.ToUpper("cd")
|
||||
case 12:
|
||||
f.Zero = s == strings.ToUpper("z")
|
||||
case 13, 14, 15, 16:
|
||||
// Can not set lenght of the section in the message
|
||||
case 13:
|
||||
f.Question = valueOfString(s)
|
||||
case 14:
|
||||
f.Answer = valueOfString(s)
|
||||
case 15:
|
||||
f.Ns = valueOfString(s)
|
||||
case 16:
|
||||
f.Extra = valueOfString(s)
|
||||
case 17:
|
||||
f.Do = s == strings.ToUpper("do")
|
||||
case 18:
|
||||
|
@ -226,7 +232,11 @@ func toFingerprint(m *dns.Msg) *fingerprint {
|
|||
f := new(fingerprint)
|
||||
|
||||
if len(m.Question) > 0 {
|
||||
f.Query.Name = m.Question[0].Name
|
||||
if len(m.Question[0].Name) == 0 {
|
||||
f.Query.Name = "."
|
||||
} else {
|
||||
f.Query.Name = m.Question[0].Name
|
||||
}
|
||||
f.Query.Qtype = m.Question[0].Qtype
|
||||
f.Query.Qclass = m.Question[0].Qclass
|
||||
}
|
||||
|
|
|
@ -19,8 +19,9 @@ func q(w dns.RequestWriter, m *dns.Msg) {
|
|||
|
||||
func main() {
|
||||
port := flag.Int("port", 53, "port number to use")
|
||||
report := flag.Bool("report", false, "show fingerprint for unknown server")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [-port 53] [@server]\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS...] [@server]\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
|
@ -38,24 +39,30 @@ func main() {
|
|||
nameserver = string([]byte(nameserver)[1:]) // chop off @
|
||||
nameserver += ":" + strconv.Itoa(*port)
|
||||
c := dns.NewClient()
|
||||
prints, _ := fingerPrintFromFile("data/q")
|
||||
results := make([]*fingerprint, 0)
|
||||
prints, _ := fingerPrintFromFile("data/q")
|
||||
results := make([]*fingerprint, 0)
|
||||
for _, f := range prints {
|
||||
f1 := probe(c, nameserver, f)
|
||||
results = append(results, f1)
|
||||
println(f.String(), f1.String())
|
||||
results = append(results, f1)
|
||||
if *report {
|
||||
fmt.Printf("%s\n", f1.String())
|
||||
}
|
||||
}
|
||||
if *report {
|
||||
return
|
||||
}
|
||||
|
||||
bind9, _ := fingerPrintFromFile("data/Bind9")
|
||||
nsd3, _ := fingerPrintFromFile("data/Nsd3")
|
||||
|
||||
for i, f := range bind9 {
|
||||
d := f.compare(results[i])
|
||||
println(d)
|
||||
}
|
||||
|
||||
for i, f := range nsd3 {
|
||||
d := f.compare(results[i])
|
||||
println(d)
|
||||
}
|
||||
// For now, just list them:
|
||||
files := []string{"data/Bind9", "data/Nsd3"}
|
||||
fmt.Printf("%s\t%s\t%s\t\t\t\t\t\t\t\t%s\n", "Server type", "Diffs", "Received", "Sent")
|
||||
for _, file := range files {
|
||||
diff := 0
|
||||
prints, _ := fingerPrintFromFile(file)
|
||||
for i, f := range prints {
|
||||
d := f.compare(results[i])
|
||||
diff += d
|
||||
fmt.Printf("%s\t%d\t%s t%s\n", file, d, f.String(), results[i].String())
|
||||
}
|
||||
fmt.Printf("\t\t==\nDifferences:\t%d\n\n", diff)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue