سؤال

I need to do the following:

  • a) Use Scapy to sniff() on eth0. This will get me a scapy packet .. say X.
  • b) Store X as a binary data into some variable... Y.
  • c) Use zeromq IPC sockets to send off Y to another process. I must use IPC, not tcp/udp.

Code:

def handler(x):
  x.show() #or do something .. 
  s = .. a zmq socket = ipc://myipcendpoint

  y = convert x to binary <== how to do this? 
  s.send(y) 


sniff(prn=handler, iface='eth0')

On the other process:

while 1: 
  y = s.recv()
  x = recover scapy packet from y
  ... do something with x ... 
هل كانت مفيدة؟

المحلول

The str() representation that Scapy implements should be enough for you.

y = str(x)

You can have Scapy parse it back into proper packet on the receiving end like so -

x = Ether(y)

From the 2nd code example in the Stacking-Layers section of the Scapy doc.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top