[python] scapy a serializace paketu

Jirka Vejrazka jirka.vejrazka na gmail.com
Pondělí Červenec 5 21:22:15 CEST 2010


Ahoj, ja ted nejsem u PC, ale mam takove tuseni, ze jsem jednou misto
scapy pouzil knihovnu dpkt a ty pakety serializovat sly. Pisu to jenom
z hlavy, tak to ber s rezervou. Vymenit scapy za dpkt asi nebude
nejjednodussi, ale kdyby nahodou...

  Jirka

On 05/07/2010, Tomas Pelka <tompelka at gmail.com> wrote:
> Zdravim vsechny,
>
> mam maly problem s ukladanim scapy paketu do fronty (multiprocess). Priklad:
>
> from multiprocessing import Process
> from multiprocessing.managers import BaseManager
> from scapy.all import sniff
>
> class Worker(Process):
>          '''
>          Class for sniffing packets, runnig as root
>          '''
>          def __init__(self):
>                  super(Worker, self).__init__()
>                  self.iface = ''
>                  self.expr = ''
>                  # key for queue daemon, remotely on localhost:5000
>                  self._keyQ = '10b222970537b97919db36ec757370d2'
>                  class QueueManager(BaseManager): pass
>                  QueueManager.register('get_dataQueue')
>                  self._m = QueueManager(address=('127.0.0.1', 5000),
> authkey=self._keyQ)
>                  self._m.connect()
>                  self.dataQueue = self._m.get_dataQueue()
>          def go(self, iface, expr):
>                  print "Starting sniffer"
>                  self.iface = iface
>                  self.expr = expr
>                  super(Worker, self).start()
>          def run(self):
>                  print "sniffing ..."
>                  print self.iface
>                  print self.expr
>                  print self.dataQueue
>                  packets = sniff(filter=self.expr, count=10, timeout=10,
> iface=self.iface)
>                  print packets
>                  self.dataQueue.put(packets)
>                  print "... done"
>
>
> But always getting:
> Traceback (most recent call last):
>    File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in
> _bootstrap
>      self.run()
>    File "/home/tom/web2py/applications/NetSim/DAEMON/Worker.py", line
> 32, in run
>      self.dataQueue.put(packets)
>    File "<string>", line 2, in put
>    File "/usr/lib/python2.6/multiprocessing/managers.py", line 725, in
> _callmethod
>      conn.send((self._id, methodname, args, kwds))
> PicklingError: Can't pickle <type 'function'>: attribute lookup
> __builtin__.function failed
>
>
> PAkety nejsou snad serializovatelne? Nesetkal se s touto chybou uz nekdo
> drive?
>
> Diky za rady
>
> --
> Tomas Pelka
>
>


Další informace o konferenci Python