【发布时间】:2015-05-03 07:20:59
【问题描述】:
我有下面的代码来发送命令,但 python 脚本永远不会退出。它挂起。 我正在使用 RHEL 6.4 x86_64。 scapy srp1 也挂了。
from socket import *
from scapy.all import *
from myproto import *
def sendeth(REQUEST, interface = "eth0"):
"""Send raw Ethernet packet on interface."""
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
s.bind((interface, 0))
s.send(REQUEST)
data = s.recv(2048)
hexdump(data)
p = Ether()/MYPROTO()/MYPROTO1()
hexdump(p)
if __name__ == "__main__":
print "Sent %d-byte Ethernet packet on eth3" % sendeth(str(p), 'eth3')
但是执行之后,我在tcpdump上看到了frame,但是python代码永远不会退出,需要一个control^C。
tcpdump: WARNING: eth3: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth3, link-type EN10MB (Ethernet), capture size 65535 bytes
17:10:37.122445 00:00:00:00:00:00 (oui Ethernet) > Broadcast, ethertype Unknown (0x8096), length 34:
0x0000: ffff ffff ffff 0000 0000 0000 8096 0001
0x0010: 0001 1500 0000 0000 0000 0000 0000 ffff
0x0020: eafe
17:10:37.133248 00:04:25:1c:a0:02 (oui Unknown) > Broadcast, ethertype Unknown (0x8096), length 76:
0x0000: ffff ffff ffff 0004 251c a002 8096 0001
0x0010: 0001 9500 0028 0000 0000 0000 0000 0000
0x0020: 0000 f1f0 f100 0000 0000 0000 0000 0000
0x0030: 0000 0000 0000 0803 0087 1634 8096 8096
0x0040: e4f2 0000 0f21 fffc 5427 ffff
【问题讨论】: