
    h7b                        d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZmZmZmZmZmZmZmZmZmZm Z   G d	 d
e	e!                   Z" G d de#          Z$ edd          Z% edd          Z& G d de$          Z' G d de'e	e                   Z( G d de'          Z) G d de'          Z* G d de*          Z+ G d de(          Z, G d de,          Z- G d d e*          Z. G d! d"e*          Z/ G d# d$e,          Z0 G d% d&e0          Z1 G d' d(e-          Z2 G d) d*e*          Z3 G d+ d,e*          Z4 G d- d.e)          Z5 G d/ d0e)          Z6 G d1 d2e)          Z7dS )3    N)LockThread)Message
ObjectPipeselect_objects)WINDOWS)log_runtimewarning)conf)get_temp_filedo_graph)AnyCallableDictIterableOptionalSetTupleUnionTypeTypeVarcastc                       e Zd Zi Zed             Zed             Zd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd ZddZd Zd ZdS )
PipeEnginec                     t          | j                                                  D ]?\  }}|j        pd}|r|                                d         }t          |dd|           @d S )N r   z>20z: )sortedpipesitems__doc__
splitlinesprint)clspnpcdocs       R/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/pipetool.py
list_pipeszPipeEngine.list_pipes(   s{     SY__..// 	* 	*FB*"C *nn&&q)CC())))		* 	*    c                     t          | j                                                  D ]9\  }}|j        rt	          d|d|j                   't	          d|z             :d S )Nz###### z
 z	###### %s)r   r   r   r    r"   )r#   r$   r%   s      r'   list_pipes_detailedzPipeEngine.list_pipes_detailed1   su     SY__..// 	( 	(FBz ("""bjj9::::kB&''''		( 	(r)   c                 6   t          j        | d           t                      | _        t                      | _        t                      | _        t                      | _         | j        |  t                      | _	        t                      | _
        d | _        d S )Nr   )r   __init__setactive_pipesactive_sourcesactive_drainsactive_sinks
_add_pipesr   thread_lockcommand_lockthread)selfr   s     r'   r-   zPipeEngine.__init__:   sw    D,///EE!ee UUEE66 FFr)   c                      |                     d          r|dd           j        v r fd}|S t          |          )Nspawn_   c                  \    j                  } || i |}                    |           |S N)r   add)argskargskpdnamer7   s       r'   fz!PipeEngine.__getattr__.<locals>.fK   s7    
5)A4)5))AHHQKKKHr)   )
startswithr   AttributeError)r7   attrrC   rB   s   `  @r'   __getattr__zPipeEngine.__getattr__F   se    ??8$$ 		HE
""      T"""r)   c                 *    |                                  S r<   )recvr7   s    r'   	_read_cmdzPipeEngine._read_cmdT   s    yy{{r)   c                 0    |                      |           d S r<   )sendr7   _cmds     r'   
_write_cmdzPipeEngine._write_cmdX   s    		$r)   c                 X   | j                             |           t          |t                    r| j                            |           t          |t
                    r| j                            |           t          |t                    r| j                            |           d S d S r<   )	r/   r=   
isinstanceSourcer0   Drainr1   Sinkr2   )r7   pipes     r'   add_one_pipezPipeEngine.add_one_pipe\   s    d###dF## 	*##D)))dE"" 	)""4(((dD!! 	(!!$'''''	( 	(r)   c                 F    fdt                      } ||           |S )Nc                     |                     |            | j        | j        z  | j        z  | j        z  D ]}||vr ||           d S r<   )r=   sourcessinkshigh_sources
high_sinks)rA   liqflattens      r'   r`   z)PipeEngine.get_pipe_list.<locals>.flattenh   s]     FF1IIIY(1>9ALH # #B;;GArNNN# #r)   )r.   )r7   rV   plr`   s      @r'   get_pipe_listzPipeEngine.get_pipe_listf   s>    	# 	# 	# 	# 	# UUb	r)   c                     t                      }|D ]}||                     |          z  }|| j        z  }|D ]}|                     |           |S r<   )r.   rb   r/   rW   )r7   r   ra   rA   r_   s        r'   r3   zPipeEngine._add_pipest   sl    UU 	( 	(A$$$Q'''BB
d 	! 	!Aa    	r)   c                 X   t          j        d           	 | j        D ]}|                                 | j        }|                    |            t          g           }d}d}|r0|rt          |          dk    rt          |d          }|D ]}|| u r^| 	                                }|dk    rd} n|dk    rd}-|dk    r | j        |z
  }|                    |            St          d	|           d||v r	 |                                 |                                r*|                    |           |                    |           # t          $ r%}	t          j        d
|j        |	           Y d }	~	d }	~	ww xY w|r|t          |          dk    n# t"          $ r Y nw xY w	 | j        D ]}|                                 	 | j                                         t          j        d           d S # | j                                         t          j        d           w xY w# 	 | j        D ]}|                                 	 | j                                         t          j        d           w # | j                                         t          j        d           w xY wxY w)NzPipe engine thread started.TF   g      ?XBAz3Unknown internal pipe engine command: %r. Ignoring.zpiping from %s failed: %szPipe engine thread stopped.)r	   debugr/   startr0   r=   r.   lenr   rK   r
   deliver	exhaustedremove	Exception	exceptionnameKeyboardInterruptstopr4   release)
r7   rA   rZ   rm   RUNSTOP_IF_EXHAUSTEDfdsfdcmdes
             r'   runzPipeEngine.run~   s<   7888*	A&  				)GKKBIC % 30 3CLL14D4D$Wc22 3 3BTzz"nn..#::"'C!E CZZ04-- CZZ&*&9I&EG#KK----# %1257 7 7 7w3JJLLL
  "||~~ 3 )b 1 1 1 'r 2 2 2  ) > > >'12M24'1> > > > > > > >> '!  30 3CLL14D4D4 ! 	 	 	D	A*  AFFHHHH  ((***!"?@@@@@  ((***!"?@@@@A*  AFFHHHH  ((***!"?@@@@  ((***!"?@@@@sx   C F 7E
?F 

E9E4/F 4E99F H( 
F$!H( #F$$H( (G6 6/H%(J)*I7	.J)7/J&&J)c                     | j                             d          r:t          | j        d          }d|_        |                                 || _        d S t          j        d           d S )NFzscapy.pipetool.PipeEnginetargetrq   TzPipe engine already running)	r4   acquirer   r{   daemonrj   r6   r	   ri   )r7   _ts     r'   rj   zPipeEngine.start   sg    ##E** 	=tx.IJJJBBIHHJJJDKKK;<<<<<r)   c                 2    |                      d           d S )Nrg   )rO   )rs   rJ   s    r'   wait_and_stopzPipeEngine.wait_and_stop   s    		s	r)   rf   c                 p   	 | j         5  | j        Y|                     |           | j                                         	 | j                                         n$# t          $ r Y nw xY wt          j        d           d d d            d S # 1 swxY w Y   d S # t          $ r t          d           Y d S w xY w)NzPipe engine thread not runningzInterrupted by user.)r5   r6   rP   joinr4   rt   ro   r	   ri   rr   r"   rN   s     r'   rs   zPipeEngine.stop   s<   	*" 	H 	H;*OOD)))K$$&&&(002222$     %&FGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H ! 	* 	* 	*())))))	*sX   B 6B AB
A'$B&A''B>B BB BB B54B5c                      | j         | }| j        5  | j        .|D ]}|                                 |                     d           d d d            d S # 1 swxY w Y   d S )Nrh   )r3   r5   r6   rj   rP   )r7   r   _pipesrA   s       r'   r=   zPipeEngine.add   s     %( 	% 	%{&  AGGIIII$$$		% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   6AAAc           	         ddg}| j         D ].}|                    dt          |          |j        fz             /|                    d           |                    d           | j         D ]@}|j        D ]6}|                    dt          |          t          |          fz             7A|                    d           |                    d           | j         D ]@}|j        D ]6}|                    dt          |          t          |          fz             7A|                    d           |                    d           | j         D ]@}|j        D ]6}|                    dt          |          t          |          fz             7A|                    d	           d
                    |          }t          |fi | d S )Nzdigraph "pipe" {z	node [shape=rectangle];z	"%i" [label="%s"];r   z"	edge [color=blue, arrowhead=vee];z	"%i" -> "%i";z'	edge [color=purple, arrowhead=veevee];z%	edge [color=red, arrowhead=diamond];}
)	r/   appendidrq   r[   r]   trigger_sinksr   r   )r7   r?   grA   shstsgraphs           r'   r   zPipeEngine.graph   s   !<?" 	? 	?AHH+r!uuafo=>>>>		6777" 	= 	=AW = =*beeRUU^;<<<<=		;<<<" 	> 	>Al > >*beeRVV_<====>		9:::" 	> 	>Ao > >*beeRVV_<====>			!  %     r)   N)rf   )__name__
__module____qualname__r   classmethodr(   r+   r-   rG   rK   rP   rW   rb   r3   r{   rj   r   rs   r=   r    r)   r'   r   r   %   s       E* * [* ( ( [(
 
 
# # #    ( ( (    -A -A -A^= = =  * * * * % % %! ! ! ! !r)   r   c                        e Zd Z fdZ xZS )	_PipeMetac           	          t          dt          t          |                               | |||                    }|t          j        |<   |S )Nz
Type[Pipe])r   superr   __new__r   r   )r#   rq   basesdctc	__class__s        r'   r   z_PipeMeta.__new__   sK     y#&&..sD%EEG G!"
r)   )r   r   r   r   __classcell__)r   s   @r'   r   r      s8        	 	 	 	 	 	 	 	 	r)   r   _SrU   )bound_TSTriggerSinkc                   Z    e Zd ZddZd Zd ZddZd Zd Zd Z	d	 Z
d
 Zd Zd Zd ZdS )PipeNc                    t                      | _        t                      | _        t                      | _        t                      | _        t                      | _        t                      | _        |d| j        j        z  }|| _	        d S )Nz%s)
