Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
wlanpi-profiler / opt / wlanpi-profiler / lib / python3.7 / site-packages / scapy / __pycache__ / scapypipes.cpython-37.pyc
Size: Mime:
B

ìŸ]¥&'¶ã@sddlmZddlZddlZddlmZmZddlmZm	Z	m
Z
ddlmZddl
mZddlmZmZmZGdd	„d	eƒZGd
d„deƒZGdd
„d
e
ƒZGdd„deƒZGdd„de
ƒZGdd„deƒZGdd„de	ƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGd d!„d!e	ƒZGd"d#„d#e	ƒZ Gd$d%„d%e	ƒZ!Gd&d'„d'e	ƒZ"Gd(d)„d)e	ƒZ#Gd*d+„d+e	ƒZ$dS),é)Úprint_functionN)ÚQueueÚEmpty)ÚSourceÚDrainÚSink)Úconf)Úraw)ÚContextManagerSubprocessÚ
PcapReaderÚ
PcapWriterc@sBeZdZdZddd„Zdd„Zdd„Zd	d
„Zdd„Zd
d„Z	dS)ÚSniffSourcea¡Read packets from an interface and send them to low exit.

    .. code::

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

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

    :param iface: A layer 2 interface to sniff packets from. Mutually
                  exclusive with the ``socket`` parameter.
    :param filter: Packet filter to use while capturing. See ``L2listen``.
                   Not used with ``socket`` parameter.
    :param socket: A ``SuperSocket`` to sniff packets from.
    NcCs8tj||d|s|r"|r"tdƒ‚||_||_||_dS)N)Únamez;iface and filter options are mutually exclusive with socket)rÚ__init__Ú
ValueErrorÚsÚifaceÚfilter)ÚselfrrÚsocketr©rúŽ/build/wlanpi-profiler-SHjkbd/wlanpi-profiler-1.0.8/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/scapy/scapypipes.pyr&szSniffSource.__init__cCs|jstj|j|jd|_dS)N)rr)rrZL2listenrr)rrrrÚstart1szSniffSource.startcCs|jr|j ¡dS)N)rÚclose)rrrrÚstop5szSniffSource.stopcCs
|j ¡S)N)rÚfileno)rrrrr9szSniffSource.filenocCsdS)NTr)rrrrÚ
check_recv<szSniffSource.check_recvcCs@y |j ¡}|dk	r| |¡Wntk
r:d|_YnXdS)NT)rÚrecvÚ_sendÚEOFErrorÚis_exhausted)rZpktrrrÚdeliver?s
zSniffSource.deliver)NNNN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrrrrr!rrrrr
s
r
c@sBeZdZdZddd„Zdd„Zdd„Zd	d
„Zdd„Zd
d„Z	dS)ÚRdpcapSourcez¼Read packets from a PCAP file send them to low exit.

    .. code::

         +----------+
      >>-|          |->>
         |          |
       >-|  [pcap]--|->
         +----------+
    NcCs$tj||d||_t|jƒ|_dS)N)r)rrÚfnamerÚf)rr'rrrrrTszRdpcapSource.__init__cCst|jƒ|_d|_dS)NF)rr'r(r )rrrrrYszRdpcapSource.startcCs|j ¡dS)N)r(r)rrrrr]szRdpcapSource.stopcCs
