scapy.scapypipes

class scapy.scapypipes.FDSourceSink(fd: ObjectPipe[Any], name: Optional[Any] = None)[source]

Bases: Source

Use a file descriptor as source and sink

   +-------------+
>>-|             |->>
   |             |
 >-|-[file desc]-|->
   +-------------+
deliver() None[source]
fileno() int[source]
push(msg: str) None[source]
class scapy.scapypipes.Inject3Sink(iface: Optional[Union[NetworkInterface, str]] = None, name: Optional[str] = None)[source]

Bases: InjectSink

start() None[source]
class scapy.scapypipes.InjectSink(iface: Optional[Union[NetworkInterface, str]] = None, name: Optional[str] = None)[source]

Bases: Sink

Packets received on low input are injected to an interface

   +-----------+
>>-|           |->>
   |           |
 >-|--[iface]  |->
   +-----------+
push(msg: Packet) None[source]
start() None[source]
stop() None[source]
class scapy.scapypipes.RdpcapSource(fname: str, name: Optional[Any] = None)[source]

Bases: Source

Read packets from a PCAP file send them to low exit.

   +----------+
>>-|          |->>
   |          |
 >-|  [pcap]--|->
   +----------+
deliver() None[source]
fileno() int[source]
start() None[source]
stop() None[source]
class scapy.scapypipes.SniffSource(iface: Optional[str] = None, filter: Optional[Any] = None, socket: Optional[SuperSocket] = None, name: Optional[Any] = None)[source]

Bases: Source

Read packets from an interface and send them to low exit.

   +-----------+
>>-|           |->>
   |           |
 >-|  [iface]--|->
   +-----------+

If neither of the iface or socket parameters are specified, then Scapy will capture from the first network interface.

Parameters
  • iface – A layer 2 interface to sniff packets from. Mutually exclusive with the socket parameter.

  • filter – Packet filter to use while capturing. See L2listen. Not used with socket parameter.

  • socket – A SuperSocket to sniff packets from.

deliver() None[source]
fileno() int[source]
start() None[source]
stop() None[source]
class scapy.scapypipes.TCPConnectPipe(addr: str = '', port: int = 0, name: Optional[str] = None)[source]

Bases: Source

TCP connect to addr:port and use it as source and sink

   +-------------+
>>-|             |->>
   |             |
 >-|-[addr:port]-|->
   +-------------+
deliver() None[source]
fileno() int[source]
push(msg: Packet) None[source]
start() None[source]
stop() None[source]
class scapy.scapypipes.TCPListenPipe(addr: str = '', port: int = 0, name: Optional[str] = None)[source]

Bases: TCPConnectPipe

TCP listen on [addr:]port and use first connection as source and sink; send peer address to high output

   +------^------+
>>-|    +-[peer]-|->>
   |   /         |
 >-|-[addr:port]-|->
   +-------------+
deliver() None[source]
push(msg: Packet) None[source]
start() None[source]
class scapy.scapypipes.TriggerDrain(f: Callable[[...], None], name: Optional[str] = None)[source]

Bases: Drain

Pass messages and trigger when a condition is met

   +------^------+
>>-|-[condition]-|->>
   |      |      |
 >-|-[condition]-|->
   +-------------+
high_push(msg: str) None[source]
push(msg: str) None[source]
class scapy.scapypipes.TriggeredMessage(msg: str, name: Optional[Any] = None)[source]

Bases: Drain

Send a preloaded message when triggered and trigger in chain

   +------^------+
>>-|      | /----|->>
   |      |/     |
 >-|-[ message ]-|->
   +------^------+
on_trigger(trigmsg: bool) None[source]
class scapy.scapypipes.TriggeredQueueingValve(start_state: bool = True, name: Optional[Any] = None)[source]

Bases: Drain

Let messages alternatively pass or queued, changing on trigger

   +------^-------+
>>-|-[pass/queue]-|->>
   |      |       |
 >-|-[pass/queue]-|->
   +------^-------+
