Skip to content
Snippets Groups Projects
Commit a6e2c2f3 authored by Pierre LALET's avatar Pierre LALET
Browse files

Prevent sr() tests crashes

parent 037c992d
No related branches found
No related tags found
No related merge requests found
......@@ -85,18 +85,27 @@ _ == (True, True)
#= Discovery packet tests in local
#~ netaccess HomePlugAV NetworkInfoConfirmationV10 NetworkInfoConfirmationV11
#pkt = Ether()/HomePlugAV()
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#a
#pkt.version = a.version
#pkt /= NetworkInformationRequest()
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#NetworkInfoConfirmationV10 in a or NetworkInfoConfirmationV11 in a
#_ == True
#= Reading local 0x400st octets of Software Image in Module Data blocks
#~ netaccess HomePlugAV ReadModuleDataRequest
#pkt = Ether()/HomePlugAV()/ReadModuleDataRequest(ModuleID=0x1)
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#a
#len(a.ModuleData) == pkt.Length
#_ == True
......
......@@ -48,7 +48,10 @@ str(tlv) == b'\x00\x05\x00\x04\x00\x11"3'
#= EDNS-PING - Live test
#~ netaccess
#* NB: 85.17.219.217 and www.edns-ping.org seem down
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#r = sr1(IP(dst="85.17.219.217")/UDP()/DNS(qd=[DNSQR(qtype="A", qname="www.edns-ping.org.")], ar=[DNSRROPT(z=0, rdata=[EDNS0TLV(optcode="PING", optdata=b"\x00\x11\x22\x33")])]), timeout=1)
#conf.debug_dissector = old_debug_dissector
#len(r.ar) and r.ar.rdata[0].optcode == 4 # XXX: should be 5
+ Test DNS Name Server Identifier (NSID) Option
......@@ -59,5 +62,8 @@ str(tlv) == b'\x00\x02\x00\x00'
= NSID - Live test
~ netaccess
old_debug_dissector = conf.debug_dissector
conf.debug_dissector = False
r = sr1(IP(dst="l.root-servers.net")/UDP()/DNS(qd=[DNSQR(qtype="SOA", qname=".")], ar=[DNSRROPT(z=0, rdata=[EDNS0TLV(optcode="NSID")])]), timeout=1)
conf.debug_dissector = old_debug_dissector
len(r.ar) and DNSRROPT in r.ar and len(r.ar[DNSRROPT].rdata) and len([x for x in r.ar[DNSRROPT].rdata if x.optcode == 3])
......@@ -491,7 +491,10 @@ assert(x.PDU.varbindlist[2].value == 1)
= Sending and receiving an ICMP
~ netaccess IP ICMP
x=sr1(IP(dst="www.google.com")/ICMP(),timeout=3)
old_debug_dissector = conf.debug_dissector
conf.debug_dissector = False
x = sr1(IP(dst="www.google.com")/ICMP(),timeout=3)
conf.debug_dissector = old_debug_dissector
x
assert x[IP].ottl() in [32, 64, 128, 255]
assert 0 <= x[IP].hops() <= 126
......@@ -501,7 +504,10 @@ x is not None and ICMP in x and x[ICMP].type == 0
~ netaccess IP UDP DNS
* A possible cause of failure could be that the open DNS (resolver1.opendns.com)
* is not reachable or down.
old_debug_dissector = conf.debug_dissector
conf.debug_dissector = False
dns_ans = sr1(IP(dst="resolver1.opendns.com")/UDP()/DNS(rd=1,qd=DNSQR(qname="www.slashdot.com")),timeout=5)
conf.debug_dissector = old_debug_dissector
DNS in dns_ans
= Whois request
......@@ -579,7 +585,10 @@ len(_) == 12
= Port scan
~ netaccess IP TCP
old_debug_dissector = conf.debug_dissector
conf.debug_dissector = False
ans,unans=sr(IP(dst="www.google.com/30")/TCP(dport=[80,443]),timeout=2)
conf.debug_dissector = old_debug_dissector
ans.make_table(lambda (s,r): (s.dst, s.dport, r.sprintf("{TCP:%TCP.flags%}{ICMP:%ICMP.code%}")))
= Traceroute function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment