scapy.scapypipes module

class scapy.scapypipes.ConvertPipe(low_type=None, high_type=None, name=None)

Bases: scapy.pipetool.Drain

Packets sent on entry are converted to another type of packet.

   +-------------+
>>-|--[convert]--|->>
   |             |
 >-|--[convert]--|->
   +-------------+

See Packet.convert_packet.

high_push(msg)
push(msg)
class scapy.scapypipes.FDSourceSink(fd, name=None)

Bases: scapy.pipetool.Source

Use a file descriptor as source and sink

   +-------------+
>>-|             |->>
   |             |
 >-|-[file desc]-|->
   +-------------+
deliver()
fileno()
push(msg)
class scapy.scapypipes.Inject3Sink(iface=None, name=None)

Bases: scapy.scapypipes.InjectSink

start()
class scapy.scapypipes.InjectSink(iface=None, name=None)

Bases: scapy.pipetool.Sink

Packets received on low input are injected to an interface

   +-----------+
>>-|           |->>
   |           |
 >-|--[iface]  |->
   +-----------+
push(msg)
start()
stop()
class scapy.scapypipes.RdpcapSource(fname, name=None)

Bases: scapy.pipetool.Source

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

   +----------+
>>-|          |->>
   |          |
 >-|  [pcap]--|->
   +----------+
check_recv()

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

deliver()
fileno()
start()
stop()
class scapy.scapypipes.SniffSource(iface=None, filter=None, socket=None, name=None)

Bases: scapy.pipetool.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.
check_recv()

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

deliver()
fileno()
start()
stop()
class scapy.scapypipes.TCPConnectPipe(addr='', port=0, name=None)

Bases: scapy.pipetool.Source

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

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

Bases: scapy.scapypipes.TCPConnectPipe

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

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

Bases: scapy.pipetool.Drain

Pass messages and trigger when a condition is met

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

Bases: scapy.pipetool.Drain

Send a preloaded message when triggered and trigger in chain

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

Bases: scapy.pipetool.Drain

Let messages alternatively pass or queued, changing on trigger

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

Bases: scapy.pipetool.Drain

Let messages alternatively high or low, changing on trigger

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

Bases: scapy.pipetool.Drain

Let messages alternatively pass or not, changing on trigger

   +------^------+
>>-|-[pass/stop]-|->>
   |      |      |
 >-|-[pass/stop]-|->
   +------^------+
high_push(msg)
on_trigger(msg)
push(msg)
class scapy.scapypipes.UDPDrain(ip='127.0.0.1', port=1234)

Bases: scapy.pipetool.Drain

UDP payloads received on high entry are sent over UDP

   +-------------+
>>-|--[payload]--|->>
   |      X      |
 >-|----[UDP]----|->
   +-------------+
high_push(msg)
push(msg)
class scapy.scapypipes.WiresharkSink(name=None, linktype=None, args=None)

Bases: scapy.scapypipes.WrpcapSink

Packets received on low input are pushed to Wireshark.

   +----------+
>>-|          |->>
   |          |
 >-|--[pcap]  |->
   +----------+
start()
class scapy.scapypipes.WrpcapSink(fname, name=None, linktype=None)

Bases: scapy.pipetool.Sink

Packets received on low input are written to PCAP file

   +----------+
>>-|          |->>
   |          |
 >-|--[pcap]  |->
   +----------+
push(msg)
start()
stop()