r.   rZ   r[   r\   r]   trigger_sourcesr   r   r   rq   r7   rq   s     r'   r-   zPipe.__init__   sf    uuUU
EE%%"uu UU<4>23D			r)   c                 D    | j         D ]}|                    |           d S r<   )r[   pushr7   msgr   s      r'   _sendz
Pipe._send  s.     	 	AFF3KKKK	 	r)   c                 D    | j         D ]}|                    |           d S r<   )r]   	high_pushr   s      r'   
_high_sendzPipe._high_send  s2     	 	AKK	 	r)   c                 D    | j         D ]}|                    |           d S r<   )r   
on_triggerr   s      r'   _triggerzPipe._trigger  s3    # 	 	ALL	 	r)   c                 n    | j                             |           |j                            |            |S r<   r[   r=   rZ   r7   others     r'   __gt__zPipe.__gt__  s1    
u$r)   c                 n    | j                             |           |j                            |            |S r<   )r]   r=   r\   r   s     r'   
__rshift__zPipe.__rshift__   s4    E"""t$$$r)   c                 n    | j                             |           |j                            |            |S r<   )r   r=   r   r   s     r'   __xor__zPipe.__xor__&  s5    u%%%!!$'''r)   c                 6    t                               |           S r<   )object__hash__rJ   s    r'   r   zPipe.__hash__,  s    t$$$r)   c                 8    t                               | |          S r<   )r   __eq__r   s     r'   r   zPipe.__eq__0  s    }}T5)))r)   c                     t           j                            d                              | j                  }| j        s| j        r|d                    d          z  z  }| j        rS|                    d                              fd| j        D                                           d          z  }|                    d          z  }| j        rS|                    d                              d                              fd| j        D                       z  }|                    d	          z  }| j	        s| j
        r|d                    d          z  z  }| j	        rS|                    d                              fd
| j	        D                                           d          z  }|                    d          z  }| j
        rS|                    d                              d                              fd| j
        D                       z  }|                    d	          z  }| j        s| j        r|d                    d          z  z  }| j        rS|                    d                              fd| j        D                                           d          z  }|                    d          z  }| j        rS|                    d                              d                              fd| j        D                       z  }|                    d	          z  }|                    d          z  }|S )N<z %s[,c              3   L   K   | ]}                     |j                  V  d S r<   
field_namerq   .0r   cts     r'   	<genexpr>z Pipe.__repr__.<locals>.<genexpr>;  s1      1^1^A"--2G2G1^1^1^1^1^1^r)   >#c              3   L   K   | ]}                     |j                  V  d S r<   r   r   s     r'   r   z Pipe.__repr__.<locals>.<genexpr>@  s1      1\1\A"--2G2G1\1\1\1\1\1\r)   ]c              3   L   K   | ]}                     |j                  V  d S r<   r   r   s     r'   r   z Pipe.__repr__.<locals>.<genexpr>F  s1      1c1cA"--2G2G1c1c1c1c1c1cr)   >>c              3   L   K   | ]}                     |j                  V  d S r<   r   r   s     r'   r   z Pipe.__repr__.<locals>.<genexpr>K  s1      1a1aA"--2G2G1a1a1a1a1a1ar)   c              3   L   K   | ]}                     |j                  V  d S r<   r   r   s     r'   r   z Pipe.__repr__.<locals>.<genexpr>Q  s1      1f1fA"--2G2G1f1f1f1f1f1fr)   ^c              3   L   K   | ]}                     |j                  V  d S r<   r   r   s     r'   r   z Pipe.__repr__.<locals>.<genexpr>V  s1      1d1dA"--2G2G1d1d1d1d1d1dr)   )r   color_themepunct
layer_namerq   rZ   r[   r   field_valuer\   r]   r   r   )r7   r   r   s     @r'   __repr__zPipe.__repr__4  s   hhsmmmR]]49%=%=%=>< 		4: 		#&&A| 4rxx}}111^1^1^1^QUQ]1^1^1^^^^!~~c2224 4s###Az ^r~~c222!xx}}111\1\1\1\QUQ[1\1\1\\\\^ ^#A 		 		#&&A  5rxx}}111c1c1c1cQUQb1c1c1cccc!~~d3335 5s###A cr~~d333!xx}}111a1a1a1aQUQ`1a1a1aaaac c#A 		4#5 		#&&A# 4rxx}}111f1f1f1fQUQe1f1f1ffff!~~c2224 4s###A! fr~~c222!xx}}111d1d1d1dQUQc1d1d1ddddf f#A	RXXc]]r)   c                     d S r<   r   rJ   s    r'   rj   z
Pipe.start\      r)   c                     d S r<   r   rJ   s    r'   rs   z	Pipe.stop`  r   r)   r<   )r   r   r   r-   r   r   r   r   r   r   r   r   r   rj   rs   r   r)   r'   r   r      s        
 
 
 
  
  
   
      % % %* * *& & &P      r)   r   )	metaclassc                   (    e Zd ZddZd Zd Zd ZdS )rS   Nc                 v    t          j        | |           t                              | |           d| _        d S Nrq   F)r   r-   r   is_exhaustedr   s     r'   r-   zSource.__init__f  s9    D$'''d&&&!r)   c                     t                      S r<   )r   rJ   s    r'   _read_messagezSource._read_messagel  s    yyr)   c                 >    | j         }|                     |           d S r<   )r   r   r7   r   s     r'   rl   zSource.deliverp  s     

3r)   c                     | j         S r<   r   rJ   s    r'   rm   zSource.exhaustedu  s      r)   r<   )r   r   r   r-   r   rl   rm   r   r)   r'   rS   rS   e  sU        " " " "    
! ! ! ! !r)   rS   c                       e Zd ZdZd Zd ZdS )rT   zRepeat messages from low/high entries to (resp.) low/high exits

    .. code::

         +-------+
      >>-|-------|->>
         |       |
       >-|-------|->
         +-------+
    c                 0    |                      |           d S r<   r   r   s     r'   r   z
Drain.push      

3r)   c                 0    |                      |           d S r<   r   r   s     r'   r   zDrain.high_push      r)   Nr   r   r   r    r   r   r   r)   r'   rT   rT   z  s<        	 	      r)   rT   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	rU   z
    Does nothing; interface to extend for custom sinks.

    All sinks have the following constructor parameters:

    :param name: a human-readable name for the element
    :type name: str
    c                     dS )z
        Called by :py:class:`PipeEngine` when there is a new message for the
        low entry.

        :param msg: The message data
        :returns: None
        :rtype: None
        Nr   r   s     r'   r   z	Sink.push  	     	r)   c                     dS )z
        Called by :py:class:`PipeEngine` when there is a new message for the
        high entry.

        :param msg: The message data
        :returns: None
        :rtype: None
        Nr   r   s     r'   r   zSink.high_push  r   r)   c                 n    |j                             |            | j                            |           |S r<   r   r   s     r'   __lt__zSink.__lt__  s1    r)   c                 n    | j                             |           |j                            |            |S r<   )r\   r=   r]   r   s     r'   
__lshift__zSink.__lshift__  s5    e$$$T"""r)   c                     | |z	   || z	   |S r<   r   r   s     r'   __floordiv__zSink.__floordiv__  s    r)   c                     | |k     || k     |S r<   r   r   s     r'   __mod__zSink.__mod__  s    ur)   N)
r   r   r   r    r   r   r   r   r   r   r   r)   r'   rU   rU     sx         
 
 

 
 
          r)   c                       e Zd Zd ZdS )r   c                     d S r<   r   r   s     r'   r   zTriggerSink.on_trigger  r   r)   N)r   r   r   r   r   r)   r'   r   r     s#            r)   c                   .    e Zd ZddZd Zd Zd Zd ZdS )
