-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqname.py
More file actions
33 lines (28 loc) · 836 Bytes
/
qname.py
File metadata and controls
33 lines (28 loc) · 836 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
import common
## called once before .each()
def init(results):
print "% qname.py"
print "@attribute qname_rt numeric %% reply time"
print "@attribute qname_size numeric %% size of the reply"
print "@attribute qname_ok numeric %% 1 if letter case ok"
print "@attribute qname_rdata string %% rdata of first reply"
## 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)
if str(rr.a.rname): # == "FaCeBoOk.cOm.":
ok = 1
else:
ok = 0
return "%.1f,%d,%d,%s" % (
res['rt'],
res['size'],
str(rr.a.rname) == "FaCeBoOk.cOm.",
common.safe(rr.a.rdata)
)
#def fail(): return "-1,-1,-1,?"