high_push(msg: str) None[source]
on_trigger(msg: bool) None[source]
push(msg: str) None[source]
start() None[source]
class scapy.scapypipes.TriggeredSwitch(start_state: bool = True, name: Optional[Any] = None)[source]

Bases: Drain

Let messages alternatively high or low, changing on trigger

   +------^------+
>>-|-\    |    /-|->>
   |  [up/down]  |
 >-|-/    |    \-|->
   +------^------+
high_push(msg: str) None[source]
on_trigger(msg: bool) None[source]
push(msg: str) None[source]
class scapy.scapypipes.TriggeredValve(start_state: bool = True, name: Optional[Any] = None)[source]

Bases: Drain

Let messages alternatively pass or not, changing on trigger

   +------^------+
>>-|-[pass/stop]-|->>
   |      |      |
 >-|-[pass/stop]-|->
   +------^------+
high_push(msg: str) None[source]
on_trigger(msg: bool) None[source]
push(msg: str) None[source]
class scapy.scapypipes.UDPClientPipe(addr: str = '', port: int = 0, name: Optional[str] = None)[source]

Bases: TCPConnectPipe

UDP send packets to addr:port and use it as source and sink Start trying to receive only once a packet has been send

   +-------------+
>>-|             |->>
   |             |
 >-|-[addr:port]-|->
   +-------------+
deliver() None[source]
push(msg: Packet) None[source]
start() None[source]
class scapy.scapypipes.UDPDrain(ip: str = '127.0.0.1', port: int = 1234)[source]

Bases: Drain

UDP payloads received on high entry are sent over UDP

   +-------------+
>>-|--[payload]--|->>
   |      X      |
 >-|----[UDP]----|->
   +-------------+
high_push(msg: Packet) None[source]
push(msg: Packet) None[source]
class scapy.scapypipes.UDPServerPipe(addr: str = '', port: int = 0, name: Optional[str] = None)[source]

Bases: TCPListenPipe

UDP bind to [addr:]port and use as source and sink Use (ip, port) from first received IP packet as destination for all data

   +------^------+
>>-|    +-[peer]-|->>
   |   /         |
 >-|-[addr:port]-|->
   +-------------+
deliver() None[source]
push(msg: Packet) None[source]
start() None[source]
class scapy.scapypipes.WiresharkSink(name: Optional[Any] = None, linktype: Optional[int] = None, args: Optional[List[str]] = None)[source]

Bases: WrpcapSink

Streams Packet from the low entry to Wireshark.

Packets are written into a pcap stream (like WrpcapSink), and streamed to a new Wireshark process on its stdin.

Wireshark is run with the -ki - arguments, which cause it to treat stdin as a capture device. Arguments in args will be appended after this.

Extends WrpcapSink.

   +----------+
>>-|          |->>
   |          |
 >-|--[pcap]  |->
   +----------+
Parameters
args

Additional arguments for the Wireshark process.

This must be either None (the default), or a list of str.

This attribute has no effect after calling PipeEngine.start().

See wireshark(1) for more details.

start() None[source]
class scapy.scapypipes.WrpcapSink(fname: str, name: Optional[str] = None, linktype: Optional[int] = None)[source]

Bases: Sink

Writes Packet on the low entry to a pcap file. Ignores all messages on the high entry.

Note

Due to limitations of the pcap format, all packets must be of the same link type. This class will not mutate packets to conform with the expected link type.

   +----------+
>>-|          |->>
   |          |
 >-|--[pcap]  |->
   +----------+
Parameters
  • fname (str) – Filename to write packets to.

  • linktype (None or int) – See linktype.

linktype

Set an explicit link-type (DLT_) for packets. This must be an int or None.

This is the same as the wrpcap() linktype parameter.

If None (the default), the linktype will be auto-detected on the first packet. This field will not be updated with the result of this auto-detection.

This attribute has no effect after calling PipeEngine.start().

push(msg: Packet) None[source]
start() None[source]
stop() None[source]