AutoSourceNc                 >    t                               | |           d S Nr   )rS   r-   r   s     r'   r-   zAutoSource.__init__  s    4(((((r)   c                 6    t          j        | |ddf           d S NFr   rM   r   s     r'   	_gen_datazAutoSource._gen_data  s!    sE5122222r)   c                 6    t          j        | |ddf           d S NTFr	  r   s     r'   _gen_high_datazAutoSource._gen_high_data  s!    sD%011111r)   c                 0    t          j        | d           d S )N)NNTr	  rJ   s    r'   _exhaustzAutoSource._exhaust  s    011111r)   c                     |                                  \  }}}|r	 |r|                     |           d S |                     |           d S r<   )rI   r   r   )r7   r   highexhausts       r'   rl   zAutoSource.deliver  sT    !YY[[T7 	 	OOC     JJsOOOOOr)   r<   )r   r   r   r-   r
  r  r  rl   r   r)   r'   r  r    sd        ) ) ) )3 3 32 2 22 2 2    r)   r  c                   (    e Zd ZddZd Zd Zd ZdS )ThreadGenSourceNc                 L    t                               | |           d| _        d S r   )r  r-   ru   r   s     r'   r-   zThreadGenSource.__init__  s&    Dt,,,r)   c                     d S r<   r   rJ   s    r'   generatezThreadGenSource.generate  r   r)   c                 d    d| _         t          | j        d                                           d S )NTzscapy.pipetool.ThreadGenSourcer}   )ru   r   r  rj   rJ   s    r'   rj   zThreadGenSource.start  s1    dm4	6 	6 	66;egggggr)   c                     d| _         d S r  )ru   rJ   s    r'   rs   zThreadGenSource.stop  s    r)   r<   )r   r   r   r-   r  rj   rs   r   r)   r'   r  r    sU           
  > > >    r)   r  c                       e Zd ZdZd Zd ZdS )ConsoleSinkzPrint messages on low and high entries to ``stdout``

    .. code::

         +-------+
      >>-|--.    |->>
         | print |
       >-|--'    |->
         +-------+
    c                 D    t          dt          |          z              d S )Nr   r"   reprr   s     r'   r   zConsoleSink.push  s     cDIIor)   c                 D    t          dt          |          z              d S )Nr   r  r   s     r'   r   zConsoleSink.high_push  s!    dT#YYr)   Nr   r   r)   r'   r  r     s<        	 	           r)   r  c                   &    e Zd ZdZddZd Zd ZdS )RawConsoleSinka>  Print messages on low and high entries, using os.write

    .. code::

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

    :param newlines: Include a new-line character after printing each packet.
                     Defaults to True.
    :type newlines: bool
    NTc                 Z    t                               | |           || _        d| _        d S )Nr   re   )rU   r-   newlines_write_pipe)r7   rq   r#  s      r'   r-   zRawConsoleSink.__init__%  s-    d&&& r)   c                 x    | j         r|dz  }t          j        | j        |                    d                     d S Nr   utf8r#  oswriter$  encoder   s     r'   r   zRawConsoleSink.push+  <    = 	4KC
