scapy.automaton

Automata with states, transitions and actions.

class scapy.automaton.ATMT[source]

Bases: object

ACTION = 'Action'
CONDITION = 'Condition'
IOEVENT = 'I/O event'
exception NewStateRequested(state_func, automaton, *args, **kargs)[source]

Bases: Exception

action_parameters(*args, **kargs)[source]
run()[source]
RECV = 'Receive condition'
STATE = 'State'
TIMEOUT = 'Timeout condition'
static action(cond, prio=0)[source]
static condition(state, prio=0)[source]
static ioevent(state, name, prio=0, as_supersocket=None)[source]
static receive_condition(state, prio=0)[source]
static state(initial=0, final=0, stop=0, error=0)[source]
static timeout(state, timeout)[source]
class scapy.automaton.Automaton(*args, **kargs)[source]

Bases: object

exception AutomatonError(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonException

exception AutomatonException(msg, state=None, result=None)[source]

Bases: Exception

exception AutomatonStopped(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonException

exception Breakpoint(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonStopped

exception CommandMessage(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonException

exception ErrorState(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonException

exception InterceptionPoint(msg, state=None, result=None, packet=None)[source]

Bases: scapy.automaton.Automaton.AutomatonStopped

exception Singlestep(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonStopped

exception Stuck(msg, state=None, result=None)[source]

Bases: scapy.automaton.Automaton.AutomatonException

accept_packet(pkt=None, wait=False)[source]
actions = {}
add_breakpoints(*bps)[source]
add_interception_points(*ipts)[source]
conditions = {}
debug(lvl, msg)[source]
forcestop()[source]
initial_states = []
ioevents = {}
ionames = []
iosupersockets = []
master_filter(pkt)[source]
my_send(pkt)[source]
next()[source]
parse_args(debug=0, store=1, **kargs)[source]
recv_conditions = {}
reject_packet(wait=False)[source]
remove_breakpoints(*bps)[source]
remove_interception_points(*ipts)[source]
restart(*args, **kargs)[source]
run(resume=None, wait=True)[source]
runbg(resume=None, wait=False)[source]
send(pkt)[source]
start(*args, **kargs)[source]
state = None
states = {}
stop()[source]
stop_states = []
timeout = {}
class scapy.automaton.Automaton_metaclass(name, bases, dct)[source]

Bases: type

build_graph()[source]
graph(**kargs)[source]
class scapy.automaton.Message(**args)[source]

Bases: object

class scapy.automaton.ObjectPipe[source]

Bases: scapy.automaton.SelectableObject, io.BufferedIOBase

check_recv()[source]
close()[source]
fileno()[source]
flush()[source]
read(n=0)[source]
recv(n=0)[source]
static select(sockets, remain=0.05)[source]
send(obj)[source]
write(obj)[source]
class scapy.automaton.SelectableObject[source]

Bases: object

DEV: to implement one of those, you need to add 2 things to your object: - add “check_recv” function - call “self.call_release” once you are ready to be read

You can set the __selectable_force_select__ to True in the class, if you want to # noqa: E501 force the handler to use fileno(). This may only be usable on sockets created using # noqa: E501 the builtin socket API.

call_release(arborted=False)[source]

DEV: Must be call when the object becomes ready to read. Relesases the lock of _wait_non_ressources

check_recv()[source]

DEV: will be called only once (at beginning) to check if the object is ready.

register_hook(hook)[source]

DEV: When call_release() will be called, the hook will also

wait_return(callback)[source]

Entry point of SelectableObject: register the callback

class scapy.automaton.SelectableSelector(inputs, remain)[source]

Bases: object

Select SelectableObject objects.

inputs: objects to process remain: timeout. If 0, return []. customTypes: types of the objects that have the check_recv function.

process()[source]

Entry point of SelectableSelector

scapy.automaton.select_objects(inputs, remain)[source]

Select SelectableObject objects. Same than: select.select([inputs], [], [], remain) But also works on Windows, only on SelectableObject.

Parameters
  • inputs – objects to process

  • remain – timeout. If 0, return [].