scapy.pipetool

class scapy.pipetool.AutoSource(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Source

deliver() None[source]
class scapy.pipetool.CLIFeeder(name: Optional[str] = None)[source]

Bases: scapy.pipetool.AutoSource

Send messages from python command line:

   +--------+
>>-|        |->>
   | send() |
 >-|   `----|->
   +--------+
close() None[source]
send(msg: str) int[source]
class scapy.pipetool.CLIHighFeeder(name: Optional[str] = None)[source]

Bases: scapy.pipetool.CLIFeeder

Send messages from python command line to high output:

   +--------+
>>-|   .----|->>
   | send() |
 >-|        |->
   +--------+
send(msg: Any) int[source]
class scapy.pipetool.ConsoleSink(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Sink

Print messages on low and high entries to stdout

   +-------+
>>-|--.    |->>
   | print |
 >-|--'    |->
   +-------+
high_push(msg: str) None[source]
push(msg: str) None[source]
class scapy.pipetool.DownDrain(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Drain

Repeat messages from high entry to low exit:

   +-------+
>>-|--.    |->>
   |   \   |
 >-|    `--|->
   +-------+
high_push(msg: Any) None[source]
push(msg: Any) None[source]
class scapy.pipetool.Drain(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Pipe

Repeat messages from low/high entries to (resp.) low/high exits

   +-------+
>>-|-------|->>
   |       |
 >-|-------|->
   +-------+
high_push(msg: Any) None[source]
push(msg: Any) None[source]
class scapy.pipetool.PeriodicSource(msg: Union[Iterable[Any], Any], period: int, period2: int = 0, name: Optional[str] = None)[source]

Bases: scapy.pipetool.ThreadGenSource

Generage messages periodically on low exit:

   +-------+
>>-|       |->>
   | msg,T |
 >-|  `----|->
   +-------+
generate() None[source]
class scapy.pipetool.Pipe(name: Optional[str] = None)[source]

Bases: object

start() None[source]
stop() None[source]
class scapy.pipetool.PipeEngine(*pipes: scapy.pipetool.Pipe)[source]

Bases: scapy.automaton.ObjectPipe[str]

add(*pipes: scapy.pipetool.Pipe) None[source]
add_one_pipe(pipe: scapy.pipetool.Pipe) None[source]
get_pipe_list(pipe: scapy.pipetool.Pipe) Set[Any][source]
graph(**kargs: Any) None[source]
classmethod list_pipes() None[source]
classmethod list_pipes_detailed() None[source]
pipes: Dict[str, Type[Pipe]] = {'AutoSource': <class 'scapy.pipetool.AutoSource'>, 'CLIFeeder': <class 'scapy.pipetool.CLIFeeder'>, 'CLIHighFeeder': <class 'scapy.pipetool.CLIHighFeeder'>, 'ConsoleSink': <class 'scapy.pipetool.ConsoleSink'>, 'DownDrain': <class 'scapy.pipetool.DownDrain'>, 'Drain': <class 'scapy.pipetool.Drain'>, 'FDSourceSink': <class 'scapy.scapypipes.FDSourceSink'>, 'Inject3Sink': <class 'scapy.scapypipes.Inject3Sink'>, 'InjectSink': <class 'scapy.scapypipes.InjectSink'>, 'PeriodicSource': <class 'scapy.pipetool.PeriodicSource'>, 'Pipe': <class 'scapy.pipetool.Pipe'>, 'QueueSink': <class 'scapy.pipetool.QueueSink'>, 'RawConsoleSink': <class 'scapy.pipetool.RawConsoleSink'>, 'RdpcapSource': <class 'scapy.scapypipes.RdpcapSource'>, 'Sink': <class 'scapy.pipetool.Sink'>, 'SniffSource': <class 'scapy.scapypipes.SniffSource'>, 'Source': <class 'scapy.pipetool.Source'>, 'TCPConnectPipe': <class 'scapy.scapypipes.TCPConnectPipe'>, 'TCPListenPipe': <class 'scapy.scapypipes.TCPListenPipe'>, 'TermSink': <class 'scapy.pipetool.TermSink'>, 'ThreadGenSource': <class 'scapy.pipetool.ThreadGenSource'>, 'TransformDrain': <class 'scapy.pipetool.TransformDrain'>, 'TriggerDrain': <class 'scapy.scapypipes.TriggerDrain'>, 'TriggerSink': <class 'scapy.pipetool.TriggerSink'>, 'TriggeredMessage': <class 'scapy.scapypipes.TriggeredMessage'>, 'TriggeredQueueingValve': <class 'scapy.scapypipes.TriggeredQueueingValve'>, 'TriggeredSwitch': <class 'scapy.scapypipes.TriggeredSwitch'>, 'TriggeredValve': <class 'scapy.scapypipes.TriggeredValve'>, 'UDPClientPipe': <class 'scapy.scapypipes.UDPClientPipe'>, 'UDPDrain': <class 'scapy.scapypipes.UDPDrain'>, 'UDPServerPipe': <class 'scapy.scapypipes.UDPServerPipe'>, 'UpDrain': <class 'scapy.pipetool.UpDrain'>, 'WiresharkSink': <class 'scapy.scapypipes.WiresharkSink'>, 'WrpcapSink': <class 'scapy.scapypipes.WrpcapSink'>}
run() None[source]
start() None[source]
stop(_cmd: str = 'X') None[source]
wait_and_stop() None[source]
class scapy.pipetool.QueueSink(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Sink

Collects messages on the low and high entries into a Queue. Messages are dequeued with recv(). Both high and low entries share the same Queue.

   +-------+
>>-|--.    |->>
   | queue |
 >-|--'    |->
   +-------+
high_push(msg: Any) None[source]
push(msg: Any) None[source]
recv(block: bool = True, timeout: Optional[int] = None) Optional[Any][source]

Reads the next message from the queue.

If no message is available in the queue, returns None.

Parameters
  • block (bool) – Blocks execution until a packet is available in the queue. Defaults to True.

  • timeout (None, int or float) – Controls how long to wait if block=True. If None (the default), this method will wait forever. If a non-negative number, this is a number of seconds to wait before giving up (and returning None).

class scapy.pipetool.RawConsoleSink(name: Optional[str] = None, newlines: bool = True)[source]

Bases: scapy.pipetool.Sink

Print messages on low and high entries, using os.write

   +-------+
>>-|--.    |->>
   | write |
 >-|--'    |->
   +-------+
Parameters

newlines (bool) – Include a new-line character after printing each packet. Defaults to True.

high_push(msg: str) None[source]
push(msg: str) None[source]
class scapy.pipetool.Sink(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Pipe

Does nothing; interface to extend for custom sinks.

All sinks have the following constructor parameters:

Parameters

name (str) – a human-readable name for the element

high_push(msg: Any) None[source]

Called by PipeEngine when there is a new message for the high entry.

Parameters

msg – The message data

Returns

None

Return type

None

push(msg: Any) None[source]

Called by PipeEngine when there is a new message for the low entry.

Parameters

msg – The message data

Returns

None

Return type

None

class scapy.pipetool.Source(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Pipe, scapy.automaton.ObjectPipe[Any]

deliver() None[source]
exhausted() bool[source]
class scapy.pipetool.TermSink(name: Optional[str] = None, keepterm: bool = True, newlines: bool = True, openearly: bool = True)[source]

Bases: scapy.pipetool.Sink

Prints messages on the low and high entries, on a separate terminal (xterm or cmd).

   +-------+
>>-|--.    |->>
   | print |
 >-|--'    |->
   +-------+
Parameters
  • keepterm (bool) – Leave the terminal window open after stop() is called. Defaults to True.

  • newlines (bool) – Include a new-line character after printing each packet. Defaults to True.

  • openearly (bool) – Automatically starts the terminal when the constructor is called, rather than waiting for start(). Defaults to True.

high_push(msg: str) None[source]
push(msg: str) None[source]
start() None[source]
stop() None[source]
class scapy.pipetool.ThreadGenSource(name: Optional[str] = None)[source]

Bases: scapy.pipetool.AutoSource

generate() None[source]
start() None[source]
stop() None[source]
class scapy.pipetool.TransformDrain(f: Callable[[Any], None], name: Optional[str] = None)[source]

Bases: scapy.pipetool.Drain

Apply a function to messages on low and high entry:

   +-------+
>>-|--[f]--|->>
   |       |
 >-|--[f]--|->
   +-------+
high_push(msg: Any) None[source]
push(msg: Any) None[source]
class scapy.pipetool.TriggerSink(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Sink

on_trigger(msg: Any) None[source]
class scapy.pipetool.UpDrain(name: Optional[str] = None)[source]

Bases: scapy.pipetool.Drain

Repeat messages from low entry to high exit:

   +-------+
>>-|    ,--|->>
   |   /   |
 >-|--'    |->
   +-------+
high_push(msg: Any) None[source]
push(msg: Any) None[source]