!3::f#5#566666r)   c                 x    | j         r|dz  }t          j        | j        |                    d                     d S r&  r(  r   s     r'   r   zRawConsoleSink.high_push1  r,  r)   NTr   r   r   r    r-   r   r   r   r)   r'   r!  r!    sP            7 7 77 7 7 7 7r)   r!  c                       e Zd ZdZd Zd ZdS )	CLIFeederzSend messages from python command line:

    .. code::

         +--------+
      >>-|        |->>
         | send() |
       >-|   `----|->
         +--------+
    c                 0    |                      |           dS Nre   )r
  r   s     r'   rM   zCLIFeeder.sendD  s    sqr)   c                     d| _         d S r.  r   rJ   s    r'   closezCLIFeeder.closeI  s     r)   N)r   r   r   r    rM   r5  r   r)   r'   r1  r1  8  s<        	 	  
! ! ! ! !r)   r1  c                       e Zd ZdZd ZdS )CLIHighFeederzSend messages from python command line to high output:

    .. code::

         +--------+
      >>-|   .----|->>
         | send() |
       >-|        |->
         +--------+
    c                 0    |                      |           dS r3  )r  r   s     r'   rM   zCLIHighFeeder.sendZ  s    C   qr)   N)r   r   r   r    rM   r   r)   r'   r7  r7  N  s-        	 	    r)   r7  c                        e Zd ZdZddZd ZdS )PeriodicSourcezGenerate messages periodically on low exit:

    .. code::

         +-------+
      >>-|       |->>
         | msg,T |
       >-|  `----|->
         +-------+
    r   Nc                     t                               | |           t          |t          t          t
          f          s	|g| _        n|| _        || _        || _        d S r  )	r  r-   rR   listr.   tupler   periodperiod2)r7   r   r>  r?  rq   s        r'   r-   zPeriodicSource.__init__l  sX      D 111#c5122 	uDHHDHr)   c                 
   | j         r{d}| j        D ]2}d}|                     |           t          j        | j                   3|rd| _        |                                  t          j        | j                   | j         yd S d S r  )	ru   r   r
  timesleepr>  r   r  r?  )r7   	empty_genms      r'   r  zPeriodicSource.generatev  s    h 		%IX ( (!	q!!!
