
    h                        U d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZ ddlZddlZddlZddlZddlmZ ddlmZ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m Z m!Z!m"Z"m#Z# dd	l$m%Z% d
ddZ&g dZ'd Z(d Z)d Z* e+             e,            ddfdZ-d Z. e)d          Z/ e*d          Z0e/r3 e1e/dz            Z2e!e1         e3d<    e1e/dz            Z4e!e1         e3d<   ndZ2dZ4d5                                Z6d Z7d4dZ8d4dZ9d4dZ:d4dZ;	 	 	 d5d Z<d! Z=d" Z>d# Z?d$ Z@d6d'ZAd7d(ZBd7d)ZCe#d*             ZDe#	 	 d8d+            ZD	 	 d8d,ZDd9d.ZEd7d/e!eF         d0e1fd1ZGdddejH        fd2ZIeJd3k    r eI             dS dS ):z&
Main module for interactive startup.
    N)zip_longest)choice)log_interactivelog_loadingScapy_Exception)DefaultThemeBlackAndWhiteapply_ipython_style)WINDOWS)AnyDictListOptionalUnionoverload)Literalztls.allz
msrpce.all)tlsmsrpce))z0Craft packets like it is your last day on earth.zLao-Tze)z#Craft packets like I craft my beer.zJean De Clerck)z$Craft packets before they craft you.Socrate)zCraft me if you can.z
IPv6 layer)z`To craft a packet, you have to be a packet, and learn how to swim in the wires and in the waves.zJean-Claude Van Damme)z,We are in France, we say Skappee. OK? Merci.zSebastien Chabal)z'Wanna support scapy? Star us on GitHub!zSatoshi Nakamoto)zI'll be back.zPython 2c                    t          j        t          j                            | |                    }|                                s*	 |                    dd           n# t          $ r Y d S w xY w |j        | 	                                S )Ni  T)modeexist_ok)
pathlibPathosenvirongetexistsmkdir	Exceptionjoinpathresolve)vardefaultcfpaths       N/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/main.py_probe_xdg_folderr(   D   s    <
sG4455D;;== 

	JJEDJ1111 	 	 	 44	 4="%%'''s   A   
A.-A.c                      t          dt          j                            t          j                            d          d          g| R  S )NXDG_CONFIG_HOME~.configr(   r   r&   join
expanduserr%   s    r'   _probe_config_folderr1   U   sI    
RW'',,i88 
       c                      t          dt          j                            t          j                            d          d          g| R  S )NXDG_CACHE_HOMEr+   z.cacher-   r0   s    r'   _probe_cache_folderr5   ^   sI    
RW'',,h77 
   r2   Tc                    t          j        |           }|                                st          j        d|            |dS 	 |j                                        s|j                            dd           t          sdt          j	        v rudt          j	        v rg	 t          j
        |j        t          t          j	        d                   t          t          j	        d                              n# t          $ r Y nw xY w|                    d          5 }|                    |           ddd           n# 1 swxY w Y   t          s~dt          j	        v rpdt          j	        v rb	 t          j
        |t          t          j	        d                   t          t          j	        d                              n# t          $ r Y nw xY wt          j        d|            n(# t          $ r t          j        d	| d
           Y dS w xY wt          j        d|            	 t          |           5 }t#          t%          |                                | d          ||           ddd           dS # 1 swxY w Y   dS # t(          $ r$}|r t          j        d| |           Y d}~dS d}~wt          $ r |r t          j        d|            Y dS w xY w)a  Read a config file: execute a python file while loading scapy, that
    may contain some pre-configured values.

    If _globals or _locals are specified, they will be updated with
    the loaded vars.  This allows an external program to use the
    function. Otherwise, vars are only available from inside the scapy
    console.

    Parameters:

    :param _globals: the globals() vars
    :param _locals: the locals() vars
    :param interactive: specified whether or not errors should be printed
    using the scapy console or raised.
    :param default: if provided, set a default value for the config file

    ex, content of a config.py file:
        'conf.verb = 42
'
    Manual loading:
        >>> _read_config_file("./config.py"))
        >>> conf.verb
        2

    z Config file [%s] does not exist.NT)parentsr   SUDO_UIDSUDO_GIDwz&Config file [%s] created with default.z&Config file [%s] could not be created.exc_infozLoading config file [%s]execz!Cannot read config file [%s] [%s]z+Error during evaluation of config file [%s])r   r   r   r   debugparentr   r   r   r   chownintr    openwriteOSErrorwarningr=   compilereadIOError	exception)	r%   _globals_localsinteractiver$   cf_pathfdcfgfes	            r'   _read_config_filerQ   g   s   6 l2G>> *<bAAA?F%	>((** $$TD$AAA"*,,"*,,#N
: 677
: 677   
 %   c"" "b!!!" " " " " " " " " " " " " " " bj((bj((HBJz233BJz233   
 !   DFKKKK 	 	 	 H")-/ / / /FF	 0"555""XX 			R00'  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
  H H H 	?QGGGGGGGGG " " " 	K 	" 	" 	" 	" 	" 	""s   AG  AC3 2G  3
D =G  ?D  G  D:.G  :D>>G  D>&G  )AF: 9G  :
GG  GG   !HHI: -3I- I: -I11I: 4I15I: :
KJ##%KKc                 "    | d         dk    o| dvS )z5Returns whether or not a variable should be imported.r   _)rangemap )ks    r'   _validate_localrX      s     Q43;41$444r2   scapyzprestart.pyDEFAULT_PRESTART_FILEz
startup.pyDEFAULT_STARTUP_FILEa  
# Scapy CLI 'pre-start' config file
# see https://scapy.readthedocs.io/en/latest/api/scapy.config.html#scapy.config.Conf
# for all available options

# default interpreter
conf.interactive_shell = "auto"

# color theme (DefaultTheme, BrightTheme, ColorOnBlackTheme, BlackAndWhite, ...)
conf.color_theme = DefaultTheme()

# disable INFO: tags related to dependencies missing
# log_loading.setLevel(logging.WARNING)

# force-use libpcap
# conf.use_pcap = True
c                  L    t          d           t          j        d           d S )NzUsage: scapy.py [-s sessionfile] [-c new_startup_file] [-p new_prestart_file] [-C] [-P] [-H]
Args:
	-H: header-less start
	-C: do not read startup file
	-P: do not read pre-startup file
r   )printsysexitrV   r2   r'   _usager`      s,    		/   HQKKKKKr2   c                    |t           j        }	 t          j        |           }d|j        v r9|j        d         D ])}||                    |           |j        |         ||<   *dS |j                                        D ]0\  }}t          |          r||                    |           |||<   1dS # t          $ r t          j	        d| d           Y dS w xY w)zLoads a Python module to make variables, objects and functions
available globally.

    The idea is to load the module using importlib, then copy the
