Python scapy.data.MTU Examples
The following are 30
code examples of scapy.data.MTU().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scapy.data
, or try the search function
.
Example #1
Source File: native.py From scapy with GNU General Public License v2.0 | 7 votes |
def recv_raw(self, x=MTU): try: data, address = self.ins.recvfrom(x) except io.BlockingIOError: return None, None, None from scapy.layers.inet import IP from scapy.layers.inet6 import IPv6 if self.ipv6: # AF_INET6 does not return the IPv6 header. Let's build it # (host, port, flowinfo, scopeid) host, _, flowinfo, _ = address header = raw(IPv6(src=host, dst=self.host_ip6, fl=flowinfo, nh=self.proto, # fixed for AF_INET6 plen=len(data))) return IPv6, header + data, time.time() else: return IP, data, time.time()
Example #2
Source File: supersocket.py From scapy with GNU General Public License v2.0 | 6 votes |
def recv(self, x=MTU): cls, val, ts = self.recv_raw(x) if not val or not cls: return try: pkt = cls(val) except KeyboardInterrupt: raise except Exception: if conf.debug_dissector: from scapy.sendrecv import debug debug.crashed_on = (cls, val) raise pkt = conf.raw_layer(val) if ts: pkt.time = ts return pkt
Example #3
Source File: utils.py From scapy with GNU General Public License v2.0 | 6 votes |
def read_packet(self, size=MTU): rp = super(PcapNgReader, self).read_packet(size=size) if rp is None: raise EOFError s, (linktype, tsresol, tshigh, tslow, wirelen) = rp try: p = conf.l2types[linktype](s) except KeyboardInterrupt: raise except Exception: if conf.debug_dissector: raise p = conf.raw_layer(s) if tshigh is not None: p.time = EDecimal((tshigh << 32) + tslow) / tsresol p.wirelen = wirelen return p
Example #4
Source File: utils.py From scapy with GNU General Public License v2.0 | 6 votes |
def read_packet(self, size=MTU): rp = super(PcapReader, self).read_packet(size=size) if rp is None: raise EOFError s, pkt_info = rp try: p = self.LLcls(s) except KeyboardInterrupt: raise except Exception: if conf.debug_dissector: from scapy.sendrecv import debug debug.crashed_on = (self.LLcls, s) raise p = conf.raw_layer(s) power = Decimal(10) ** Decimal(-9 if self.nano else -6) p.time = EDecimal(pkt_info.sec + power * pkt_info.usec) p.wirelen = pkt_info.wirelen return p
Example #5
Source File: supersocket.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): if self.mode_tun: data = os.read(self.ins.fileno(), x + 4) proto = struct.unpack('!H', data[2:4])[0] return conf.l3types.get(proto, conf.raw_layer)(data[4:]) return conf.l2types.get(1, conf.raw_layer)( os.read(self.ins.fileno(), x) )
Example #6
Source File: supersocket.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): pkt = self.ins.recv(x, socket.MSG_PEEK) x = len(pkt) if x == 0: return None pkt = self.basecls(pkt) pad = pkt.getlayer(conf.padding_layer) if pad is not None and pad.underlayer is not None: del(pad.underlayer.payload) from scapy.packet import NoPayload while pad is not None and not isinstance(pad, NoPayload): x -= len(pad.load) pad = pad.payload self.ins.recv(x) return pkt
Example #7
Source File: bluetooth.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #8
Source File: bluetooth.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return HCI_Hdr(self.ins.recv(x))
Example #9
Source File: can.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, size=MTU): """ Emulate a socket """ return self.read_packet(size=size)
Example #10
Source File: usb.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return self.ins.recv(x)
Example #11
Source File: native.py From scapy with GNU General Public License v2.0 | 5 votes |
def nonblock_recv(self, x=MTU): return self.recv() # https://docs.microsoft.com/en-us/windows/desktop/winsock/tcp-ip-raw-sockets-2 # noqa: E501 # - For IPv4 (address family of AF_INET), an application receives the IP # header at the front of each received datagram regardless of the # IP_HDRINCL socket option. # - For IPv6 (address family of AF_INET6), an application receives # everything after the last IPv6 header in each received datagram # regardless of the IPV6_HDRINCL socket option. The application does # not receive any IPv6 headers using a raw socket.
Example #12
Source File: pcapdnet.py From scapy with GNU General Public License v2.0 | 5 votes |
def nonblock_recv(self): """Receives and dissect a packet in non-blocking mode. Note: on Windows, this won't do anything.""" self.ins.setnonblock(1) p = self.recv(MTU) self.ins.setnonblock(0) return p
Example #13
Source File: pcapdnet.py From scapy with GNU General Public License v2.0 | 5 votes |
def __init__(self, iface=None, type=ETH_P_ALL, promisc=None, filter=None, monitor=None): # noqa: E501 super(L2pcapListenSocket, self).__init__() self.type = type self.outs = None self.iface = iface if iface is None: iface = conf.iface if promisc is None: promisc = conf.sniff_promisc self.promisc = promisc # Note: Timeout with Winpcap/Npcap # The 4th argument of open_pcap corresponds to timeout. In an ideal world, we would # noqa: E501 # set it to 0 ==> blocking pcap_next_ex. # However, the way it is handled is very poor, and result in a jerky packet stream. # noqa: E501 # To fix this, we set 100 and the implementation under windows is slightly different, as # noqa: E501 # everything is always received as non-blocking self.ins = open_pcap(iface, MTU, self.promisc, 100, monitor=monitor) try: ioctl(self.ins.fileno(), BIOCIMMEDIATE, struct.pack("I", 1)) except Exception: pass if type == ETH_P_ALL: # Do not apply any filter if Ethernet type is given # noqa: E501 if conf.except_filter: if filter: filter = "(%s) and not (%s)" % (filter, conf.except_filter) # noqa: E501 else: filter = "not (%s)" % conf.except_filter if filter: self.ins.setfilter(filter)
Example #14
Source File: pcapdnet.py From scapy with GNU General Public License v2.0 | 5 votes |
def __init__(self, iface=None, type=ETH_P_ALL, promisc=None, filter=None, nofilter=0, # noqa: E501 monitor=None): super(L2pcapSocket, self).__init__() if iface is None: iface = conf.iface self.iface = iface if promisc is None: promisc = 0 self.promisc = promisc # See L2pcapListenSocket for infos about this line self.ins = open_pcap(iface, MTU, self.promisc, 100, monitor=monitor) self.outs = self.ins try: ioctl(self.ins.fileno(), BIOCIMMEDIATE, struct.pack("I", 1)) except Exception: pass if nofilter: if type != ETH_P_ALL: # PF_PACKET stuff. Need to emulate this for pcap # noqa: E501 filter = "ether proto %i" % type else: filter = None else: if conf.except_filter: if filter: filter = "(%s) and not (%s)" % (filter, conf.except_filter) # noqa: E501 else: filter = "not (%s)" % conf.except_filter if type != ETH_P_ALL: # PF_PACKET stuff. Need to emulate this for pcap # noqa: E501 if filter: filter = "(ether proto %i) and (%s)" % (type, filter) else: filter = "ether proto %i" % type if filter: self.ins.setfilter(filter)
Example #15
Source File: pcapdnet.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): r = L2pcapSocket.recv(self, x) if r: r.payload.time = r.time return r.payload return r
Example #16
Source File: enet.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): pkt = super(ISOTP_ENETSocket, self).recv(x) return self.outputcls(bytes(pkt[1]))
Example #17
Source File: bluetooth.py From dash-hack with MIT License | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #18
Source File: bluetooth.py From isip with MIT License | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #19
Source File: bluetooth.py From dash-hack with MIT License | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #20
Source File: bluetooth.py From dash-hack with MIT License | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #21
Source File: utils.py From scapy with GNU General Public License v2.0 | 5 votes |
def read_packet(self, size=MTU): """return a single packet read from the file as a tuple containing (pkt_data, pkt_metadata) raise EOFError when no more packets are available """ hdr = self.f.read(16) if len(hdr) < 16: raise EOFError sec, usec, caplen, wirelen = struct.unpack(self.endian + "IIII", hdr) return (self.f.read(caplen)[:size], RawPcapReader.PacketMetadata(sec=sec, usec=usec, wirelen=wirelen, caplen=caplen))
Example #22
Source File: bluetooth.py From CyberScan with GNU General Public License v3.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #23
Source File: bluetooth.py From smod-1 with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #24
Source File: bluetooth.py From arissploit with GNU General Public License v3.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #25
Source File: bluetooth.py From CVE-2016-6366 with MIT License | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #26
Source File: bluetooth.py From mptcp-abuse with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #27
Source File: bluetooth.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def recv(self, x=MTU): return L2CAP_CmdHdr(self.ins.recv(x))
Example #28
Source File: automaton.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, n=MTU): r = self.spb.recv(n) if self.proto is not None: r = self.proto(r) return r
Example #29
Source File: supersocket.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, x=MTU): return self.ins.recv(x)
Example #30
Source File: utils.py From scapy with GNU General Public License v2.0 | 5 votes |
def recv(self, size=MTU): """ Emulate a socket """ return self.read_packet(size=size)[0]