-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdnskey.py
More file actions
33 lines (30 loc) · 1017 Bytes
/
dnskey.py
File metadata and controls
33 lines (30 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import base64
import dnslib # sudo pip install dnslib
## called once before .each()
def init(results):
print "% dnskey.py"
print "@attribute dnskey_rt numeric %% response time"
print "@attribute dnskey_size numeric %% response size"
print "@attribute dnskey_flags numeric %% header bit flags (decimal)"
print "@attribute dnskey_rcode numeric %% response code"
print "@attribute dnskey_qcount numeric %% query count"
print "@attribute dnskey_acount numeric %% answer count"
print "@attribute dnskey_nscount numeric %% authority count"
print "@attribute dnskey_arcount numeric %% additional count"
## called for each element in result JSON
# pid: probe id
# el: element of the result array
# res: el[result] (just a shortcut)
def each(pid, el, res):
abuf = base64.b64decode(res['abuf'])
rr = dnslib.DNSRecord.parse(abuf)
return "%.1f,%d,%d,%d,%d,%d,%d,%d" % (
res['rt'],
res['size'],
rr.header.bitmap,
rr.header.rcode,
rr.header.q,
rr.header.a,
rr.header.auth,
rr.header.ar
)