diff --git a/bin/UTscapy.bat b/bin/UTscapy.bat new file mode 100755 index 0000000000000000000000000000000000000000..8f86ff0d1c8efc701035a3e453ca1d68cad5cd2e --- /dev/null +++ b/bin/UTscapy.bat @@ -0,0 +1,2 @@ +@REM Use Python to run the UTscapy script from the current directory, passing all parameters +@python %~dp0\UTscapy %* diff --git a/bin/scapy.bat b/bin/scapy.bat new file mode 100755 index 0000000000000000000000000000000000000000..613370a5e2a666e5007fdc346c5b3618a2087e63 --- /dev/null +++ b/bin/scapy.bat @@ -0,0 +1,2 @@ +@REM Use Python to run the Scapy script from the current directory, passing all parameters +@python %~dp0\scapy %* diff --git a/doc/scapy/installation.rst b/doc/scapy/installation.rst index 94454afe81783672deee6c2af9609d303a2e16a4..92b6fce28745675e6b3477fcafe65cf51d5c2611 100644 --- a/doc/scapy/installation.rst +++ b/doc/scapy/installation.rst @@ -364,9 +364,9 @@ You need the following software packages in order to install Scapy on Windows: * `Python <http://www.python.org>`_: `python-2.5.4.msi <http://www.python.org/ftp/python/2.5.4/python-2.5.4.msi>`_. After installation, add ``C:\Python25`` and ``C:\Python25\Scripts`` to your PATH. I'm using Python 2.5. Scapy-win does not work with Python 2.4 or 2.6, because not all third-party extensions on this page are available for them. * `Scapy-win2 <http://hg.secdev.org/scapy-win2>`_: `latest version from the Mercurial repository <http://hg.secdev.org/scapy-win2/archive/tip.zip>`_. Unzip the archive, open a command prompt in that directroy and run "python setup.py install". * `pywin32 <http://python.net/crew/mhammond/win32/Downloads.html>`_: `pywin32-214.win32-py2.5.exe <http://surfnet.dl.sourceforge.net/sourceforge/pywin32/pywin32-214.win32-py2.5.exe>`_ - * `Wireshark <http://www.wireshark.org/>`_: `Wireshark download page <http://www.wireshark.org/download.html>`_. - * `pypcap <http://code.google.com/p/pypcap/>`_: `pcap-1.1-scapy-20090720.win32-py25.exe <http://dirk-loss.de/scapy/pcap-1.1-scapy-20090720.win32-py25.exe>`_. This is a *special version for Scapy*, as the original leads to some timing problems. Now works on Vista and Windows 7, too. - * `libdnet <http://code.google.com/p/libdnet/>`_: `dnet-1.12.win32-py2.5.exe <http://libdnet.googlecode.com/files/dnet-1.12.win32-py2.5.exe>`_ + * `Wireshark <http://www.wireshark.org/>`_: `Wireshark download page <http://www.wireshark.org/download.html>`_. If you get WinPcap installation errors on Windows 7, please run the installation program in "Vista compatibility" mode. You might want to choose "[x] Start WinPcap service 'NPF' at startup", so that non-privileged users can sniff, especially under Vista and Windows 7. + * `pypcap <http://code.google.com/p/pypcap/>`_: `pcap-1.1-scapy-20090720.win32-py25.exe <http://www.secdev.org/projects/scapy/files/pcap-1.1-scapy-20090720.win32-py2.5.exe>`_. This is a *special version for Scapy*, as the original leads to some timing problems. Now works on Vista and Windows 7, too. Under Vista/Win7 please right-click on the installer and choose "Run as administrator". + * `libdnet <http://code.google.com/p/libdnet/>`_: `dnet-1.12.win32-py2.5.exe <http://libdnet.googlecode.com/files/dnet-1.12.win32-py2.5.exe>`_. Under Vista/Win7 please right-click on the installer and choose "Run as administrator" * `pyreadline <http://ipython.scipy.org/moin/PyReadline/Intro>`_: `pyreadline-1.5-win32-setup.exe <http://ipython.scipy.org/dist/pyreadline-1.5-win32-setup.exe>`_ Just download the files and run the setup program. Choosing the default installation options should be safe. diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py old mode 100644 new mode 100755 index 6b55b978e9716c8fdce4d88af8f57261a957a9b8..a80cbce37c99bf79691b21d119740994c8b635d9 --- a/scapy/arch/windows/__init__.py +++ b/scapy/arch/windows/__init__.py @@ -226,11 +226,13 @@ pcapdnet.open_pcap = lambda iface,*args,**kargs: _orig_open_pcap(pcap_name(iface def read_routes(): ok = 0 routes = [] - ip = '(\d+\.\d+\.\d+\.\d+)\s+' - # On Vista and Windows 7 the gateway can be IP or 'on-link'. - # The exact 'on-link' string depends on the locale. - gw_pattern = '([\w\s]+|\d+\.\d+\.\d+\.\d+)\s+' - netstat_line = ip + ip + gw_pattern + ip + "(\d+)" + ip = '(\d+\.\d+\.\d+\.\d+)' + # On Vista and Windows 7 the gateway can be IP or 'On-link'. + # But the exact 'On-link' string depends on the locale, so we allow any text. + gw_pattern = '(.+)' + metric_pattern = "(\d+)" + delim = "\s+" # The columns are separated by whitespace + netstat_line = delim.join([ip, ip, gw_pattern, ip, metric_pattern]) pattern = re.compile(netstat_line) f=os.popen("netstat -rn") for l in f.readlines(): diff --git a/setup.py b/setup.py index 2fffd0f9c48cc2f2b0ac781646909ec4bc157c67..477e26d26399960d1b49fcf7b7a62ee391a39377 100755 --- a/setup.py +++ b/setup.py @@ -34,12 +34,16 @@ def make_ezipfile(base_name, base_dir, verbose=0, dry_run=0): archive_util.ARCHIVE_FORMATS["ezip"] = (make_ezipfile,[],'Executable ZIP file') +SCRIPTS = ['bin/scapy','bin/UTscapy'] +# On Windows we also need additional batch files to run the above scripts +if os.name == "nt": + SCRIPTS += ['bin/scapy.bat','bin/UTscapy.bat'] setup( name = 'scapy', version = '2.0.1-dev', packages=['scapy','scapy/arch', 'scapy/arch/windows', 'scapy/layers','scapy/asn1','scapy/tools','scapy/modules'], - scripts = ['bin/scapy','bin/UTscapy'], + scripts = SCRIPTS, data_files = [('share/man/man1', ["doc/scapy.1.gz"])], # Metadata