
    h?                     &   d Z ddlmZmZ ddlmZ ddl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mZmZ dZddd	Zd
dddddddddddddddZddddddd d!Z G d" d#e          Zd$d%gZd&d'gZ G d( d)e          Zd*d+d,d-d.d/Z G d0 d1e          Zdd2d3d4Z  G d5 d6e          Z!d*d+d	Z" G d7 d8e          Z# G d9 d:e          Z$d*d+d	Z% G d; d<e          Z&d=d>d?d4Z'd@dAdBd4Z( G dC dDe          Z)dEd+dFdGdHdIdJdKZ* G dL dMe          Z+ G dN dOe          Z, G dP dQe          Z- G dR dSe          Z. G dT dUe          Z/dVd+dWdXdYZ0 G dZ d[e          Z1 G d\ d]e          Z2 G d^ d_e          Z3 eeed`a            eeed`b           dcS )dz6
PPTP (Point to Point Tunneling Protocol)

[RFC 2637]
    )Packetbind_layers)TCP)orb)ByteEnumFieldFieldLenField
FlagsFieldIntFieldIntEnumFieldLenField	XIntField
ShortFieldShortEnumFieldStrFixedLenFieldStrLenFieldXShortField
XByteFieldiM<+zControl MessagezManagemenent Message)      z Start-Control-Connection-RequestzStart-Control-Connection-ReplyzStop-Control-Connection-RequestzStop-Control-Connection-ReplyzEcho-Requestz
Echo-ReplyzOutgoing-Call-RequestzOutgoing-Call-ReplyzIncoming-Call-RequestzIncoming-Call-ReplyzIncoming-Call-ConnectedzCall-Clear-RequestzCall-Disconnect-NotifyzWAN-Error-NotifyzSet-Link-Info)r   r                     	   
                  NonezNot-Connectedz
Bad-Formatz	Bad-ValuezNo-ResourcezBad-Call IDz	PAC-Error)r   r   r   r   r   r   r   c            
           e Zd Zd Z eddddd            edde           ed	e           ed
de	           e
dd           eddd           gZi Zed             Zedd            ZdS )PPTPlenNHdatac                     |dz   S Nr    )pxs     U/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/layers/pptp.py<lambda>zPPTP.<lambda>8   s
    QV     )fmt	length_ofadjusttyper   magic_cookiectrl_msg_type
reserved_0r    c                     | j         dz
  S r*   )r&   )r,   s    r.   r/   zPPTP.<lambda>=   s     r0   )length_fromc                 .    | | j         | j        j        <   d S N)registered_optionsr6   default)clss    r.   register_variantzPPTP.register_variantA   s    <?s08999r0   c                 j    |r0t          |d                   }| j                            ||           S | S )Nr   )r   r=   get)r?   _pktargskargsos        r.   dispatch_hookzPPTP.dispatch_hookE   s7     	6DGA)--a555
r0   r<   )__name__
__module____qualname__namer   r   _PPTP_msg_typer   _PPTP_MAGIC_COOKIE_PPTP_ctrl_msg_typer   r   fields_descr=   classmethodr@   rG   r+   r0   r.   r%   r%   5   s        D =#(;(;= = =!>&!^<<9^-?@@!>/16IJJ;|V44;vr7K7KLLLNK @ @ [@    [  r0   r%   zAsynchronous Framing supportedzSynchronous Framing supportedzAnalog access supportedzDigital access supportedc                   D   e Zd ZdZ edd           edde           ede           edde	           e
dd	           ed
d           e
dd	           edd	de           edd	de           edd           edd           eddd           eddd          gZdS )!PPTPStartControlConnectionRequestz%PPTP Start Control Connection Requestr&      r4   r   r5   r6   r7   r   protocol_version   
reserved_1framing_capabilities    bearer_capabilitiesmaximum_channels  firmware_revision	host_namelinux@   vendor_stringr8   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r	    _PPTP_FRAMING_CAPABILITIES_FLAGS_PPTP_BEARER_CAPABILITIES_FLAGSr   rO   r+   r0   r.   rR   rR   T   s       2D8E3''!>&!^<<9^-?@@!>/16IJJ;|V44:0&99;|V44:4a>@ @:3Q=? ?:0%88:1377##K"==##OR<<>KKKr0   rR   OKzGeneral errorzCommand channel already existszNot authorizedzUnsupported protocol version)r   r   r   r   r   c                   d   e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edde           edd
e           edd
de           edd
de           edd           edd           eddd           eddd          gZd ZdS )PPTPStartControlConnectionReplyz#PPTP Start Control Connection Replyr&   rS   r4   r   r5   r6   r   r7   r   rT   rU   result_code
error_coderW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   r8   c                 ,    t          |t                    S r<   )
isinstancerR   selfothers     r.   answersz'PPTPStartControlConnectionReply.answers   s    %!BCCCr0   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r   %_PPTP_start_control_connection_result_PPTP_general_error_coder	   ra   rb   r   rO   rm   r+   r0   r.   re   re   n   s7       0D8E3''!>&!^<<9^-?@@!>/16IJJ;|V44:0&99 =!FH H =q2JKK:4a>@ @:3Q=? ?:0%88:1377##K"==##OR<<!>K$D D D D Dr0   re   zStop-ProtocolzStop-Local-Shutdown)r   r   r   c                       e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edde           edd
           e
