Answering machines.

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

Bases: Generic[_T]

filter: Optional[str] = None
function_name = ''
is_request(req: Packet) int[source]
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: Optional[Callable[[...], None]] = None, address: Optional[Any] = None) None[source]
run(*args: Any, **kargs: Any) None[source]
static send_function(x: Union[List[Packet], Packet, SetGen[Packet], _PacketList[Packet]], iface: Optional[Union[NetworkInterface, str]] = None, **kargs: Any) Optional[PacketList][source]

Send packets at layer 3

  • 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.verbose)

  • 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: Optional[Callable[[...], None]] = None) None[source]
sniff() 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 clients

close() None[source]
make_reply(req: Packet, address: Optional[Any] = None) Packet[source]
optam0: Dict[str, Any]
optam1: Dict[str, Any]
optam2: Dict[str, Any]
optsend: Dict[str, Any]
optsniff: Dict[str, Any]
parse_options(port: int = 80, cls: ~typing.Type[~scapy.packet.Packet] = <class 'scapy.packet.Raw'>) None[source]
sniff() None[source]
class scapy.ansmachine.AnsweringMachineUtils[source]

Bases: object

static reverse_packet(req: Packet, mirror_src: bool = False) Optional[Packet][source]
class scapy.ansmachine.ReferenceAM(name: str, bases: Tuple[type, ...], dct: Dict[str, Any])[source]

Bases: _Generic_metaclass