scapy.supersocket module
SuperSocket.
- class scapy.supersocket.IterSocket(obj: Sequence[Packet] | Packet | SetGen[Packet] | _PacketList[Packet])[source]
Bases:
SuperSocket
- desc = 'wrapper around an iterable'
- nonblocking_socket: bool = True
- static select(sockets: List[SuperSocket], remain: Any = None) List[SuperSocket] [source]
- class scapy.supersocket.L2ListenTcpdump(iface: NetworkInterface | str | None = None, promisc: bool | None = None, filter: str | None = None, nofilter: bool = False, prog: str | None = None, quiet: bool = False, *arg: Any, **karg: Any)[source]
Bases:
SuperSocket
- desc = 'read packets at layer 2 using tcpdump'
- static select(sockets: List[SuperSocket], remain: float | None = None) List[SuperSocket] [source]
- class scapy.supersocket.L3RawSocket(type: int = 2048, filter: str | None = None, iface: NetworkInterface | str | None = None, promisc: bool | None = None, nofilter: int = 0)[source]
Bases:
SuperSocket
- desc = 'Layer 3 using Raw sockets (PF_INET/SOCK_RAW)'
- class scapy.supersocket.L3RawSocket6(type: int = 34525, filter: str | None = None, iface: NetworkInterface | str | None = None, promisc: bool | None = None, nofilter: bool = False)[source]
Bases:
L3RawSocket
- class scapy.supersocket.SSLStreamSocket(sock: socket, basecls: Type[Packet] | None = None)[source]
Bases:
StreamSocket
- desc = 'similar usage than StreamSocket but specialized for handling SSL-wrapped sockets'
- static select(sockets: List[SuperSocket], remain: float | None = None) List[SuperSocket] [source]
- class scapy.supersocket.SimpleSocket(sock: socket, basecls: Type[Packet] | None = None)[source]
Bases:
SuperSocket
- desc = 'wrapper around a classic socket'
- class scapy.supersocket.StreamSocket(sock: socket, basecls: Type[Packet] | None = None)[source]
Bases:
SimpleSocket
Wrap a stream socket into a layer 2 SuperSocket
- Parameters:
sock – the socket to wrap
basecls – the base class packet to use to dissect the packet
- desc = 'transforms a stream socket into a layer 2'
- class scapy.supersocket.SuperSocket(family: int = AddressFamily.AF_INET, type: int = SocketKind.SOCK_STREAM, proto: int = 0, iface: NetworkInterface | str | None = None, **kwargs: Any)[source]
Bases:
object
- am(cls: Type[Any], *args: Any, **kwargs: Any) Any [source]
Creates an AnsweringMachine associated with this socket.
- Parameters:
cls – A subclass of AnsweringMachine to instantiate
- auxdata_available: bool = False
- closed: bool = False
- nonblocking_socket: bool = False
- recv(x: int = 65535, **kwargs: Any) Packet | None [source]
Receive a Packet according to the basecls of this socket
- Parameters:
x – Maximum number of bytes to be received, defaults to MTU
- Returns:
The received Packet object, or None
- recv_raw(x: int = 65535) Tuple[Type[Packet] | None, bytes | None, float | None] [source]
Returns a tuple containing (cls, pkt_data, time)
- Parameters:
x – Maximum number of bytes to be received, defaults to MTU
- Returns:
A tuple, consisting of a Packet type, the received data, and a timestamp
- static select(sockets: List[SuperSocket], remain: float | None = 0.05) List[SuperSocket] [source]
This function is called during sendrecv() routine to select the available sockets.
- Parameters:
sockets – an array of sockets that need to be selected
- Returns:
an array of sockets that were selected and the function to be called next to get the packets (i.g. recv)
- send(x: Packet) int [source]
Sends a Packet object
- Parameters:
x – Packet to be send
- Returns:
Number of bytes that have been sent
- sniff(*args: Any, **kargs: Any) PacketList [source]
- sr(*args: Any, **kargs: Any) Tuple[SndRcvList, PacketList] [source]
Send and Receive multiple packets
- class scapy.supersocket.tpacket_auxdata[source]
Bases:
Structure
- tp_len
Structure/Union member
- tp_mac
Structure/Union member
- tp_net
Structure/Union member
- tp_snaplen
Structure/Union member
- tp_status
Structure/Union member
- tp_vlan_tci
Structure/Union member
- tp_vlan_tpid
Structure/Union member