Closed MrErne closed 6 years ago
Can you type
import scapy
scapy.VERSION
In a repl?
(dofus_conda) C:\Users\MrErne>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy
>>> scapy.VERSION
'2.4.0'
What about
import scapy3k
?
(dofus_conda) C:\Users\MrErne>pip install scapy3k
Collecting scapy3k
Could not find a version that satisfies the requirement scapy3k (from versions: )
No matching distribution found for scapy3k
(dofus_conda) C:\Users\MrErne>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy3k
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scapy3k'
>>>
If you install scapy-python3 (the package for scapy3k), does the sniffer work?
(dofus_conda) E:\DEV\Emulation\Conda>python -m labot.sniffer.main --debug
WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6
16:25:13.787 WARNING: MainThread - utils.warning(): No route found for IPv6 destination :: (no default route?). This affects only IPv6
16:25:14.290 DEBUG: MainThread - main.<module>(): Starting sniffer on live interface
16:25:14.291 DEBUG: MainThread - ui.init(): Initializing UI...
16:25:14.292 DEBUG: MainThread - ui.__init__(): Initializing sniffer UI with capture file None and start function <function launch_in_thread at 0x000001FB226C0598>
16:25:14.295 DEBUG: MainThread - ui.__init__(): Initializing Message Table
16:25:14.295 DEBUG: MainThread - ui.init(): Finished initializing UI.
16:25:14.296 DEBUG: MainThread - ui.async_start(): Starting sniffer asynchronously...
16:25:14.296 DEBUG: MainThread - selector_events.__init__(): Using selector: SelectSelector
16:25:14.298 DEBUG: Thread-3 - ui.loop_in_thread(): Starting loop: `<_WindowsSelectorEventLoop running=False closed=False debug=False>` in thread
16:25:14.298 DEBUG: MainThread - ui.async_start(): Started sniffer in thread: <Thread(Thread-3, started 14412)>
[I:wdom.server] Start server on localhost:8888
[I:wdom.server._tornado] connected
[I:wdom.server._tornado] 200 GET / (::1)
[W:wdom.server._tornado] 304 GET /_static/js/wdom.js (::1) 99.62ms
[I:wdom.server._tornado] 101 GET /wdom_ws (::1)
[I:wdom.server._tornado] WebSocket OPEN
16:25:24.838 DEBUG: Thread-3 - network.launch_in_thread(): Launching sniffer in thread...
16:25:24.839 DEBUG: Thread-4 - network.sniff(): Setting up sniffer...
16:25:24.839 DEBUG: Thread-3 - network.launch_in_thread(): Started sniffer in new thread
16:25:24.840 DEBUG: Thread-4 - network.sniff(): Started Sniffing
<L2pcapListenSocket: read packets at layer 2 using libpcap>
16:25:24.840 DEBUG: Thread-4 - network.sniff(): Stopped sniffing.
Exception in thread Thread-4:
Traceback (most recent call last):
File "D:\Users\MrErne\Miniconda3\envs\dofus_conda\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "D:\Users\MrErne\Miniconda3\envs\dofus_conda\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "E:\DEV\Emulation\Conda\labot\sniffer\network.py", line 137, in _sniff
prn=lambda p: on_receive(p, action),
File "E:\DEV\Emulation\Conda\labot\sniffer\network.py", line 57, in sniff
sel = select([s], [], [], refresh)
File "D:\Users\MrErne\Miniconda3\envs\dofus_conda\lib\site-packages\scapy\supersocket.py", line 38, in fileno
return self.ins.fileno()
File "D:\Users\MrErne\Miniconda3\envs\dofus_conda\lib\site-packages\scapy\arch\pcapdnet.py", line 232, in fileno
error("Cannot get selectable PCAP fd on Windows")
NameError: name 'error' is not defined
OK so basically there is a problem in both scapy3k (kamene) and normal scapy (the first one that was used).
The problem is caused by my use of select on the ListenSocket which is not supported by Windows.
I adapted the function sniff in sendrecv.py from kamene (scapy3k). I just looked at its equivalent in scapy, and it seems they have another system to replace select: https://github.com/secdev/scapy/blob/master/scapy/sendrecv.py#L877
It seems they just read and ignore the error on windows, so I'll adapt what they do (with a sleep).
I will also delete the scapy3k imports now that this name is deprecated and scapy works well on Python 3.
Tell me if it is fixed (forgot that r'fix #[0-9]+' triggers github)
Sacpy Fix on Windows 👍
Soucis avec Scapy sur Windows
Log:
Et voici le code de scapy qui doit surement bloquer: