2

我需要执行以下操作:

  • a) 使用 Scapy 在 eth0 上嗅探()。这会给我一个scapy包..说X。
  • b)将X作为二进制数据存储到某个变量中...... Y。
  • c) 使用 zeromq IPC 套接字将 Y 发送到另一个进程。我必须使用 IPC,而不是 tcp/udp。

代码:

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')

在另一个过程中:

while 1: 
  y = s.recv()
  x = recover scapy packet from y
  ... do something with x ... 
4

1 回答 1

1

Scapy 实现的str()表示对您来说应该足够了。

y = str(x)

您可以让 Scapy 在接收端将其解析回正确的数据包,如下所示 -

x = Ether(y)

来自Scapy 文档的 Stacking-Layers部分的第二个代码示例。

于 2013-11-14T03:12:00.253 回答