4;''''  $(!Jt|$$$ h 		% 		% 		% 		% 		%r)   )r   N)r   r   r   r    r-   r  r   r)   r'   r:  r:  `  sA        	 	   % % % % %r)   r:  c                   Z    e Zd ZdZ	 	 ddZerd Zd Znd Zd Z	d	 Z
d
 Zd Zd Zd ZdS )TermSinka  
    Prints messages on the low and high entries, on a separate terminal (xterm
    or cmd).

    .. code::

         +-------+
      >>-|--.    |->>
         | print |
       >-|--'    |->
         +-------+

    :param keepterm: Leave the terminal window open after :py:meth:`~Pipe.stop`
                     is called. Defaults to True.
    :type keepterm: bool
    :param newlines: Include a new-line character after printing each packet.
                     Defaults to True.
    :type newlines: bool
    :param openearly: Automatically starts the terminal when the constructor is
                      called, rather than waiting for :py:meth:`~Pipe.start`.
                      Defaults to True.
    :type openearly: bool
    NTc                     t                               | |           || _        || _        || _        d| _        | j        r|                                  d S d S r   )rU   r-   keeptermr#  	openearlyopenedrj   )r7   rq   rH  r#  rI  s        r'   r-   zTermSink.__init__  s[     	d&&&  "> 	JJLLLLL	 	r)   c                 
   | j         sd| _         t                      | _        t          | j        d                                           | j        dn| j        | _        d| j        d| j                            dd          d}t          j        t          t          j        d	          |gt          j        
          }|                                \  }}t          |          | _        t!          d| j        z             d S d S )NTaScapyzW$app = Start-Process PowerShell -ArgumentList '-command &{$host.ui.RawUI.WindowTitle=\"z\";Get-Content \"\z\\z"\" -wait}' -passthru; echo $app.Id
powershell)stdoutzPID: %d)rJ  r   _TermSink__fopenr5  rq   replace
subprocessPopengetattrr   progPIPEcommunicateintpidr"   )r7   ry   procoutput_s        r'   _start_windowszTermSink._start_windows  s:   ; ,"(??TXs##))+++'+y'8GGdi		 sw  s|  s|  s|  ~B  ~F  ~N  ~N  OS  U[  ~\  ~\  ~\  ~\  ]!'	<88 &?   !,,..	v;;i$(*+++++#, ,r)   c                     | j         std| _        dd l}d}|j        j                            |d| j                  }|j        j                            |d           |j        j                            |           d S d S )NFr   re   )	rH  rJ  ctypeswindllkernel32OpenProcessr[  TerminateProcessCloseHandle)r7   rb  PROCESS_TERMINATEhandles       r'   _stop_windowszTermSink._stop_windows  s    = ;# $%!/;;<MuVZV^__&77CCC&226:::::; ;r)   c                    | j         sd| _         t          j                    \  }| _        t          j        |d           dg}| j        |                    d| j        g           | j        r|                    d           |                    dd|z  g           t          j
        |d          | _        t          j        |           d S d S )	NTxtermz-titlez-holdz-ezcat <&%dF)	close_fds)rJ  r)  rV   wdescset_inheritablerq   extendrH  r   rT  rU  r\  r5  )r7   rdescry   s      r'   _start_unixzTermSink._start_unix  s    ;  "$&GII!tz"5$///i9(JJ$)4555= (JJw'''

D*u"45666&,SEBBB	   r)   c                     | j         s;d| _        | j                                         | j                                         d S d S r  )rH  rJ  r\  killwaitrJ   s    r'   
_stop_unixzTermSink._stop_unix  sG    = !#	   	     ! !r)   c                 `    t           r|                                 S |                                 S r<   )r   r_  rr  rJ   s    r'   rj   zTermSink.start  s.     	&&&(((##%%%r)   c                 `    t           r|                                 S |                                 S r<   )r   rj  rv  rJ   s    r'   rs   zTermSink.stop  s,     	%%%'''??$$$r)   c                    | j         r|dz  }t          r@t          | j        d          }|                    |           |                                 d S t          j        | j        |                                           d S )Nr   rL  )	r#  r   rR  rQ  r*  r5  r)  rn  r+  )r7   r   rn  s      r'   _printzTermSink._print  sp    = 	IA 	-3''EKKNNNKKMMMMMHTZ,,,,,r)   c                 J    |                      t          |                     d S r<   rz  strr   s     r'   r   zTermSink.push       CHHr)   c                 J    |                      t          |                     d S r<   r|  r   s     r'   r   zTermSink.high_push  r~  r)   )NTTT)r   r   r   r    r-   r   r_  rj  rr  rv  rj   rs   rz  r   r   r   r)   r'   rF  rF    s         0 ;?	 	 	 	  6!	, 	, 	,*
	; 
	; 
	; 
	;	  	  	 	! 	! 	!& & &% % %	- 	- 	-      r)   rF  c                   .    e Zd ZdZddZd Zd Zd	dZdS )
	QueueSinka5  
    Collects messages on the low and high entries into a :py:class:`Queue`.
    Messages are dequeued with :py:meth:`recv`.
    Both high and low entries share the same :py:class:`Queue`.

    .. code::

         +-------+
      >>-|--.    |->>
         | queue |
       >-|--'    |->
         +-------+
    Nc                 n    t                               | |           t          j                    | _        d S r  )rU   r-   queueQueuer_   r   s     r'   r-   zQueueSink.__init__  s)    d&&&#(;==r)   c                 :    | j                             |           d S r<   r_   putr   s     r'   r   zQueueSink.push      

