本文整理汇总了Python中scapy.supersocket.SuperSocket类的典型用法代码示例。如果您正苦于以下问题:Python SuperSocket类的具体用法?Python SuperSocket怎么用?Python SuperSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SuperSocket类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: send
def send(self, x):
pkt_src_mac_field,pkt_src_mac_val = x.getfield_and_val('src')
if self.__use_iface and pkt_src_mac_val is None:
iff = self.iface
if iff:
try:
src_mac = scapy.arch.get_if_hwaddr(iff)
except:
pass
if src_mac is None:
src_mac = "00:00:00:00:00:00"
x.src = scapy.fields.MACField.i2h(pkt_src_mac_field, x, src_mac)
if x.haslayer('IP') :
pkt_src_ip_field,pkt_src_ip_val = x['IP'].getfield_and_val('src')
if isinstance(pkt_src_ip_field,scapy.fields.Emph):
pkt_src_ip_field = pkt_src_ip_field.fld
if self.__use_iface and pkt_src_ip_val is None:
iff = self.iface
if iff:
try:
src_ip = scapy.arch.get_if_addr(iff)
except:
pass
x['IP'].src = scapy.fields.SourceIPField.i2h(pkt_src_ip_field, x, src_ip)
SuperSocket.send(self, x)
开发者ID:ogreworld,项目名称:ScapyExtension,代码行数:28,代码来源:pcapdnet.py
示例2: close
def close(self):
if self.closed:
return
self.closed = 1
if self.promisc:
set_promisc(self.ins, self.iface, 0)
SuperSocket.close(self)
开发者ID:plorinquer,项目名称:scapy,代码行数:7,代码来源:linux.py
示例3: send
def send(self, x):
try:
return SuperSocket.send(self, x)
except socket.error as msg:
if msg[0] == 22 and len(x) < conf.min_pkt_size:
padding = b"\x00" * (conf.min_pkt_size - len(x))
if isinstance(x, Packet):
return SuperSocket.send(self, x / Padding(load=padding))
else:
return SuperSocket.send(self, raw(x) + padding)
raise
开发者ID:plorinquer,项目名称:scapy,代码行数:11,代码来源:linux.py
示例4: __init__
def __init__(self, peer="127.0.0.1"):
SuperSocket.__init__(self, socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
self.outs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
self.tx_addr = (peer, 52001)
self.rx_addr = (peer, 52002)
self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.outs.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.outs.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except AttributeError:
pass
self.ins.bind(self.rx_addr)
开发者ID:cloatre,项目名称:EZ-Wave,代码行数:13,代码来源:gnuradio.py
示例5: send
def send(self, x):
try:
if hasattr(x, "sent_time"):
x.sent_time = time.time()
# need to change the byteoder of the first four bytes,
# required by the underlying Linux SocketCAN frame format
bs = bytes(x)
bs = bs + b'\x00' * (CAN_FRAME_SIZE - len(bs))
bs = struct.pack("<I12s", *struct.unpack(">I12s", bs))
return SuperSocket.send(self, bs)
except socket.error as msg:
raise msg
开发者ID:segment-routing,项目名称:scapy,代码行数:13,代码来源:cansocket_native.py
示例6: recv
def recv(self, x=MTU):
# cls, pkt, ts, direction = self.recv_raw()
# [Dissection stuff]
pkt = SuperSocket.recv(self, x)
# pkt.direction = direction
return pkt
开发者ID:plorinquer,项目名称:scapy,代码行数:6,代码来源:linux.py
示例7: close
def close(self):
SuperSocket.close(self)
self.usbpcap_proc.kill()
开发者ID:commial,项目名称:scapy,代码行数:3,代码来源:usb.py
注:本文中的scapy.supersocket.SuperSocket类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论