louisabraham / LaBot

Bot Dofus 2 en Python 3
MIT License
79 stars 37 forks source link

Problème au lancement du sniffer #26

Open awshx opened 3 years ago

awshx commented 3 years ago

Bonjour et merci pour le temps que vous voudrez bien m'accorder

J'ai récemment codé un pixelbot mais j'aurais besoin de récupérer des informations via le sniffer pour qu'il soit plus efficace (j'arrive au bout des limites du pixel pour la détection des ressources avec openCV et pyautogui c'est assez gourmand mais bref c'est pas le sujet).

La seule partie du code que j'ai changé c'est l'import, j'ai remplacé

#from scapy.all import plist, conf
#from scapy.all import Raw, IP, PcapReader

par from scapy.all import *

Lors du lancement, j'ai un problème qui est le suivant :

File "/Users/awshx/Desktop/LaBot-master/labot/sniffer/network.py", line 88, in _select
    return select(sockets, [], [], refresh)[0]
TypeError: 'module' object is not callable

Je ne sais pas d'où ça vient, j'y connais vraiment pas grand chose en réseau, le code m'a l'air correct je ne comprends pas pourquoi ça plante.

Merci par avance les codeurs ;D

kenny94xxhell commented 3 years ago

Le lancement du sniffer se fait par le module labot.sniffer.__main__ Donc il faut placer son working directory à la racine LaBot, puis executer python3 -m labot.sniffer.__main__ Des arguments peuvent être ajoutés à la fin. Voir --help.

Pour importer le sniffer dans un autre projet, il faut réaliser l'import de cette manière :

from LaBot.labot.sniffer import __main__
from LaBot.labot.sniffer import network

Le sniffer se lance. il faut maintenant se connecter au serveur local WDOM sur le port 8888 depuis un navigateur internet. localhost:8888

awshx commented 3 years ago

Merci pour ta réponse, c'est effectivement ce qu'il se passe, sur le localhost:8888 j'ai bien la fenêtre du sniffer qui apparaît, mais lorsque je clique sur "Start", tout s'arrête et j'ai cette erreur dans la console que j'avais auparavant:

awshx@MacBook-Air-de-awshx LaBot-master % sudo python3 -m labot.sniffer.__main__   
[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) 13.23ms
[I:wdom.server._tornado] 101 GET /wdom_ws (::1)
[I:wdom.server._tornado] WebSocket OPEN
[I:wdom.server._tornado] WebSocket CLOSED
[I:wdom.server._tornado] connected
[I:wdom.server._tornado] 304 GET / (::1)
[I:wdom.server._tornado] 101 GET /wdom_ws (::1)
[I:wdom.server._tornado] WebSocket OPEN
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/awshx/Desktop/LaBot-master/labot/sniffer/network.py", line 206, in _sniff
    sniff(
  File "/Users/awshx/Desktop/LaBot-master/labot/sniffer/network.py", line 102, in sniff
    sel = _select([s])
  File "/Users/awshx/Desktop/LaBot-master/labot/sniffer/network.py", line 89, in _select
    return select(sockets, [], [], refresh)[0]
TypeError: 'module' object is not callable

Je viens d'y penser, j'ai un Mac M1 et c'est peut être dû à ça au niveau des threads (ça fonctionne sur une architecture ARM).

Edit : Je viens d'essayer avec mon ancien Mac, tournant sur une version Intel et j'ai également le bug, donc c'est pas dû à la puce M1

ImNotARobot742 commented 3 years ago

Salut =)

Je cherche a réutiliser le sniffer et je suis retombé sur le même problème que @awshx . As tu trouvé une solution ? Parce que de mon côté avec ma faible connaissance du python je n'ai pas réussi.

(Je suis sur Windows 10, il semble donc que le problème ne soit pas lié a l'OS)

louisabraham commented 3 years ago

Je peux avoir le message d'erreur complet ?

J'ai l'impression que les lignes ne correspondent pas au code : https://github.com/louisabraham/LaBot/blob/master/labot/sniffer/network.py#L87

AlexisVLRT commented 2 years ago

J'ai eu le même problème. Résolu en gigotant un peu les imports:

from scapy.all import conf, Raw, IP
from scapy import plist
from scapy.data import ETH_P_ALL, MTU
from scapy.consts import WINDOWS

MacOS BigSur Python 3.10 Scapy 2.4.5

pssistorm commented 1 year ago

bonjour, quand j'essaye de lancer le sniffer j'obtient l'erreur suivante:

(base) Psistorm@pc-44 LaBot-master % sudo python -m labot.sniffer
WARNING: No IPv4 address found on anpi1 ! WARNING: No IPv4 address found on anpi0 ! WARNING: more No IPv4 address found on en3 ! [I:wdom.server] Start server on localhost:8888 [I:wdom.server._tornado] connected [I:wdom.server._tornado] 200 GET / (::1) [I:wdom.server._tornado] 101 GET /wdom_ws (::1) [I:wdom.server._tornado] WebSocket OPEN [W:wdom.server._tornado] 404 GET /favicon.ico (::1) Exception in thread Thread-2: Traceback (most recent call last): File "/Users/Psistorm/opt/anaconda3/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/Users/Psistorm/opt/anaconda3/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/Users/Psistorm/Downloads/LaBot-master/labot/sniffer/network.py", line 201, in _sniff sniff( File "/Users/Psistorm/Downloads/LaBot-master/labot/sniffer/network.py", line 112, in sniff r = prn(p) File "/Users/Psistorm/Downloads/LaBot-master/labot/sniffer/network.py", line 205, in prn=lambda p: on_receive(p, action), File "/Users/Psistorm/Downloads/LaBot-master/labot/sniffer/network.py", line 177, in on_receive msg = Msg.fromRaw(buf, direction) File "/Users/Psistorm/Downloads/LaBot-master/labot/data/msg.py", line 67, in fromRaw logger.debug("Parsed %s", protocol.msg_from_id[id]["name"]) KeyError: 6743 [I:wdom.server._tornado] WebSocket CLOSED