dd
          gZdS ) PPTPStopControlConnectionRequestz$PPTP Stop Control Connection Requestr&      r4   r   r5   r6   r   r7   r   reasonrV   
reserved_2N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   $_PPTP_stop_control_connection_reasonr   rO   r+   r0   r.   rq   rq      s        1D8E2&&!>&!^<<9^-?@@!>/16IJJ;|V44 =1!EG G:lD11;|V446KKKr0   rq   c                       e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edde           edd
e           e
dd
          gZd ZdS )PPTPStopControlConnectionReplyz"PPTP Stop Control Connection Replyr&   rr   r4   r   r5   r6   r   r7   r   rf   rg   rt   c                 ,    t          |t                    S r<   )ri   rq   rj   s     r.   rm   z&PPTPStopControlConnectionReply.answers   s    %!ABBBr0   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   $_PPTP_stop_control_connection_resultro   rO   rm   r+   r0   r.   rw   rw      s        /D8E2&&!>&!^<<9^-?@@!>/16IJJ;|V44 =!EG G =q2JKK;|V446KC C C C Cr0   rw   c            	           e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd          gZdS )PPTPEchoRequestzPPTP Echo Requestr&   rr   r4   r   r5   r6   r   r7   r   
identifierN)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r
   rO   r+   r0   r.   r{   r{      sz        D8E2&&!>&!^<<9^-?@@!>/16IJJ;|V448L$//1KKKr0   r{   c                       e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edde           edd
e           e
dd
          g	Zd ZdS )PPTPEchoReplyzPPTP Echo Replyr&      r4   r   r5   r6   r   r7   r   r|   Nrf   rg   rV   c                 L    t          |t                    o|j        | j        k    S r<   )ri   r{   r|   rj   s     r.   rm   zPPTPEchoReply.answers   s!    %11Ye6F$/6YYr0   )rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r
   r   _PPTP_echo_resultro   rO   rm   r+   r0   r.   r~   r~      s        D8E2&&!>&!^<<9^-?@@!>/16IJJ;|V448L$// =3DEE =q2JKK;|V446KZ Z Z Z Zr0   r~   zAnalog channelzDigital channelzAny type of channelzAsynchronous framingzSynchronous framingzAny type of framingc                      e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edd
           edd           edd           edde           edde           edd           edd
           edd
           e
dd
           eddd           eddd          gZdS )PPTPOutgoingCallRequestzPPTP Outgoing Call Requestr&      r4   r   r5   r6   r   r7   r   call_idcall_serial_numberminimum_bpsi   maximum_bpsl        bearer_typer   framing_typepkt_window_sizerr   pkt_proc_delayphone_number_lenrV   phone_numberr8   r_   
subaddressN)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r
   r   _PPTP_bearer_type_PPTP_framing_typer   rO   r+   r0   r.   r   r      s/       'D8E3''!>&!^<<9^-?@@!>/16IJJ;|V44:i++:2A668M5118M:66<q2CDD<3EFF:/44:.22:0!44;|V44##NB;;##L"b99!;KKKr0   r   	Connectedz
No CarrierBusyzNo dial tonezTime-outzDo not accept)r   r   r   r   r   r   r   c                   X   e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edd           edde           edd
e           edd
           edd           edd           edd
           edd
          gZd ZdS )PPTPOutgoingCallReplyzPPTP Outgoing Call Replyr&   rX   r4   r   r5   r6   r   r7   r   r   peer_call_idrf   rg   
cause_codeconnect_speed r   rr   r   
channel_idc                 L    t          |t                    o|j        | j        k    S r<   )ri   r   r   r   rj   s     r.   rm   zPPTPOutgoingCallReply.answers  "    %!899`emtO`>``r0   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r   _PPTP_result_codero   r
   rO   rm   r+   r0   r.   r   r      s       %D8E2&&!>&!^<<9^-?@@!>/16IJJ;|V44:i++:na00 =3DEE =q2JKK:lA..8OY77:/44:.228L!,,.Ka a a a ar0   r   c                   V   e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edd           edde           edd
           edd
           edd
           eddd           eddd           eddd          gZdS )PPTPIncomingCallRequestzPPTP Incoming Call Requestr&      r4   r   r5   r6   r   r7   r   r   r   r   r   r   dialed_number_lendialing_number_lendialed_numberr8   r_   dialing_numberr   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r   r   r
   r   rO   r+   r0   r.   r   r     s       'D8E3''!>&!^<<9^-?@@!>/16IJJ;|V44:i++:2A66<q2CDD8L!,,:1155:2A66##OR<<##$4b"==##L"b99;KKKr0   r   c                   ,   e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edd           edde           edd