|j ¡S)N)r(r)rrrrr`szRdpcapSource.filenocCsdS)NTr)rrrrrcszRdpcapSource.check_recvcCs8y|j ¡}| |¡Wntk
r2d|_YnXdS)NT)r(rrrr )rÚprrrr!fs

zRdpcapSource.deliver)N)
r"r#r$r%rrrrrr!rrrrr&Hs

r&c@s2eZdZdZddd„Zdd„Zdd„Zd	d
„ZdS)Ú
InjectSinkzÇPackets received on low input are injected to an interface

    .. code::

         +-----------+
      >>-|           |->>
         |           |
       >-|--[iface]  |->
         +-----------+
    NcCs&tj||d|dkrtj}||_dS)N)r)rrrr)rrrrrrrzszInjectSink.__init__cCstj|jd|_dS)N)r)rZL2socketrr)rrrrr€szInjectSink.startcCs|j ¡dS)N)rr)rrrrrƒszInjectSink.stopcCs|j |¡dS)N)rÚsend)rÚmsgrrrÚpush†szInjectSink.push)NN)r"r#r$r%rrrr-rrrrr*ns


r*c@seZdZdd„ZdS)ÚInject3SinkcCstj|jd|_dS)N)r)rZL3socketrr)rrrrr‹szInject3Sink.startN)r"r#r$rrrrrr.Šsr.c@s2eZdZdZddd„Zdd„Zdd„Zd	d
„ZdS)Ú
WrpcapSinka2
    Writes :py:class:`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.

    .. code::

         +----------+
      >>-|          |->>
         |          |
       >-|--[pcap]  |->
         +----------+

    :param fname: Filename to write packets to.
    :type fname: str
    :param linktype: See :py:attr:`linktype`.
    :type linktype: None or int

    .. py:attribute:: linktype

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

        This is the same as the :py:func:`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 :py:meth:`PipeEngine.start`.
    NcCs$tj||d||_d|_||_dS)N)r)rrr'r(Úlinktype)rr'rr0rrrrµszWrpcapSink.__init__cCst|j|jd|_dS)N)r0)rr'r0r()rrrrr»szWrpcapSink.startcCs|jr|j ¡|j ¡dS)N)r(Úflushr)rrrrr¾s
zWrpcapSink.stopcCs|r|j |¡dS)N)r(Úwrite)rr,rrrr-ÃszWrpcapSink.push)NN)r"r#r$r%rrrr-rrrrr/s
$
r/c@s"eZdZdZddd„Zdd„ZdS)Ú
WiresharkSinkaô
    Streams :py:class:`Packet` from the low entry to Wireshark.

    Packets are written into a ``pcap`` stream (like :py:class:`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 :py:attr:`args` will be
    appended after this.

    Extends :py:mod:`WrpcapSink`.

    .. code::

         +----------+
      >>-|          |->>
         |          |
       >-|--[pcap]  |->
         +----------+

    :param linktype: See :py:attr:`WrpcapSink.linktype`.
    :type linktype: None or int
    :param args: See :py:attr:`args`.
    :type args: None or list[str]

    .. py:attribute:: 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 :py:meth:`PipeEngine.start`.

        See :manpage:`wireshark(1)` for more details.
    NcCstj|d||d||_dS)N)r'rr0)r/rÚargs)rrr0r4rrrríszWiresharkSink.__init__c	Csbttjjƒ:tjjddg}|jr.| |j¡tj|tjddd}WdQRX|j	|_
t |¡dS)Nz-Slkiú-)ÚstdinÚstdoutÚstderr)
r
rÚprogZ	wiresharkr4ÚextendÚ
subprocessÚPopenÚPIPEr6r'r/r)rr4ÚprocrrrrñszWiresharkSink.start)NNN)r"r#r$r%rrrrrrr3Ès#
r3c@s*eZdZdZddd„Zdd„Zdd	„Zd
S)ÚUDPDrainzÌUDP payloads received on high entry are sent over UDP

    .. code::

         +-------------+
      >>-|--[payload]--|->>
         |      X      |
       >-|----[UDP]----|->
         +-------------+
    ú	127.0.0.1éÒcCst |¡||_||_dS)N)rrÚipÚport)rrBrCrrrrs
zUDPDrain.__init__cCsJddlm}m}||krF||jdkrF||krF||j}| t|ƒ¡dS)Nr)ÚIPÚUDPé)Úscapy.layers.inetrDrEÚprotoÚpayloadÚ
_high_sendr	)rr,rDrErIrrrr-s
z
UDPDrain.pushcCs<ddlm}m}||jd|d|jd|}| |¡dS)Nr)rDrE)ÚdstiÒ)ZsportÚdport)rGrDrErBrCr)rr,rDrEr)rrrÚ	high_pushszUDPDrain.high_pushN)r@rA)r"r#r$r%rr-rMrrrrr?s

r?c@s2eZdZdZddd„Zdd„Zdd„Zd	d
„ZdS)ÚFDSourceSinkz¿Use a file descriptor as source and sink

    .. code::

         +-------------+
      >>-|             |->>
         |             |
       >-|-[file desc]-|->
         +-------------+
    NcCstj||d||_dS)N)r)rrÚfd)rrOrrrrr-szFDSourceSink.__init__cCs|j |¡dS)N)rOr2)rr,rrrr-1szFDSourceSink.pushcCs
|j ¡S)N)rOr)rrrrr4szFDSourceSink.filenocCs| |j ¡¡dS)N)rrOÚread)rrrrr!7szFDSourceSink.deliver)N)r"r#r$r%rr-rr!rrrrrN!s


rNc@sFeZdZdZdZddd„Zdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dS)ÚTCPConnectPipezÍTCP connect to addr:port and use it as source and sink

    .. code::

         +-------------+
      >>-|             |->>
         |             |
       >-|-[addr:port]-|->
         +-------------+
    TÚrNcCs$tj||d||_||_d|_dS)N)r)rrÚaddrrCrO)rrSrCrrrrrHszTCPConnectPipe.__init__cCs"t ¡|_|j |j|jf¡dS)N)rrOÚconnectrSrC)rrrrrNs