3r)   c                 :    | j                             |           d S r<   r  r   s     r'   r   zQueueSink.high_push  r  r)   Tc                 h    	 | j                             ||          S # t          j        $ r Y dS w xY w)a^  
        Reads the next message from the queue.

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

        :param block: Blocks execution until a packet is available in the
                      queue. Defaults to True.
        :type block: bool
        :param timeout: 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).
        :type timeout: None, int or float
        )blocktimeoutN)r_   getr  Empty)r7   r  r  s      r'   rI   zQueueSink.recv  sC     	6::E7:;;;{ 	 	 	44	s    11r<   )TN)r   r   r   r    r-   r   r   rI   r   r)   r'   r  r    sd         1 1 1 1
         r)   r  c                   &    e Zd ZdZddZd Zd ZdS )TransformDrainzApply a function to messages on low and high entry:

    .. code::

         +-------+
      >>-|--[f]--|->>
         |       |
       >-|--[f]--|->
         +-------+
    Nc                 L    t                               | |           || _        d S r  )rT   r-   rC   )r7   rC   rq   s      r'   r-   zTransformDrain.__init__@  s#    t$'''r)   c                 V    |                      |                     |                     d S r<   )r   rC   r   s     r'   r   zTransformDrain.pushE  s$    

466#;;r)   c                 V    |                      |                     |                     d S r<   )r   rC   r   s     r'   r   zTransformDrain.high_pushI  s$    s$$$$$r)   r<   r/  r   r)   r'   r  r  4  sP        	 	   
     % % % % %r)   r  c                       e Zd ZdZd Zd ZdS )UpDrainzRepeat messages from low entry to high exit:

    .. code::

         +-------+
      >>-|    ,--|->>
         |   /   |
       >-|--'    |->
         +-------+
    c                 0    |                      |           d S r<   r   r   s     r'   r   zUpDrain.pushZ  r   r)   c                     d S r<   r   r   s     r'   r   zUpDrain.high_push^  r   r)   Nr   r   r)   r'   r  r  N  s<        	 	      r)   r  c                       e Zd ZdZd Zd ZdS )	DownDrainzRepeat messages from high entry to low exit:

    .. code::

         +-------+
      >>-|--.    |->>
         |   \   |
       >-|    `--|->
         +-------+
    c                     d S r<   r   r   s     r'   r   zDownDrain.pusho  r   r)   c                 0    |                      |           d S r<   r   r   s     r'   r   zDownDrain.high_pushs  r   r)   Nr   r   r)   r'   r  r  c  s<        	 	      r)   r  )8r)  r  rT  rA  	threadingr   r   scapy.automatonr   r   r   scapy.constsr   scapy.errorr	   r
   scapy.configr   scapy.utilsr   r   typingr   r   r   r   r   r   r   r   r   r   r   r}  r   typer   r   r   r   rS   rT   rU   r   r  r  r  r!  r1  r7  r:  rF  r  r  r  r  r   r)   r'   <module>r     s   
			       " " " " " " " "         
 !           , , , , , , , ,       / / / / / / / /                         E! E! E! E! E!C E! E! E!P
 
 
 
 
 
 
 
 WT   ge=)))d d d d dY d d d dN! ! ! ! !T:c? ! ! !*    D   *7 7 7 7 74 7 7 7t    $          8    j   *         $      * 7  7  7  7  7T  7  7  7F! ! ! ! !
 ! ! !,    I   $!% !% !% !% !%_ !% !% !%H{ { { { {t { { {|/ / / / / / / /d% % % % %U % % %4    e   *         r)   