e           edd           edd
           e
dd
          gZd ZdS )PPTPIncomingCallReplyzPPTP Incoming Call Replyr&      r4   r   r5   r6   r   r7   r   r   r   rf   rg   r   r_   pkt_transmit_delayrV   c                 L    t          |t                    o|j        | j        k    S r<   )ri   r   r   r   rj   s     r.   rm   zPPTPIncomingCallReply.answers'  r   r0   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r   r   ro   rO   rm   r+   r0   r.   r   r     s        %D8E3''!>&!^<<9^-?@@!>/27JKK;|V44:i++:na00 =3DEE =q2JKK:/44:2A66;|V446Ka a a a ar0   r   c                      e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           e
dd
           edd           edd           edd
           edde          gZd ZdS )PPTPIncomingCallConnectedzPPTP Incoming Call Connectedr&      r4   r   r5   r6   r   r7   r   r   rV   r   r   r   r_   r   r   c                 L    t          |t                    o|j        | j        k    S r<   )ri   r   r   r   rj   s     r.   rm   z!PPTPIncomingCallConnected.answers9  s"    %!677^EMTM^<^^r0   N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r
   r   r   rO   rm   r+   r0   r.   r   r   +  s        )D8E2&&!>&!^<<9^-?@@!>/27JKK;|V44:na00;|V448OY77:/44:2A66<3EFF
HK_ _ _ _ _r0   r   c            
           e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           e
dd
          gZdS )PPTPCallClearRequestzPPTP Call Clear Requestr&   rr   r4   r   r5   r6   r   r7   r   r   rV   NrH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   rO   r+   r0   r.   r   r   =  s        $D8E2&&!>&!^<<9^-?@@!>/27JKK;|V44:i++;|V446KKKr0   r   zLost CarrierzAdmin ShutdownRequest)r   r   r   r   c                      e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           edde           edd
e           edd
           e
dd
           eddd          gZdS )PPTPCallDisconnectNotifyzPPTP Call Disconnect Notifyr&   r   r4   r   r5   r6   r    r7   r   r   rf   rg   r   rV   call_statisticr8      N)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r   _PPTP_call_disconnect_resultro   r   rO   r+   r0   r.   r   r   N  s        (D8E3''!>&!^<<9^-?@@!>/27JKK;|V44:i++ =!=? ? =q2JKK:lA..;|V44##$4b#>>@KKKr0   r   c                   8   e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           e
dd
           edd
           edd
           edd
           edd
           edd
           edd
          gZdS )PPTPWANErrorNotifyzPPTP WAN Error Notifyr&   (   r4   r   r5   r6   r!   r7   r   r   rV   
crc_errorsframing_errorshardware_overrunsbuffer_overrunstime_out_errorsalignment_errorsN)rH   rI   rJ   rK   r   r   rL   r   rM   rN   r   r   r
   rO   r+   r0   r.   r   r   ^  s        "D8E2&&!>&!^<<9^-?@@!>/27JKK;|V44:na00;|V448L!,,8,a008/338-q118-q118.224KKKr0   r   c                       e Zd ZdZ edd           edde           ede           edde	           e
d	d
           edd           e
dd
           edd
           edd
          g	ZdS )PPTPSetLinkInfozPPTP Set Link Infor&      r4   r   r5   r6   r"   r7   r   r   rV   	send_accmreceive_accmNr   r+   r0   r.   r   r   o  s        D8E2&&!>&!^<<9^-?@@!>/27JKK;|V44:na00;|V449[*559^Z88:KKKr0   r   i  )sport)dportN)4__doc__scapy.packetr   r   scapy.layers.inetr   scapy.compatr   scapy.fieldsr   r   r	   r
   r   r   r   r   r   r   r   r   r   rM   rL   rN   ro   r%   ra   rb   rR   rn   re   ru   rq   ry   rw   r{   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r+   r0   r.   <module>r      s`    - , , , , , , , ! ! ! ! ! !      ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;   &+- - *'(&! %  (  &.+*,,*, ,     6   0 %E$C$E   $=#=#? > > > > > > > >& -1,;,L,<,J	)L )L %D D D D Dd D D D0 ,2+:+@(B (B $

6 
6 
6 
6 
6t 
6 
6 
6 ,0+:(< (< $C C C C CT C C C 1 1 1 1 1d 1 1 1 ') ) Z Z Z Z ZD Z Z Z  ))-/ /  0..0 0 
; ; ; ; ;d ; ; ;* $'$&"') ) a a a a aD a a a*; ; ; ; ;d ; ; ;$a a a a aD a a a&_ _ _ _ _ _ _ _$6 6 6 6 64 6 6 6 $2#2#3#, .  . @ @ @ @ @t @ @ @ 4 4 4 4 4 4 4 4"
: 
: 
: 
: 
:d 
: 
: 
: CT " " " " CT " " " " " "r0   