symbols to the global symbol table.

    N__all__zLoading module %sTr;   )
builtins__dict__	importlibimport_moduleappenditemsrX   r    r   error)moduleglobals_dict	symb_listmodnamesyms         r'   _loadrp      s(    (J%f--$$Y/ 8 8($$T***%(\$%7T""8 8 !\//11 - -	c"4(( - ,!((...),L&	- -
  J J J16DIIIIIIIJs   AB2 &A
B2 2!CCc                 0    t          d| z   ||           dS )z[Loads a Scapy module to make variables, objects and functions
    available globally.

    zscapy.modules.rk   rl   N)rp   rn   rk   rl   s      r'   load_modulert     s2     

T
!#y: : : : : :r2   c                 b    t          dt                              | |           z   ||           dS )zaLoads a Scapy layer module to make variables, objects and functions
    available globally.

    zscapy.layers.rr   N)rp   LAYER_ALIASESr   rs   s      r'   
load_layerrw      sA     
/M--dD99
9#y: : : : : :r2   c                     	 t          j        d| z              t          d| z   ||           dS # t          $ r/}	 t	          | ||           n# t          $ r |w xY wY d}~dS d}~ww xY w)zLoads a Scapy contrib module to make variables, objects and
    functions available globally.

    If no contrib module can be found with the given name, try to find
    a layer module, since a contrib module may become a layer module.

    scapy.contrib.rr   N)re   rf   rp   ImportErrorrw   )rn   rk   rl   rP   s       r'   load_contribr{   *  s    
 04 7888%'9	> 	> 	> 	> 	> 	>   	t$0IG G G G G 	 	 	G	G G G G G Gs&   ,0 
A)AA$AA$$A)Fc                 r   | d} n"d| vrd| vr|                      d          s| dz  } g }t          j                            t          j                            t
                    d          }t          j        dk    r8t          j                            |d|           } t          j	        | d	
          }n4t          j                            ||           } t          j	        |           }|D ]}|
                    t          j        j        d                              d          d         }|                    d          rW|                     d          r
|dd         }dd|d}t          j        |d          5 }	|	D ]}
|
d         dk    r|
                    d          }|dk    r[|dz  }|
                    d|          }|
||                                         }|
|dz   d                                         }|||<   |d         dk    r n(|d         r|d         r|                    |            nddd           n# 1 swxY w Y   |r0|d         dk    rw|d         r|d         st'          d|z            |                    d            |r|S |D ]}t+          d |z             dS )!zShow the list of all existing contribs.

    :param name: filter to search the contribs
    :param ret: whether the function should return a dict instead of
        printing it
    :returns: None or a dictionary containing the results if ret=True
    Nz*.py*?z.pycontrib)      z**T)	recursive.zcontrib.   __ )descriptionstatusrn   replace)errorsr   #ry      =   r   skipr   z(Module %s is missing its contrib infos !c                     | d         S )Nrn   rV   )xs    r'   <lambda>zlist_contrib.<locals>.<lambda>|  s
    qy r2   )keyz1%(name)-20s: %(description)-40s status=%(status)s)endswithr   r&   r.   dirname__file__r^   version_infoglobiglobr   sep	partition
startswithiorB   findstriprg   r   sortr]   )rn   ret_debugresultsdir_pathiteratorfrm   descrN   linepqr   values                  r'   list_contribr   @  s%   & |	DS__T]]55I5I_Gw||BGOOH55yAAH
6!!w||HdD11:dd333w||Hd++:d## ? ?iiS))33J??B>>$ 	<< 	crc(C!R==WQy))) 	R  7c>>II.//66GA		#q))Aqs)//++C QL..00E %DI>V++E& 4> NN4(((E	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   	?H~''-( ?X ?% '8:='> ? ? ?LL((L)))
  	N 	NDELMMMMts   <B>II
	I
	c                     d| vri x| d<   | d<   i | d<   	 ddl m}  |            j                            |            dS # t          $ r Y dS w xY w)z)Updates IPython session with a custom one_ohOutInr   get_ipythonN)IPythonr   user_nsupdater    )sessionr   s     r'   update_ipython_sessionr     s     G*,,''''''$$W-----   s   (? 
AAc                      d t          j        dd          j                                                                        D             S )z+Load Scapy prestart and return all builtinsc                 8    i | ]\  }}t          |          ||S rV   rX   .0rW   vs      r'   
<dictcomp>z,_scapy_prestart_builtins.<locals>.<dictcomp>  <       Aq1	1  r2   r,   rY   re   rf   rd   copyrh   rV   r2   r'   _scapy_prestart_builtinsr     sK     +Iw??HMMOOUUWW   r2   c                      d t          j        dd          j                                                                        D             S )z"Load Scapy and return all builtinsc                 8    i | ]\  }}t          |          ||S rV   r   r   s      r'   r   z#_scapy_builtins.<locals>.<dictcomp>  r   r2   z.allrY   r   rV   r2   r'   _scapy_builtinsr     sK     +FG<<EJJLLRRTT   r2   c                      ddl m}  i }| j        j                                        D ]f\  }}|j        rZt          j        |         }|                    d |j	        
                                                                D                        g|S )z)Load Scapy exts and return their builtinsr   confc                 8    i | ]\  }}t          |          ||S rV   r   r   s      r'   r   z_scapy_exts.<locals>.<dictcomp>  s<       Aq"1%%1  r2   )scapy.configr   exts	all_specsrh   r$   r^   modulesr   rd   r   )r   resmodnamespecrm   s        r'   _scapy_extsr     s     "!!!!!
C,2244  < 	+g&CJJ  L--//5577     
 Jr2   r   c           	         ddl m} ddlm}m} | s&|j        } | s|                    d          x|_        } t          j        d|            |s1|j	        dv rddl
m}  |            j        }nt          j        d	         }|st          j        d
           dS |                    dg           }g d}|                                }	t%          |	          D ]}
|	|
         }|
d         dk    r|	|
= t'          |d          r|j                            d          r|	|
= It-          ||          r|	|
= ]|
|v s|
|v r|	|
= it-          |t.          t0          j        t0          j        f          r3|
d         dk    r#t          j        d|
t/          |                     |	|
= 	 t9          j        |           # t<          $ r' t          j        d|
t/          |                     Y w xY w	 t?          j         | | dz              n# tB          $ r Y nw xY wtE          j#        | d          }t9          j$        |	||           |%                                 dS )a  Save current Scapy session to the file specified in the fname arg.

    params:
     - fname: file to save the scapy session in
     - session: scapy session to use. If None, the console one will be used
     - pickleProto: pickle proto version (default: -1 = latest)r   )utils)r   	ConfClassT)keepzSaving session into [%s]ipython	ptipythonr   scapy_sessionzNo session found ?!N_scpybuiltins)r   r   r   rB   rS   
__module__r   z[%s] (%s) can't be saved.z.bakwb)&rY   r   r   r   r   r   get_temp_filer   infointeractive_shellr   r   r   rc   rd   ri   r   r   listhasattrr   r   
isinstancetypetypes
ModuleTypeFunctionTyperE   pickledumpsr    r   renamerD   gziprB   dumpclose)fnamer   pickleProtor   r   r   r   ignorehard_ignoreto_be_savedrW   ir   s                r'   save_sessionr     s    ,,,,,,,, B 	B#(#6#6D#6#A#AADL53U;;; 9!%===++++++!kmm+GG'8G 3444[["--F888K,,..K+ Q QNQ43;;AQ%% 	Q!,*A*A)*L*L 	QA9%% 	QA&[[A,,AD%"2E4FGHH 	Qts{{'(CQQPPPAQQ Q Q Q'(CQQPPPPPQ
	%((((    		%A
KQ,,,GGIIIIIs$   F22-G#"G#'H   
HHc                 
   ddl m} | |j        } 	 t          j        t          j        | d                    }nC# t          $ r6 	 t          j        t          | d                    }n# t          $ r  w xY wY nw xY wt          j	        d         |
                    fdd         D                                                         
                    |           t                     t          j        d|            dS )	zLoad current Scapy session from the file specified in the fname arg.
    This will erase any existing session.

    params:
     - fname: file to load the scapy session fromr   r   Nrbr   c                 "    i | ]}||         S rV   rV   )r   rW   r   s     r'   r   z load_session.<locals>.<dictcomp>  s     JJJaaq!JJJr2   r   zLoaded session [%s])r   r   r   r   loadr   rB   rH   rc   rd   r   clearr   r   r   r   r   sr   s      @r'   load_sessionr     s.    "!!!!!}K	%..//   	D--..AA 	 	 		 A %o6MHHJJJJ=+IJJJKKK=)))*E22222s'   ': 
A:"A('A:(A44A:9A:c                 F   ddl m} | |j        } 	 t          j        t          j        | d                    }n2# t          $ r% t          j        t          | d                    }Y nw xY wt          j	        d         }|
                    |           t          |           dS )zUpdate current Scapy session from the file specified in the fname arg.

    params:
     - fname: file to load the scapy session fromr   r   Nr   r   )r   r   r   r   r   r   rB   rH   rc   rd   r   r   r   s       r'   update_sessionr     s     "!!!!!}+K	%..// + + +KUD))**+%o6M=)))))s   '9 ,A('A(c                     d S NrV   session_namemydictr   s      r'   init_sessionr  %  	     	Dr2   c                     d S r  rV   r  s      r'   r  r  .  r  r2   c                    ddl m} i }t                      }|                    t	                                 | rU	 t          j        |            	 	 t          j        t          j
        | d                    }n2# t          $ r% t          j        t          | d                    }Y nw xY wt          j        d|            n# t          $ r d}t          j        ||            Y nit           $ r t          j        d|            Y nIt"          $ r t          j        d|            Y n)w xY w# t$          $ r t          j        d|            Y nw xY w|r4d	|v r(|                    |d	                    | |_        ||d	<   n| |_        n| |_        d	|i}nd	|i}|                    |           |                                |d
<   |t,          j        d<   |4t,          j        d                             |           t1          |           |r|S d S )Nr   r   r   zUsing existing session [%s]z5Error opening Python3 pickled session on Python2 [%s]zError opening session [%s]z-Error opening session [%s]. Attribute missingzNew session [%s]r   r   r   )r   r   r   r   r   r   statr   r   r   rB   rH   r   r   
ValueErrorri   EOFErrorAttributeErrorrD   	configurer   keysrc   rd   r   )r  r  r   r   SESSIONscapy_builtinsmsgs          r'   r  r  7  s   
 "!!!!!G %&&N +--(((  !	EGL!!!ED$k$)L$*G*GHHGG D D D$k$|T*B*BCCGGGD !>MMMM 5 5 5M!#|44444 N N N!">MMMMM! E E E! #67CE E E E EE  	? 	? 	?/>>>>>	?$  		%  wv///+"&+'DLtnGG4.NN>"""-2244GO)0Ho&/*11&999v&&&
 4sM   D) 'A: 9C :,B)&C (B))C !D&%D&D&%D&)E
EN   c                    |                      d          }|dz  }g }g }d }|r|r( ||          t          |d                   z   dz
  |k    r)|                    |                    d                     U|                    dd                    |          z             g }||r-|                    dd                    |          z             g }|                    dd|t          |          z
  dz
  z  d	|           |S )
zhThis function processes a quote and returns a string that is ready
to be used in the fancy banner.

        c                 Z    t          d | D                       t          |           z   dz
  S )Nc              3   4   K   | ]}t          |          V  d S r  )len)r   elts     r'   	<genexpr>z/_prepare_quote.<locals>._len.<locals>.<genexpr>  s(      ,,3s88,,,,,,r2   r   )sumr  )r   s    r'   _lenz_prepare_quote.<locals>._len  s/    ,,t,,,,,s4yy81<<r2   r   r   z   | %sz   | r   z-- )splitr  rg   popr.   )quoteauthormax_len_quotelinescur_liner  s          r'   _prepare_quoter%  w  s-    [[FqLGEH= = =   	DDNNS^^;a?7JJOOFJJqMM***Y(!3!33444    Y(!3!33444	LLL3'CKK*?!*C#D#D#DffMNNNLr2   minireturnc           
         ddl m ddlm} |  |            pddk    }n| }g d}g d}d	d	d
ddj        z  d
dd
dd
g
}|r!|}d |dd         D             }d	g|z   d	gz   }nQt          t                    \  }}|                    t          ||d                     |	                    d
           d
                    d t          fd|D             fd|D             d	          D                       S )zq
    Generates the fancy Scapy banner

    :param mini: if set, force a mini banner or not. Otherwise detect
    r   r   )get_terminal_widthNT   K   )&                                      z&                     aSPY//YASa       z&             apyyyyCY//////////YCa    z&            sY//////YSpcs  scpCY//Pp  z& ayp ayyyyyyySCP//Pp           syY//C z& AYAsAYYYYYYYY///Ps              cY//Sz&         pCCCCY//p          cSSps y//Yz&         SPPPP///a          pP///AC//Yz&              A//A            cyP////Cz&              p///Ac            sC///az&              P////YCpc           A//Az&       scccccp///pSP///p          p//Yz&      sY/////////y  caa           S//Pz&       cayCyayP//Ya              pY/Yaz&        sY/PsY////YCc          aC//Yp z&         sc  sccaCY//PCypaapyCP//YSs  z&                  spCPY//////YPSps    z&                       ccaacs         r,  )	z      .SYPACCCSASYY  zP /SCS/CCS        ACSz       /A          ACz     A/PS       /SPPSz        YP        (SCz       SPS/A.      SCz   Y/PACC          PPz    PY*AYC        CAAz         YYCY//SCYP  r   z   |z   | Welcome to Scapyz   | Version %sz$   | https://github.com/secdev/scapyz   | Have fun!c                 "    g | ]}|d d         S )r   NrV   )r   r   s     r'   
<listcomp>z$get_fancy_banner.<locals>.<listcomp>  s     666ae666r2   r   r   '   )r!  
c              3   &   K   | ]\  }}||z   V  d S r  rV   )r   logobanners      r'   r  z#get_fancy_banner.<locals>.<genexpr>  s;        &$v     r2   c              3   L   K   | ]}j                             |          V  d S r  )color_themer2  r   r   r   s     r'   r  z#get_fancy_banner.<locals>.<genexpr>  s4      >>TT""4((>>>>>>r2   c              3   L   K   | ]}j                             |          V  d S r  )r5  successr6  s     r'   r  z#get_fancy_banner.<locals>.<genexpr>  s4      CCT%%d++CCCCCCr2   )	fillvalue)r   r   scapy.utilsr)  versionr   QUOTESextendr%  rg   r.   r   )	r&  r)  mini_bannerthe_logothe_logo_mini
the_bannerr  r   r   s	           @r'   get_fancy_bannerrB    s    "!!!!!......|))++1rb8  H.
 
 
M 	
DL(.J  " 66Z"%5666
TJ&"-

vv.CCCDDD&!!!99  *5>>>>X>>>CCCC
CCC+
 +
 +
     r2   c                    t          j        d           ddlm} d|_        t                      |_        |||_        t          }t          }d}|t          j        }	 t          j        |dd         d          }|d         D ]\  }	}
|	dk    rt                       |	d	k    r d
|_        d|_        t           j        |_        @|	dk    r|
}I|	dk    r|
}R|	dk    rd}[|	dk    r|
}d|	dk    rd}m|	dk    rt%          d|j        dz
            |_        t'          |d                   dk    r0t          j        dd                    |d                   z            nD# t          j        $ r2}t-          j        |           t          j        d           Y d}~nd}~ww xY wt          j        dd         t          _        |r$t3          |dt5                      t6                     t9          || d          }|rt3          |d|           |j        rt;                      }n
d|j        z  }|
|dz  }||z  }|j        dvrt-          j         d           d|_        dgdgdgddgd}|j        dk    r_d D ]A}	 tC          j"        |           |#                                |_         n+# tH          $ r Y >w xY wt-          j         d!           d"|_        |j        |v rS||j                 D ]E}	 tC          j"        |           # tH          $ r! t-          j         d#|z             d"|_        Y Bw xY w|j        d"k    rd$g}tJ          r)|&                    d%           tO                      |_        ns	 ddl(}ddl)}|*                    |+                    |&          j,                   |-                    d'           n&# tH          $ r |.                    dd(           Y nw xY wt-          j/        d)d*                    |          dt'          |          dk    rd+nd,d-           d. }|j        d/v r[ddl0}|j        d0k    r>|d1|j1        z  z   }	 dd2l2m} d |d          z   }n# tH          $ r d3}Y nw xY w|d4|z  z  }nf|d1|j1        z  z   }nX|j        dk    r1	 dd2l2m} d |d          z   }n# tH          $ r d3}Y nw xY w|d5|z  z   }n|j        dk    rddl3}|d6|j1        z  z   }|j        d/v r|dz  }|j        d0k    rdd7l4m5} ndd7l0m5} 	 dd8l6m7}  |            }	 dd9l0m8}  |            stH          n=# tH          $ r0 ts          |j:        :           d
|j:        _;        d3|j:        _<        Y nw xY wt{          |j1        d                   d;k    r2d|j:        _>        d<|j        z  |j:        _?        |j@        |j+        _A        nd
|j:        _>        |jB        |jC        _D        ||jE        _F        i }|j        d0k    r||d=<   	  |dK||d>| n9# t          t          f$ r t          jJ        ||?           Y nw xY w# tH          $ rT t-          j         d@           	  |d
|dA|z   dBz   gC           n&# t          $ r t          jJ        ||?           Y nw xY wY nw xY w|j        dk    rKt-          j         dD           dd7lLm5} |dz  }t          |            |||jB        d<|j        z  |E           nT|j        dk    rddFlNmO}  |dGdHg||d3I           n1|j        d"k    rt          jJ        ||?           nt          dJ          |jQ        rt          |jQ        |           dS dS )Lz!
    Starts Scapy's console.
    alwaysr   r   TNr   zhs:Cc:Pp:d:Hz-hz-HFz-sz-cz-Cz-pz-Pz-d
   zToo many parameters : [%s]r  )rL   rK   r$   )r  r   )rL   rK   zWelcome to Scapy (%s)r0  )r   pythonptpythonr   bpythonautoz-Unknown conf.interactive_shell ! Using 'auto'rI  r   rH  rG  )r   rH  rG  r   )r   rH  rG  zONo alternative Python interpreters found ! Using standard Python shell instead.rF  z%s requested but not found !HistoryColors)	namespaceztab: completeAutoCompletionz Using the default Python shell: ,isarez
 disabled.c                 L    d| _         d| _        d| _        d| _        d| _        d S )NFT)show_status_barcomplete_while_typingenable_auto_suggestconfirm_exitshow_signature)repls    r'   ptpython_configurez$interact.<locals>.ptpython_configure~  s2      %%*"#' !"r2   r   r   z using IPython %s)r;  r   z and ptpython%sz using ptpython%sz using bpython %s)embed)Configr   )shellr  zScapy %sr  )configr   )r3  localzFtraitlets not available. Some Scapy shell features won't be available.z	print("""z"""))display_bannerr   
exec_linesz.ptpython support is currently partially broken)localshistory_filenametitler  )mainz-qz-i)argslocals_r3  welcome_messagezInvalid conf.interactive_shellrV   )Swarningssimplefilterr   r   rL   r   r5  logLevelr[   rZ   r^   argvgetoptr`   fancy_bannerverbloggingWARNINGmaxr  GetoptErrorr.   r   ri   r_   rQ   r   DEFAULT_PRESTARTr  rB  r;  r   rE   re   rf   lowerrz   r   rg   r	   rlcompleterreadlineset_completer	Completercompleteparse_and_bindinsertr   r   __version__importlib.metadatarH  ptpython.ipythonrY  traitlets.config.loaderrZ  r   r
   InteractiveShellEmbedrU  separate_inrA   
term_titleterm_title_formatipython_use_jediuse_jedihistfileHistoryAccessor	hist_fileInteractiveShellbanner1r  	TypeErrorcodeinteractr    ptpython.replr]   bpython.curtsiesrc  r
  r   r   )r  rj  mybannerloglevelr   STARTUP_FILEPRESTART_FILEr  optsoptparamr  r  banner_text_IMPORTSimpdisabledrt  ru  rX  r   r3  r;  ptpython_versionrH  rY  rZ  cfgr   _kwargss                                 r'   r  r    s\
    (### "!!!!!D#~~D 'L)ML|x}T!""X~66q' 	; 	;JCd{{$)!	 '$$# % $ #At}r'9 : :tAw<<!$,sxxQ/@/@@   
    #
 x|CH 
,..$		
 	
 	
 	
 <DAAAG 
	
 	
 	
 	
  =&((-<tx  &   	KLLL!' ;;L,	 H ''5 	. 	.C',,,),&    7   &.D"))D23 	2 	2C2',,,, 2 2 2#$BS$HIII)1&&&2
 )); 	5OOH%%%,D	5""""&&))G)<<E   ''8888 5 5 5#3444445 	""""H**55	
 	
 	
# # #$ !999![00 #69L#LLF&666666#&)<)<#<   & & &#%   &'*:::FF #69L#LLFF		:	-	-	"222222"WWZ%8%88 	" 	" 	"!	"25EEE		9	,	,2W5HHH !999$![00.......%%%%%%0	A666666 &((C
<//////"{}} &%%& < < < $#*CDDDD9>)68;)555< 7&q)**a//7;)4?I?C|@L); *.)>&&7<)4,0MC)+1C (G%44'9$A=S'==W===="I. A A A[@@@@@@A[  	A 	A 	A  A#(# . 7) CD    
  A A A[@@@@@@A	A` 
	:	-	- 	LMMM''''''$f!]t|+(		
 	
 	
 	
 	
 
	9	,	,222222		
 	
 	
 	
 	
 
	8	+	+[888889:::| ,T\7+++++, ,s   C?E F,(FF7-J&&
J32J3*K??(L*)L*,AN8 8 OO
Q Q.-Q.R) )R87R8X5 T1 17U+*U+:X 'X21X25ZY*)Z* Z
ZZZZ__main__)NN)NFF)r   Nr   r  )NF)r  )K__doc__rc   r   r^   r   rk  r  r   r   re   r   	itertoolsr   rn  r   r   rg  randomr   scapy.errorr   r   r   scapy.themesr   r	   r
   scapy.constsr   typingr   r   r   r   r   r   scapy.compatr   rv   r<  r(   r1   r5   globalsr`  rQ   rX   SCAPY_CONFIG_FOLDERSCAPY_CACHE_FOLDERstrrZ   __annotations__r[   r   rr  r`   rp   rt   rw   r{   r   r   r   r   r   r   r   r   r  r%  boolrB  INFOr  __name__rV   r2   r'   <module>r     s    
   



 				         				 ! ! ! ! ! !                   
 J I I I I I I I I I                                
  


 

 

( ( ("     $+799ffhh"&V" V" V" V"r5 5 5 +*733 ((11   +.3/B]/R+S+S8C=SSS*-#.AL.P*Q*Q(3-QQQQ   
EGG! &
 
 
$J J J J<: : : :: : : :   , B B B BR
 
 
       : : : :z3 3 3 38* * * *$ 
	 	 
	 
	 	 	 
	 9 9 9 9@   6K K8D> KS K K K K\ tdW\ ^, ^, ^, ^,B	 zHJJJJJ r2   