diff --git a/.appveyor.yml b/.appveyor.yml index 5c698a56f16a0b2bb905b7dd7cdc7fbebfd61526..3a744d8528cfbd3e6b1fda65d0ade1e18539b1fe 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -25,7 +25,7 @@ test_script: - set PATH="%APPVEYOR_BUILD_FOLDER%;C:\Program Files\Wireshark\;%PATH%" # Main unit tests - - "%PYTHON%\\python -m coverage run --parallel-mode bin\\UTscapy -f text -t test\\regression.uts -F -K mock_read_routes6_bsd || exit /b 42" + - "%PYTHON%\\python -m coverage run --parallel-mode bin\\UTscapy -f text -t test\\regression.uts -F -K mock_read_routes6_bsd -K ipv6 || exit /b 42" - 'del test\regression.uts' # Secondary and contrib unit tests diff --git a/.travis/test.sh b/.travis/test.sh index cb7a55f448dd73b35ceac490db30c30037a499b1..40d67ac1382120839438e4a6189646079734daa6 100644 --- a/.travis/test.sh +++ b/.travis/test.sh @@ -62,6 +62,9 @@ then $SCAPY_SUDO ./run_tests -q -F -t bpf.uts $UT_FLAGS || exit $? fi UT_FLAGS+=" -K manufdb -K linux" +else + # IPv6 is not available yet on the linux machines (but is on OSX) + UT_FLAGS+=" -K ipv6" fi # Run all normal and contrib tests diff --git a/scapy/arch/linux.py b/scapy/arch/linux.py index 8d4d7d662cf25cd1bf840bde9b3ecf5ed4e5818c..3b5eb8cfd3348efc9475a7223fb85ec700de26c8 100644 --- a/scapy/arch/linux.py +++ b/scapy/arch/linux.py @@ -335,7 +335,7 @@ def read_routes6(): cset = ['::1'] else: devaddrs = filter(lambda x: x[2] == dev, lifaddr) - cset = scapy.utils6.construct_source_candidate_set(d, dp, devaddrs, LOOPBACK_NAME) + cset = scapy.utils6.construct_source_candidate_set(d, dp, devaddrs) if len(cset) != 0: routes.append((d, dp, nh, dev, cset)) diff --git a/scapy/arch/unix.py b/scapy/arch/unix.py index f73ee70c4a086240c71af732c2a89a77095e1cc6..4a65495c6d9dabc22a7c0c5ab21824b64ce97a45 100644 --- a/scapy/arch/unix.py +++ b/scapy/arch/unix.py @@ -320,7 +320,7 @@ def read_routes6(): else: # Get possible IPv6 source addresses devaddrs = filter(lambda x: x[2] == dev, lifaddr) - cset = construct_source_candidate_set(destination, destination_plen, devaddrs, LOOPBACK_NAME) + cset = construct_source_candidate_set(destination, destination_plen, devaddrs) if len(cset): routes.append((destination, destination_plen, next_hop, dev, cset)) diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py index 89a747d870b762ec028c500a4d161216f9a66fd0..07aff9d7445e76a0e45581b71ecd76775e09906c 100755 --- a/scapy/arch/windows/__init__.py +++ b/scapy/arch/windows/__init__.py @@ -684,7 +684,7 @@ def _append_route6(routes, dpref, dp, nh, iface, lifaddr): cset = ['::1'] else: devaddrs = filter(lambda x: x[2] == iface, lifaddr) - cset = scapy.utils6.construct_source_candidate_set(dpref, dp, devaddrs, scapy.consts.LOOPBACK_INTERFACE) + cset = scapy.utils6.construct_source_candidate_set(dpref, dp, devaddrs) if len(cset) == 0: return # APPEND (DESTINATION, NETMASK, NEXT HOP, IFACE, CANDIDATS) diff --git a/scapy/layers/dhcp6.py b/scapy/layers/dhcp6.py index 7887a8d3c7de41d0b9270b288b45340b232a27ad..2c97471f9edf8d7b2803d505161861357597535c 100644 --- a/scapy/layers/dhcp6.py +++ b/scapy/layers/dhcp6.py @@ -1194,12 +1194,12 @@ class DHCPv6_am(AnsweringMachine): send_function = staticmethod(send) def usage(self): msg = """ -dhcp6d( dns="2001:500::1035", domain="localdomain, local", duid=None) - iface=conf.iface6, advpref=255, sntpservers=None, +DHCPv6_am.parse_options( dns="2001:500::1035", domain="localdomain, local", + duid=None, iface=conf.iface6, advpref=255, sntpservers=None, sipdomains=None, sipservers=None, nisdomain=None, nisservers=None, nispdomain=None, nispservers=None, - bcmcsdomain=None, bcmcsservers=None) + bcmcsdomains=None, bcmcsservers=None) debug : When set, additional debugging information is printed. @@ -1331,7 +1331,7 @@ dhcp6d( dns="2001:500::1035", domain="localdomain, local", duid=None) # Timeval from time import gmtime, strftime, mktime epoch = (2000, 1, 1, 0, 0, 0, 5, 1, 0) - delta = mktime(epoch) - mktime(gmtime(0)) + delta = mktime(epoch) - EPOCH timeval = time.time() - delta # Mac Address diff --git a/scapy/layers/llmnr.py b/scapy/layers/llmnr.py index 65ecad41762020e7c5276ebc13f130c1c23f7897..e406706106d5d67ad5468c014c5a1da3b315d003 100644 --- a/scapy/layers/llmnr.py +++ b/scapy/layers/llmnr.py @@ -50,8 +50,8 @@ class LLMNRResponse(LLMNRQuery): def _llmnr_dispatcher(x, *args, **kargs): cls = conf.raw_layer - if len(x) >= 3: - if (ord(x[4]) & 0x80): # Response + if len(x) >= 2: + if (ord(x[2]) & 0x80): # Response cls = LLMNRResponse else: # Query cls = LLMNRQuery diff --git a/scapy/modules/nmap.py b/scapy/modules/nmap.py index b879af7cb860ad18a95e13d81d82ea769bcf865d..8ab7ab72cf50f090d835ca73ae9b4b78de6e884c 100644 --- a/scapy/modules/nmap.py +++ b/scapy/modules/nmap.py @@ -55,36 +55,32 @@ None. self.filename) except (IOError, TypeError): warning("Cannot open nmap database [%s]" % self.filename) + self.filename = None return self.base = [] name = None sig = {} - try: - for line in fdesc: - line = line.split('#', 1)[0].strip() - if not line: - continue - if line.startswith("Fingerprint "): - if name is not None: - self.base.append((name, sig)) - name = line[12:].strip() - sig = {} - continue - if line.startswith("Class "): - continue - line = _NMAP_LINE.search(line) - if line is None: - continue - test, values = line.groups() - sig[test] = dict(val.split('=', 1) for val in - (values.split('%') if values else [])) - if name is not None: - self.base.append((name, sig)) - except Exception: - self.base = None - warning("Cannot read nmap database [%s](new nmap version ?)" % - self.filename) + for line in fdesc: + line = line.split('#', 1)[0].strip() + if not line: + continue + if line.startswith("Fingerprint "): + if name is not None: + self.base.append((name, sig)) + name = line[12:].strip() + sig = {} + continue + if line.startswith("Class "): + continue + line = _NMAP_LINE.search(line) + if line is None: + continue + test, values = line.groups() + sig[test] = dict(val.split('=', 1) for val in + (values.split('%') if values else [])) + if name is not None: + self.base.append((name, sig)) fdesc.close() @@ -156,15 +152,15 @@ def nmap_sig(target, oport=80, cport=81, ucport=1): for snd, rcv in ans: if snd.sport == 5008: - res["PU"] = nmap_udppacket_sig(snd, rcv) + res["PU"] = (snd, rcv) else: test = "T%i" % (snd.sport - 5000) if rcv is not None and ICMP in rcv: warning("Test %s answered by an ICMP" % test) rcv = None - res[test] = nmap_tcppacket_sig(rcv) + res[test] = rcv - return res + return nmap_probes2sig(res) def nmap_probes2sig(tests): tests = tests.copy() diff --git a/scapy/route6.py b/scapy/route6.py index eef80393579e7d2b86d1ea5b85dfa3d8eabf97a3..3eed0c53370a7545e95503d48105760fe7451171 100644 --- a/scapy/route6.py +++ b/scapy/route6.py @@ -75,7 +75,7 @@ class Route6: # replace that unique address by the list of all addresses lifaddr = in6_getifaddr() devaddrs = filter(lambda x: x[2] == dev, lifaddr) - ifaddr = construct_source_candidate_set(prefix, plen, devaddrs, LOOPBACK_INTERFACE) + ifaddr = construct_source_candidate_set(prefix, plen, devaddrs) return (prefix, plen, gw, dev, ifaddr) diff --git a/scapy/utils6.py b/scapy/utils6.py index ace1db2ea55faf47a2fa55b54f72dab3896b1778..7d1c62e493373d71d9961bcd746a98a5fee87ce5 100644 --- a/scapy/utils6.py +++ b/scapy/utils6.py @@ -22,7 +22,7 @@ from scapy.error import warning from functools import reduce -def construct_source_candidate_set(addr, plen, laddr, loiface): +def construct_source_candidate_set(addr, plen, laddr): """ Given all addresses assigned to a specific interface ('laddr' parameter), this function returns the "candidate set" associated with 'addr/plen'. @@ -58,7 +58,7 @@ def construct_source_candidate_set(addr, plen, laddr, loiface): cset = filter(lambda x: x[1] == IPV6_ADDR_SITELOCAL, laddr) elif in6_ismaddr(addr): if in6_ismnladdr(addr): - cset = [('::1', 16, loiface)] + cset = [('::1', 16, scapy.consts.LOOPBACK_INTERFACE)] elif in6_ismgladdr(addr): cset = filter(lambda x: x[1] == IPV6_ADDR_GLOBAL, laddr) elif in6_ismlladdr(addr): diff --git a/test/bpf.uts b/test/bpf.uts index 79c625c13158dcb383b3c0e64831186dccfe65a8..e78641ff6b6ba241604e514f612a0dc14faa7eec 100644 --- a/test/bpf.uts +++ b/test/bpf.uts @@ -94,6 +94,20 @@ s.set_nonblock(set_flag=True) s.set_nonblock(set_flag=False) s.close() += L2bpfListenSocket - recv as nonblocking +~ needs_root + +s = L2bpfListenSocket() +s.set_nonblock(set_flag=True) + +def test_nonblock_recv(s): + for i in range(1, 100): + a = s.recv() + if not a: + return True + return False + +assert test_nonblock_recv(s) = L2bpfListenSocket - get_*() ~ needs_root diff --git a/test/configs/windows2.utsc b/test/configs/windows2.utsc index 445817e2ce41734bc0ec532871217b83b68fdae7..1cf7a6c54a6d1f63bd525509d307d304f63ce3a1 100644 --- a/test/configs/windows2.utsc +++ b/test/configs/windows2.utsc @@ -10,6 +10,7 @@ "format": "html", "kw_ko": [ "combined_modes_ccm", - "mock_read_routes6_bsd" + "mock_read_routes6_bsd", + "appveyor_only" ] } diff --git a/test/linux.uts b/test/linux.uts index ed251ae432f9beb12462bfd3bfd53e3c326da9c3..23e1802ad14d75736f204ea1d67223bbf86038c1 100644 --- a/test/linux.uts +++ b/test/linux.uts @@ -53,3 +53,13 @@ for i in xrange(10): assert(os.system(IPTABLE_RULE % ('D', SECDEV_IP4)) == 0) assert(success) + += Supersocket _flush_fd +~ needs_root linux + +import select + +from scapy.arch.linux import _flush_fd +socket = conf.L2listen() +select.select([socket],[],[],2) +_flush_fd(socket.ins) diff --git a/test/mock_windows.uts b/test/mock_windows.uts index b7357456a12332fccd9e151e963b29e12c43328c..ffab2ba789e21edb89439e629e889c4ecf975327 100644 --- a/test/mock_windows.uts +++ b/test/mock_windows.uts @@ -67,7 +67,7 @@ ifIndex DestinationPrefix NextHop # Mocked in6_getifaddr() output mock_dev_from_index.side_effect = dev_from_index_custom # Random - mock_utils6cset.side_effect = lambda w,x,y,z: ["::1"] if w=="::" else ["fdbb:d995:ddd8:51fc::"] + mock_utils6cset.side_effect = lambda x,y,z: ["::1"] if x=="::" else ["fdbb:d995:ddd8:51fc::"] # Test the function routes = _read_routes6_post2008() for r in routes: diff --git a/test/nmap.uts b/test/nmap.uts index 7dfcadc4304537b5c7fe4eda21a54b2194f37d11..6e3699ca0964489b381f02411e0819e8f414d63a 100644 --- a/test/nmap.uts +++ b/test/nmap.uts @@ -30,3 +30,35 @@ score, fprint = nmap_fp(conf.route.route('0.0.0.0')[2]) print score, fprint assert score > 0.5 assert fprint + += fingerprint test: to text +~ netaccess + +import re as re_ + +a = nmap_sig("www.secdev.org", 80, 81) +a +for x in nmap_sig2txt(a).split("\n"): + assert re_.match(r"\w{2,4}\(.*\)", x) + += nmap_udppacket_sig test: www.google.com +~ netaccess + +a = nmap_sig("www.google.com", ucport=80) +assert len(a) > 3 +assert len(a["PU"]) > 0 + ++ Nmap errors triggering + += Nmap base not available + +nmap_kdb.filename = "invalid" +nmap_kdb.reload() +assert nmap_kdb.filename == None + += Clear temp files +try: + os.remove('nmap-os-fingerprints') +except: + pass + diff --git a/test/regression.uts b/test/regression.uts index a4bd3bb66b0092149b4c778199026f030cb0a448..1655caf7afc67f34824ac6f75ecca32cc5896e93 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -207,6 +207,8 @@ except OSError: pass = Test temporary file creation +~ appveyor_only + tmpfile = get_temp_file(autoext=".ut") if WINDOWS: assert("scapy" in tmpfile and tmpfile.startswith('C:\\Users\\appveyor\\AppData\\Local\\Temp')) @@ -3464,6 +3466,9 @@ a.optcode == 6 and a.optlen == 0 and a.reqopts == [23,24] a=DHCP6OptOptReq(b'\x00\x06\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04') a.optcode == 6 and a.optlen == 8 and a.reqopts == [1,2,3,4] += DHCP6OptOptReq - repr +a.show() + ############ ############ @@ -3502,6 +3507,9 @@ a.optcode == 8 and a.optlen == 2 and a.elapsedtime == 0 a=DHCP6OptElapsedTime(b'\x00\x08\x00\x02\x01\xa5') a.optcode == 8 and a.optlen == 2 and a.elapsedtime == 421 += DHCP6OptElapsedTime - Repr +a.show() + ############ ############ @@ -4245,6 +4253,11 @@ a.msgtype == 7 and a.trid == 0 a=UDP()/DHCP6_Reply() a.sport == 547 and a.dport == 546 += DHCP6_Reply - Answers + +assert not DHCP6_Reply(trid=0).answers(DHCP6_Request(trid=1)) +assert DHCP6_Reply(trid=1).answers(DHCP6_Request(trid=1)) + ############ ############ @@ -4326,6 +4339,17 @@ a = DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 a.msgtype == 12 and DHCP6OptRelayMsg in a and DHCP6OptClientId in a +############ +############ ++ Test DHCP6 Messages - DHCP6OptRelayMsg + += DHCP6OptRelayMsg - Basic Instantiation +str(DHCP6OptRelayMsg(optcode=37)) == b'\x00%\x00\x00' + += DHCP6OptRelayMsg - Basic Dissection +a=DHCP6OptRelayMsg(b'\x00\r\x00\x00') +assert a.optcode == 13 + ############ ############ + Test DHCP6 Messages - DHCP6_RelayReply @@ -4337,6 +4361,53 @@ str(DHCP6_RelayReply()) == b'\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ a=DHCP6_RelayReply(b'\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') a.msgtype == 13 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::" +############ +############ ++ Test DHCPv6_am + += DHCPv6_am - Basic Instantiaion +~ ipv6 netaccess +a = DHCPv6_am() +a.usage() + +a.parse_options(dns="2001:500::1035", domain="localdomain, local", duid=None, + iface=conf.iface6, advpref=255, sntpservers=None, + sipdomains=None, sipservers=None, + nisdomain=None, nisservers=None, + nispdomain=None, nispservers=None, + bcmcsdomains=None, bcmcsservers=None, + debug=1) + += DHCPv6_am - SOLICIT +~ ipv6 netaccess +req = IPv6(dst="::1")/UDP()/DHCP6(msgtype=1)/DHCP6OptClientId(duid=DUID_LLT()) +assert a.is_request(req) +res = a.make_reply(req) +assert not a.is_request(res) +assert res[DHCP6_Advertise] +assert res[DHCP6OptPref].prefval == 255 +assert res[DHCP6OptReconfAccept] +a.print_reply(req, res) + += DHCPv6_am - INFO-REQUEST +~ ipv6 netaccess +req = IPv6(dst="::1")/UDP()/DHCP6(msgtype=11)/DHCP6OptClientId(duid=DUID_LLT()) +assert a.is_request(req) +res = a.make_reply(req) +assert not a.is_request(res) +assert res[DHCP6_Reply] +assert "local" in res[DHCP6OptDNSDomains].dnsdomains +a.print_reply(req, res) + += DHCPv6_am - REQUEST +~ ipv6 netaccess +req = IPv6(dst="::1")/UDP()/DHCP6(msgtype=3)/DHCP6OptClientId(duid=DUID_LLT())/DHCP6OptServerId(duid=a.duid) +assert a.is_request(req) +res = a.make_reply(req) +assert not a.is_request(res) +assert res[UDP].dport == 546 +assert res[DHCP6_Solicit] +a.print_reply(req, res) ############ ############ @@ -5192,6 +5263,40 @@ wrpcap(filename, [IP()/UDP(), IPv6()/UDP()], linktype=DLT_RAW) packets = rdpcap(filename) assert(isinstance(packets[0], IP) and isinstance(packets[1], IPv6)) +############ +############ ++ LLMNR protocol + += Simple packet dissection +pkt = Ether(b'\x11\x11\x11\x11\x11\x11\x99\x99\x99\x99\x99\x99\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\xc0\xa8\x00w\x7f\x00\x00\x01\x14\xeb\x14\xeb\x00\x14\x95\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +assert pkt.sport == 5355 +assert pkt.dport == 5355 +assert pkt[LLMNRQuery].opcode == 0 + += Packet build / dissection +pkt = UDP(str(UDP()/LLMNRResponse())) +assert LLMNRResponse in pkt +assert pkt.qr == 1 +assert pkt.c == 0 +assert pkt.tc == 0 +assert pkt.z == 0 +assert pkt.rcode == 0 +assert pkt.qdcount == 0 +assert pkt.arcount == 0 +assert pkt.nscount == 0 +assert pkt.ancount == 0 + += Answers - building +a = UDP()/LLMNRResponse() +b = UDP()/LLMNRQuery() +assert a.answers(b) +assert not b.answers(a) + += Answers - dissecting +a = Ether(b'\xd0P\x99V\xdd\xf9\x14\x0cv\x8f\xfe(\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\x7f\x00\x00\x01\xc0\xa8\x00w\x14\xeb\x14\xeb\x00\x14\x95\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +b = Ether(b'\x14\x0cv\x8f\xfe(\xd0P\x99V\xdd\xf9\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\xc0\xa8\x00w\x7f\x00\x00\x01\x14\xeb\x14\xeb\x00\x14\x15\xcf\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00') +assert b.answers(a) +assert not a.answers(b) ############ ############ @@ -5868,6 +5973,20 @@ ff02::%lo0/32 ::1 UC - test_netbsd_7_0() +############ +############ ++ STP tests + += STP - Basic Instantiation +assert str(STP()) == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00\x02\x00\x0f\x00' + += STP - Basic Dissection + +s = STP(b'\x00\x00\x00\x00\x00\x00\x00\x12\x13\x14\x15\x16\x17\x00\x00\x00\x00\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\x00\x00\x01\x00\x14\x00\x05\x00\x0f\x00') +assert s.rootmac == "12:13:14:15:16:17" +assert s.bridgemac == "aa:aa:aa:aa:aa:aa" +assert s.hellotime == 5 + ############ ############ + EAPOL class tests @@ -7788,14 +7907,27 @@ in6_isaddrllallservers("ff02::2") == True = in6_getscope() -in6_getscope("2001:db8::2807") == IPV6_ADDR_GLOBAL -in6_getscope("fec0::2807") == IPV6_ADDR_SITELOCAL -in6_getscope("fe80::2807") == IPV6_ADDR_LINKLOCAL -in6_getscope("ff02::2807") == IPV6_ADDR_LINKLOCAL -in6_getscope("ff0e::2807") == IPV6_ADDR_GLOBAL -in6_getscope("ff05::2807") == IPV6_ADDR_SITELOCAL -in6_getscope("ff01::2807") == IPV6_ADDR_LOOPBACK -in6_getscope("::1") == IPV6_ADDR_LOOPBACK +assert in6_getscope("2001:db8::2807") == IPV6_ADDR_GLOBAL +assert in6_getscope("fec0::2807") == IPV6_ADDR_SITELOCAL +assert in6_getscope("fe80::2807") == IPV6_ADDR_LINKLOCAL +assert in6_getscope("ff02::2807") == IPV6_ADDR_LINKLOCAL +assert in6_getscope("ff0e::2807") == IPV6_ADDR_GLOBAL +assert in6_getscope("ff05::2807") == IPV6_ADDR_SITELOCAL +assert in6_getscope("ff01::2807") == IPV6_ADDR_LOOPBACK +assert in6_getscope("::1") == IPV6_ADDR_LOOPBACK + += construct_source_candidate_set() + +dev_addresses = [('fe80::', IPV6_ADDR_LINKLOCAL, "linklocal"),('fec0::', IPV6_ADDR_SITELOCAL, "sitelocal"),('ff0e::', IPV6_ADDR_GLOBAL, "global")] + +assert construct_source_candidate_set("2001:db8::2807", 0, dev_addresses) == ["ff0e::"] +assert construct_source_candidate_set("fec0::2807", 0, dev_addresses) == ["fec0::"] +assert construct_source_candidate_set("fe80::2807", 0, dev_addresses) == ["fe80::"] +assert construct_source_candidate_set("ff02::2807", 0, dev_addresses) == ["fe80::"] +assert construct_source_candidate_set("ff0e::2807", 0, dev_addresses) == ["ff0e::"] +assert construct_source_candidate_set("ff05::2807", 0, dev_addresses) == ["fec0::"] +assert construct_source_candidate_set("ff01::2807", 0, dev_addresses) == ["::1"] +assert construct_source_candidate_set("::", 0, dev_addresses) == ["ff0e::"] = inet_pton() diff --git a/test/run_tests.bat b/test/run_tests.bat index fce8e76ec211e621da2abb2352058932f50b4e77..f11e866efe31a91643cdbb19f69f76ef196bfab6 100644 --- a/test/run_tests.bat +++ b/test/run_tests.bat @@ -3,8 +3,8 @@ title UTscapy - All tests set MYDIR=%cd%\.. set PYTHONPATH=%MYDIR% if [%1]==[] ( - python "%MYDIR%\scapy\tools\UTscapy.py" -c configs\\windows2.utsc -T bpf.uts -o scapy_regression_test_%date:~6,4%_%date:~3,2%_%date:~0,2%.html + python "%MYDIR%\scapy\tools\UTscapy.py" -c configs\\windows2.utsc -T bpf.uts -T linux.uts -o scapy_regression_test_%date:~6,4%_%date:~3,2%_%date:~0,2%.html ) else ( python "%MYDIR%\scapy\tools\UTscapy.py" %@ ) -PAUSE +PAUSE \ No newline at end of file diff --git a/test/tls.uts b/test/tls.uts index 142534a67800278c9e49f93c8cea58964056d041..0c08772930ed984bc14ad2a2a535b9d510238e47 100644 --- a/test/tls.uts +++ b/test/tls.uts @@ -384,6 +384,13 @@ t1 and t2 and t3 and t4 ### Ciphers ### ############################################################################### ++ Test _CipherSuitesField + +a = _CipherSuitesField("test", None, {}) +assert a.i2repr(None, None) == "None" +assert isinstance(a.randval(), RandBin) +assert hash(a) == 8890308 + + Test RC4 = Crypto - RC4 stream cipher, encryption/decryption checks from RFC 6229 @@ -695,6 +702,9 @@ t2 = TLS(p2_sh, tls_session=t1.tls_session) t3 = TLS(p3_cert, tls_session=t1.tls_session) t4 = TLS(p4_certstat_ske_shd, tls_session=t1.tls_session) += Test TLS with bad data +a = TLS(b'\x00\x03\x03\x00\x03data') +assert a.haslayer(Raw) + Test TLS Record header = Reading test session - TLS Record header @@ -774,6 +784,8 @@ assert(sh.cipher == 0xc02f) assert(len(sh.ext) == 6) sh.ext[-1].protocols[-1].protocol == "http/1.1" += Useless function +assert not TLSHelloRequest().tls_session_update(None) + Test TLS Certificate = Reading test session - Certificate @@ -855,6 +867,10 @@ assert(isinstance(k, ClientECDiffieHellmanPublic)) assert(k.ecdh_Yclen == 65) assert(k.ecdh_Yc[:4] == b'\x04\xd2\x07\xce' and k.ecdh_Yc[-4:] == b'\xdc\x86[\xe7') += Bad data in TLSClientKeyExchange + +a = TLSClientKeyExchange(str(TLSClientKeyExchange(exchkeys="baddata"))) +assert a.haslayer(Raw) + Test TLS ChangeCipherSpec = Reading test session - ChangeCipherSpec diff --git a/test/x509.uts b/test/x509.uts index 1b3efbd0443a109c2a362b3d96a842047453d80c..6822e407a52161f2ad2b0ce83d2a00e7a35505e6 100644 --- a/test/x509.uts +++ b/test/x509.uts @@ -129,6 +129,13 @@ x.signatureValue == ASN1_BIT_STRING(b"6\xce\xdd\x01\xbdz\x1f\x89[\xc71i_\xb5\x90 = Cert class : Default X509_Cert from scratch str(X509_Cert(str(X509_Cert()))) == str(X509_Cert()) += Cert class : Error +try: + Cert("fail") +except: + assert True +else: + assert False ############ CRL class ###############################################