scapy icon indicating copy to clipboard operation
scapy copied to clipboard

trace3D broken under Windows (not a #353 regression)

Open z3ndrag0n opened this issue 2 years ago • 1 comments

Brief description

Using the following sample code results in a traceback on Windows 11 using Python 3.11: a,u=traceroute(["www.python.org", "google.com","slashdot.org"]) a.trace3D()

Scapy version

2.5.0.dev40

Python version

3.11

Operating system

Windows 11 Pro

Additional environment information

No response

How to reproduce

import scapy from scapy.all import * a,u=traceroute(["www.python.org", "google.com","slashdot.org"]) a.trace3D()

Actual result

traceback is: `Traceback (most recent call last): File "", line 1, in File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 120, in spawn_main exitcode = _main(fd, parent_sentinel) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 129, in _main prepare(preparation_data) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 240, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 291, in _fixup_main_from_path main_content = runpy.run_path(main_path, ^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 291, in run_path File "", line 98, in _run_module_code File "", line 88, in _run_code File "c:\Users\z3ndr\Downloads\scapy-intro.py", line 17, in a.trace3D() File "C:\Users\z3ndr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\scapy\layers\inet.py", line 1388, in trace3D p.start() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) ^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\context.py", line 336, in _Popen return Popen(process_obj) ^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\popen_spawn_win32.py", line 45, in init prep_data = spawn.get_preparation_data(process_obj._name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 158, in get_preparation_data _check_not_importing_main() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 138, in _check_not_importing_main raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

`

Expected result

No response

Related resources

No response

z3ndrag0n avatar Mar 03 '23 13:03 z3ndrag0n

from scapy.all import *

# Define your traceroute function
def my_traceroute(targets):
    # Perform your traceroute operations here
    # For example:
    res, unans = sr(IP(dst=targets)/ICMP(), timeout=1)
    return res, unans

# Call your traceroute function
a, u = my_traceroute(["www.python.org", "google.com", "slashdot.org"])

# After obtaining the results, you can then call trace3D()
a.trace3D()

ljluestc avatar Feb 20 '24 03:02 ljluestc