diff --git a/appveyor.yml b/appveyor.yml index a0a4393520f8f13133099c1130a995ade7b96ed2..5410db151dadabf8bd75aa8b79f52a977cc74927 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,15 +24,22 @@ test_script: - set PATH="%APPVEYOR_BUILD_FOLDER%;C:\Program Files\Wireshark\;%PATH%" # Main unit tests - - "%PYTHON%\\python -m coverage run -a 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 || exit /b 42" - 'del test\regression.uts' # Secondary and contrib unit tests - 'del test\bpf.uts' # Don't bother with BPF regression tests - - "%PYTHON%\\python -m coverage run -a bin\\UTscapy -c test\\configs\\windows.utsc || exit /b 42" + - "%PYTHON%\\python -m coverage run --parallel-mode bin\\UTscapy -c test\\configs\\windows.utsc || exit /b 42" + + # TLS unit tests + # Note: due to a multiprocessing bug, we got to be in the UTscapy.py folder and call it directly + - 'cd scapy/tools' + - "%PYTHON%\\python -m coverage run --concurrency=multiprocessing UTscapy.py -f text -t ..\\..\\test\\tls\\tests_tls_netaccess.uts -F -P \"sys.path.append(os.path.abspath('../../test/tls'))\" -K open_ssl_client || exit /b 42" + - 'cd ../../' after_test: # Install & run codecov - "%PYTHON%\\python -m pip install codecov" - "SET PATH=%PYTHON%\\Scripts\\;%PATH%" + - "coverage combine ./ ./scapy/tools/" - codecov diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py index c6b345a01991b89b58d0dd94f5250e9dfcbda8ad..62256a787e26148994ab2a7e74de85be8c36fb74 100755 --- a/scapy/arch/windows/__init__.py +++ b/scapy/arch/windows/__init__.py @@ -6,6 +6,7 @@ """ Customizations needed to support Microsoft Windows. """ + import os,re,sys,socket,time, itertools import subprocess as sp from glob import glob @@ -259,6 +260,9 @@ class WinProgPath(ConfClass): ) self.cscript = win_find_exe("cscript", installsubdir="System32", env="SystemRoot") + if self.wireshark != "wireshark": + manu_path = load_manuf(os.path.sep.join(self.wireshark.split(os.path.sep)[:-1])+os.path.sep+"manuf") + scapy.data.MANUFDB = conf.manufdb = MANUFDB = manu_path conf.prog = WinProgPath() if conf.prog.powershell == "powershell": diff --git a/scapy/data.py b/scapy/data.py index 5a46311957afe11df02e8d0d090308766e32c0dd..b6d805361efd83d6e26f846cca42c54004071c59 100644 --- a/scapy/data.py +++ b/scapy/data.py @@ -147,7 +147,8 @@ class ManufDA(DADict): if oui in self: return ":".join([self[oui][0]]+ mac.split(":")[3:]) return mac - + def __repr__(self): + return "\n".join(["<%s %s, %s>" % (i[0], i[1][0], i[1][1]) for i in self.__dict__.items()]) @@ -165,12 +166,12 @@ def load_manuf(filename): lng=shrt else: lng = l[i+2:] - manufdb[oui] = shrt,lng + manufdb[oui] = shrt, lng except Exception,e: log_loading.warning("Couldn't parse one line from [%s] [%r] (%s)" % (filename, l, e)) except IOError: - #log_loading.warning("Couldn't open [%s] file" % filename) - pass + log_loading.warning("Couldn't open [%s] file" % filename) + return "" return manufdb @@ -179,6 +180,7 @@ if WINDOWS: ETHER_TYPES=load_ethertypes("ethertypes") IP_PROTOS=load_protocols(os.environ["SystemRoot"]+"\system32\drivers\etc\protocol") TCP_SERVICES,UDP_SERVICES=load_services(os.environ["SystemRoot"] + "\system32\drivers\etc\services") + # Default value, will be updated by arch.windows MANUFDB = load_manuf(os.environ["ProgramFiles"] + "\\wireshark\\manuf") else: IP_PROTOS=load_protocols("/etc/protocols") diff --git a/test/mock_windows.uts b/test/mock_windows.uts index 65acbeb218a69c86d1c597fdc51495a34f836d68..01f644b074d78bb15c9df59d3a73a633ac40d67b 100644 --- a/test/mock_windows.uts +++ b/test/mock_windows.uts @@ -206,3 +206,30 @@ for i in ps_read_routes: break assert _correct + += show_interfaces + +from scapy.arch import show_interfaces +from StringIO import StringIO + +@mock.patch('sys.stdout', new_callable=StringIO) +def test_show_interfaces(mock_stdout): + show_interfaces() + lines = mock_stdout.getvalue().split("\n")[1:] + for l in lines: + if not l.strip(): + continue + try: + int(l[0]) + except: + sys.stderr.write(l) + return False + return True + +assert test_show_interfaces() + += dev_from_pcapname + +from scapy.config import conf + +assert dev_from_pcapname(conf.iface.pcap_name).guid == conf.iface.guid diff --git a/test/regression.uts b/test/regression.uts index 0da39aa3a932165e569956f68573df5247d23b77..bffcd6565760761442846833db21ef51ac9fcc83 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -671,6 +671,23 @@ send_and_sniff(IP(dst="secdev.org")/ICMP()) send_and_sniff(IP(dst="secdev.org")/ICMP(), flt="icmp") send_and_sniff(Ether()/IP(dst="secdev.org")/ICMP()) +############ +############ ++ ManuFDB tests + += __repr__ + +if conf.manufdb: + conf.manufdb +else: + True + += check _resolve_MAC + +if conf.manufdb: + assert conf.manufdb._resolve_MAC("00:00:63") == "HP" +else: + True ############ ############ diff --git a/test/tls/tests_tls_netaccess.uts b/test/tls/tests_tls_netaccess.uts index e4f2bc4fb3784656b65552b680a28848b5df9940..7cf8fb2bc3f8c3d7626ad72288bd7126814a9509 100644 --- a/test/tls/tests_tls_netaccess.uts +++ b/test/tls/tests_tls_netaccess.uts @@ -9,6 +9,7 @@ ### DISCLAIMER: Those tests are slow ### = Load server util functions +~ open_ssl_client import sys, os, re, time, multiprocessing, subprocess @@ -58,14 +59,17 @@ def test_tls_server(suite="", version=""): = Testing TLS server with TLS 1.0 and TLS_RSA_WITH_RC4_128_SHA +~ open_ssl_client test_tls_server("RC4-SHA", "-tls1") = Testing TLS server with TLS 1.2 and TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 +~ open_ssl_client test_tls_server("DHE-RSA-AES128-SHA256", "-tls1_2") = Testing TLS server with TLS 1.2 and TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +~ open_ssl_client test_tls_server("ECDHE-RSA-AES256-GCM-SHA384", "-tls1_2")