Answering machines.

class scapy.ansmachine.AnsweringMachine(self)[source]

Bases: Generic[_T]

bg(*args: Any, **kwargs: Any) AsyncSniffer[source]
filter: str | None = None
function_name = ''
is_request(req: Packet) int[source]
abstract make_reply(req: Packet) _T[source]
parse_all_options(mode: int, kargs: Any) Tuple[Dict[str, Any], Dict[str, Any]][source]
parse_options() None[source]
print_reply(req: Packet, reply: _T) None[source]
reply(pkt: Packet, send_function: Callable[[...], None] | None = None, address: Any | None = None) None[source]
run(*args: Any, **kargs: Any) None[source]
static send_function(x: List[Packet] | Packet | SetGen[Packet] | _PacketList[Packet], iface: NetworkInterface | str | None = None, iface_hint: str | None = None, socket: SuperSocket | None = None, **kargs: Any) PacketList | None[source]

Send packets at layer 2

  • x – the packets

  • inter – time (in s) between two packets (default 0)

  • loop – send packet indefinitely (default 0)

  • count – number of packets to send (default None=1)

  • verbose – verbose mode (default None=conf.verb)

  • realtime – check that a packet was sent before sending the next one

  • return_packets – return the sent packets

  • socket – the socket to use (default is conf.L3socket(kargs))

  • iface – the interface to send the packets on

  • monitor – (not on linux) send in monitor mode



send_options: Dict[str, Any] = {'verbose': 0}
send_options_list = ['iface', 'inter', 'loop', 'verbose', 'socket']
send_reply(reply: _T, send_function: Callable[[...], None] | None = None) None[source]
sniff() None[source]
sniff_bg() None[source]
sniff_options: Dict[str, Any] = {'store': 0}
sniff_options_list = ['store', 'iface', 'count', 'promisc', 'filter', 'type', 'prn', 'stop_filter', 'opened_socket']
class scapy.ansmachine.AnsweringMachineTCP(self, port=80, cls=<class 'scapy.packet.Raw'>)[source]

Bases: AnsweringMachine[Packet]

An answering machine that use the classic socket.socket to answer multiple TCP clients

TYPE = 1
close() None[source]
make_reply(req: Packet, address: Any | None = None) Packet[source]
parse_options(port: int = 80, cls: ~typing.Type[~scapy.packet.Packet] = <class 'scapy.packet.Raw'>) None[source]
sniff() None[source]
sniff_bg() None[source]
class scapy.ansmachine.AnsweringMachineUDP(self, port=80, cls=<class 'scapy.packet.Raw'>)[source]

Bases: AnsweringMachineTCP

An answering machine that use the classic socket.socket to answer multiple UDP clients

TYPE = 2
class scapy.ansmachine.ReferenceAM(name: str, bases: Tuple[type, ...], dct: Dict[str, Any])[source]

Bases: type