zTCPConnectPipe.startcCs|jr|j ¡dS)N)rOr)rrrrrRszTCPConnectPipe.stopcCs|j |¡dS)N)rOr+)rr,rrrr-VszTCPConnectPipe.pushcCs
|j ¡S)N)rOr)rrrrrYszTCPConnectPipe.filenocCsDy|j d¡}Wn tjk
r0| ¡‚YnX|r@| |¡dS)Ni)rOrrÚerrorrr)rr,rrrr!\szTCPConnectPipe.deliver)rRrN)r"r#r$r%Ú__selectable_force_select__rrrr-rr!rrrrrQ;s

rQc@s6eZdZdZdZddd„Zdd	„Zd
d„Zdd
„ZdS)Ú
TCPListenPipeaTCP listen on [addr:]port and use first connection as source and sink;
    send peer address to high output

    .. code::

         +------^------+
      >>-|    +-[peer]-|->>
         |   /         |
       >-|-[addr:port]-|->
         +-------------+
    TrRrNcCs"t ||||¡d|_tƒ|_dS)NF)rQrÚ	connectedrÚq)rrSrCrrrrrtszTCPListenPipe.__init__cCsHd|_t ¡|_|j tjtjd¡|j |j|jf¡|j 	d¡dS)NFé)
rXrrOÚ
setsockoptÚ
SOL_SOCKETÚSO_REUSEADDRÚbindrSrCÚlisten)rrrrrys

zTCPListenPipe.startcCs$|jr|j |¡n|j |¡dS)N)rXrOr+rYÚput)rr,rrrr-€szTCPListenPipe.pushcCs¼|jrHy|j d¡}Wn tjk
r6| ¡‚YnX|r¸| |¡np|j ¡\}}| |¡|j 	¡||_d|_| 
|¡x6y|j |jj
dd¡Wq‚tk
r²PYq‚Xq‚WdS)NiTF)Úblock)rXrOrrrUrrÚacceptrJrÚ_triggerr+rYÚgetr)rr,rOÚfrmrrrr!†s&


zTCPListenPipe.deliver)rRrN)	r"r#r$r%rVrrr-r!rrrrrWfs
rWc@s2eZdZdZd
dd„Zdd„Zd	d
„Zdd„ZdS)Ú
UDPClientPipeaUDP send packets to addr:port and use it as source and sink
    Start trying to receive only once a packet has been send

    .. code::

         +-------------+
      >>-|             |->>
         |             |
       >-|-[addr:port]-|->
         +-------------+
    rRrNcCst ||||¡d|_dS)NF)rQrrX)rrSrCrrrrrªszUDPClientPipe.__init__cCs0t tjtj¡|_|j |j|jf¡d|_dS)NT)rÚAF_INETÚ
SOCK_DGRAMrOrTrSrCrX)rrrrr®szUDPClientPipe.startcCs|j |¡dS)N)rOr+)rr,rrrr-³szUDPClientPipe.pushcCsN|js
dSy|j d¡}Wn tjk
r:| ¡‚YnX|rJ| |¡dS)Ni)rXrOrrrUrr)rr,rrrr!¶szUDPClientPipe.deliver)rRrN)r"r#r$r%rrr-r!rrrrrfs

rfc@s2eZdZdZd
dd„Zdd„Zd	d
„Zdd„ZdS)Ú
UDPServerPipeaUDP bind to [addr:]port and use as source and sink
    Use (ip, port) from first received IP packet as destination for all data

    .. code::

         +------^------+
      >>-|    +-[peer]-|->>
         |   /         |
       >-|-[addr:port]-|->
         +-------------+
    rRrNcCst ||||¡d|_dS)N)rWrÚ_destination)rrSrCrrrrrÏszUDPServerPipe.__init__cCs*t tjtj¡|_|j |j|jf¡dS)N)rrgrhrOr^rSrC)rrrrrÓszUDPServerPipe.startcCs(|jr|j ||j¡n|j |¡dS)N)rjrOÚsendtorYr`)rr,rrrr-×szUDPServerPipe.pushcCsÄ|jrHy|j d¡}Wn tjk
r6| ¡‚YnX|rÀ| |¡nx|j d¡\}}|rf| |¡||_| |¡| 	|¡x>y"|j
jdd}|j ||j¡Wq‚t
k
rºPYq‚Xq‚WdS)NiF)ra)rjrOrrrUrrÚrecvfromrcrJrYrdrkr)rr,Údestrrrr!Ýs(


zUDPServerPipe.deliver)rRrN)r"r#r$r%rrr-r!rrrrriÂs

ric@s"eZdZdZddd„Zdd„ZdS)ÚTriggeredMessagezÓSend a preloaded message when triggered and trigger in chain

    .. code::

         +------^------+
      >>-|      | /----|->>
         |      |/     |
       >-|-[ message ]-|->
         +------^------+
    NcCstj||d||_dS)N)r)rrr,)rr,rrrrrszTriggeredMessage.__init__cCs&| |j¡| |j¡| |¡dS)N)rr,rJrc)rZtrigmsgrrrÚ
on_triggerszTriggeredMessage.on_trigger)N)r"r#r$r%rrorrrrrnõs

rnc@s*eZdZdZd	dd„Zdd„Zdd„ZdS)
ÚTriggerDrainzÈPass messages and trigger when a condition is met

    .. code::

         +------^------+
      >>-|-[condition]-|->>
         |      |      |
       >-|-[condition]-|->
         +-------------+
    NcCstj||d||_dS)N)r)rrr()rr(rrrrrszTriggerDrain.__init__cCs&| |¡}|r| |¡| |¡dS)N)r(rcr)rr,Úvrrrr-s

zTriggerDrain.pushcCs&| |¡}|r| |¡| |¡dS)N)r(rcrJ)rr,rqrrrrM!s

zTriggerDrain.high_push)N)r"r#r$r%rr-rMrrrrrps

rpc@s2eZdZdZddd„Zdd„Zdd	„Zd
d„ZdS)
ÚTriggeredValvezÎLet messages alternatively pass or not, changing on trigger

.. code::

         +------^------+
      >>-|-[pass/stop]-|->>
         |      |      |
       >-|-[pass/stop]-|->
         +------^------+
    TNcCstj||d||_dS)N)r)rrÚopened)rÚstart_staterrrrr4szTriggeredValve.__init__cCs|jr| |¡dS)N)rsr)rr,rrrr-8szTriggeredValve.pushcCs|jr| |¡dS)N)rsrJ)rr,rrrrM<szTriggeredValve.high_pushcCs|jdN_| |¡dS)NT)rsrc)rr,rrrro@szTriggeredValve.on_trigger)TN)r"r#r$r%rr-rMrorrrrrr(s


rrc@s:eZdZdZddd„Zdd„Zdd	„Zd
d„Zdd
„ZdS)ÚTriggeredQueueingValvezÚLet messages alternatively pass or queued, changing on trigger

    .. code::

         +------^-------+
      >>-|-[pass/queue]-|->>
         |      |       |
       >-|-[pass/queue]-|->
         +------^-------+
    TNcCs tj||d||_tƒ|_dS)N)r)rrrsrrY)rrtrrrrrQszTriggeredQueueingValve.__init__cCstƒ|_dS)N)rrY)rrrrrVszTriggeredQueueingValve.startcCs&|jr| |¡n|j d|f¡dS)NT)rsrrYr`)rr,rrrr-YszTriggeredQueueingValve.pushcCs&|jr| |¡n|j d|f¡dS)NF)rsrrYr`)rr,rrrrM_sz TriggeredQueueingValve.high_pushcCsj|jdN_| |¡xLy|jjdd\}}Wntk
rFPYqX|rX| |¡q| |¡qWdS)NTF)ra)rsrcrYrdrrrJ)rr,Úlowrrrroes
z!TriggeredQueueingValve.on_trigger)TN)	r"r#r$r%rrr-rMrorrrrruEs

ruc@s.eZdZdZd
dd„Zdd„ZeZdd	„ZdS)ÚTriggeredSwitchzÒLet messages alternatively high or low, changing on trigger

    .. code::

         +------^------+
      >>-|-\    |    /-|->>
         |  [up/down]  |
       >-|-/    |    \-|->
         +------^------+
    TNcCstj||d||_dS)N)r)rrrv)rrtrrrrr€szTriggeredSwitch.__init__cCs |jr| |¡n
| |¡dS)N)rvrrJ)rr,rrrr-„szTriggeredSwitch.pushcCs|jdN_| |¡dS)NT)rvrc)rr,rrrro‹szTriggeredSwitch.on_trigger)TN)r"r#r$r%rr-rMrorrrrrwts


rwc@s*eZdZdZd	dd„Zdd„Zdd„ZdS)
ÚConvertPipezùPackets sent on entry are converted to another type of packet.

    .. code::

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

    See ``Packet.convert_packet``.
    NcCstj||d||_||_dS)N)r)rrÚlow_typeÚ	high_type)rryrzrrrrrszConvertPipe.__init__cCs |jr|j |¡}| |¡dS)N)ryÚconvert_packetr)rr,rrrr-¢szConvertPipe.pushcCs |jr|j |¡}| |¡dS)N)rzr{rJ)rr,rrrrM§szConvertPipe.high_push)NNN)r"r#r$r%rr-rMrrrrrxs
rx)%Ú
__future__rrr;Zscapy.modules.six.moves.queuerrZscapy.pipetoolrrrZscapy.configrZscapy.compatr	Zscapy.utilsr
rrr
r&r*r.r/r3r?rNrQrWrfrirnrprrrurwrxrrrrÚ<module>s27&9<+7%3/