404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.129.67.218: ~ $
3

�~�fY�@shddlZddlZddlZddlmZddlmZmZmZddl	m
Z
mZeje
�ZdZdLZdZdee�dZGdd �d �ZGd!d"�d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zefd/d0�ZdMd1d2�ZGd3d4�d4�Zeed5�d6d7�Zeed5�d8d9�Z d:d;�Z!ee"d<�d=d>�Z#d?d@�Z$efdAdB�Z%dCdD�Z&efeeeefdE�dFdG�Z'dHdI�Z(dJdK�Z)dS)N�N)�suppress)�List�Sequence�Tuple)�subp�utilz/etc/ssh/sshd_config�dsa�rsa�ecdsa�ed25519�(ecdsa-sha2-nistp256-cert-v01@openssh.com�ecdsa-sha2-nistp256�(ecdsa-sha2-nistp384-cert-v01@openssh.com�ecdsa-sha2-nistp384�(ecdsa-sha2-nistp521-cert-v01@openssh.com�ecdsa-sha2-nistp521�+sk-ecdsa-sha2-nistp256-cert-v01@openssh.com�"sk-ecdsa-sha2-nistp256@openssh.com�#sk-ssh-ed25519-cert-v01@openssh.com�sk-ssh-ed25519@openssh.com�ssh-dss-cert-v01@openssh.com�ssh-dss� ssh-ed25519-cert-v01@openssh.com�ssh-ed25519�ssh-rsa-cert-v01@openssh.com�ssh-rsa�ssh-xmss-cert-v01@openssh.com�ssh-xmss@openssh.com�z�no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"$USER\" rather than the user \"$DISABLE_USER\".';echo;sleep 10;exit �"c@s&eZdZddd�Zdd�Zdd�ZdS)	�AuthKeyLineNcCs"||_||_||_||_||_dS)N)�base64�comment�options�keytype�source)�selfr%r$r!r"r#�r'�/usr/lib/python3.6/ssh_util.py�__init__Hs
zAuthKeyLine.__init__cCs|jo
|jS)N)r!r$)r&r'r'r(�validQszAuthKeyLine.validcCsdg}|jr|j|j�|jr(|j|j�|jr:|j|j�|jrL|j|j�|sV|jSdj|�SdS)N� )r#�appendr$r!r"r%�join)r&�toksr'r'r(�__str__TszAuthKeyLine.__str__)NNNN)�__name__�
__module__�__qualname__r)r*r/r'r'r'r(r Gs
r c@s"eZdZdZdd�Zddd�ZdS)�AuthKeyLineParsera�
    AUTHORIZED_KEYS FILE FORMAT
     AuthorizedKeysFile specifies the file containing public keys for public
     key authentication; if none is specified, the default is
     ~/.ssh/authorized_keys.  Each line of the file contains one key (empty
     (because of the size of the public key encoding) up to a limit of 8 kilo-
     bytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16
     kilobits.  You don't want to type them in; instead, copy the
     identity.pub, id_dsa.pub, or the id_rsa.pub file and edit it.

     sshd enforces a minimum RSA key modulus size for protocol 1 and protocol
     2 keys of 768 bits.

     The options (if present) consist of comma-separated option specifica-
     tions.  No spaces are permitted, except within double quotes.  The fol-
     lowing option specifications are supported (note that option keywords are
     case-insensitive):
    cCs�d}d}x~|t|�kr�|s&||d	kr�||}|dt|�krH|d}P||d}|dkrn|dkrn|d}n|dkr||}|d}q
W|d|�}||d�j�}||fS)
z�
        The options (if present) consist of comma-separated option specifica-
         tions.  No spaces are permitted, except within double quotes.
         Note that option keywords are case-insensitive.
        Frr+�	��\rN)r+r4)�len�lstrip)r&�entZquoted�iZcurcZnextcr#�remainr'r'r(�_extract_optionsxs 
z"AuthKeyLineParser._extract_optionsNcCs�|jd�}|jd�s |j�dkr(t|�Sdd�}|j�}y||�\}}}WnZtk
r�|j|�\}	}
|dkrt|	}y||
�\}}}Wntk
r�t|�SXYnXt|||||d�S)Nz
�#�cSs^|jdd�}t|�dkr(tdt|���|dtkrDtd|d��t|�dkrZ|jd�|S)N�zTo few fields: %srzInvalid keytype %sr>)�splitr7�	TypeError�VALID_KEY_TYPESr,)r9r.r'r'r(�
parse_ssh_key�s
z.AuthKeyLineParser.parse.<locals>.parse_ssh_key)r$r!r"r#)�rstrip�
startswith�stripr rAr<)r&Zsrc_liner#�linerCr9r$r!r"Zkeyoptsr;r'r'r(�parse�s*
zAuthKeyLineParser.parse)N)r0r1r2�__doc__r<rHr'r'r'r(r3dsr3c
Cs�g}t�}g}xp|D]h}y<tjj|�rRtj|�j�}x|D]}|j|j|��q:WWqt	t
fk
rztjtd|�YqXqW|S)NzError reading lines from %s)
r3�os�path�isfiler�	load_file�
splitlinesr,rH�IOError�OSError�logexc�LOG)�fnames�lines�parser�contents�fnamerGr'r'r(�parse_authorized_keys�s

rXcCs�tdd�|D��}x`tdt|��D]N}||}|j�s8q"x.|D]&}|j|jkr>|}||kr>|j|�q>W|||<q"Wx|D]}|j|�qzWdd�|D�}|jd�dj|�S)NcSsg|]}|j�r|�qSr')r*)�.0�kr'r'r(�
<listcomp>�sz*update_authorized_keys.<locals>.<listcomp>rcSsg|]}t|��qSr')�str)rY�br'r'r(r[�sr>�
)�list�ranger7r*r!�remover,r-)Zold_entries�keysZto_addr:r9rZ�keyrTr'r'r(�update_authorized_keys�s 


rdcCs8tj|�}|s|jr$td|��tjj|jd�|fS)Nz"Unable to get SSH info for user %rz.ssh)�pwd�getpwnam�pw_dir�RuntimeErrorrJrKr-)�username�pw_entr'r'r(�users_ssh_info�s
rkc	Csxd|fd|fdf}|sd}|j�}g}xL|D]D}x|D]\}}|j||�}q6W|jd�sftjj||�}|j|�q,W|S)Nz%hz%u�%%�%z%h/.ssh/authorized_keys�/)rlrm)r@�replacerErJrKr-r,)	�valueZhomedirriZmacros�pathsZrenderedrKZmacroZfieldr'r'r(�render_authorizedkeysfile_paths�s

rrc
Cs�d}|rd}tj|�}|r@||kr@|dkr@tjd||||�dStj|�}||kr\|dM}n.tj|�}tj|�}	||	kr�|dM}n|dM}||@d	kr�tjd
|||�dS|r�|d@d	kr�tjd||�dSd
S)aVCheck if the file/folder in @current_path has the right permissions.

    We need to check that:
    1. If StrictMode is enabled, the owner is either root or the user
    2. the user can access the file/folder, otherwise ssh won't use it
    3. If StrictMode is enabled, no write permission is given to group
       and world users (022)
    i�i��rootzXPath %s in %s must be own by user %s or by root, but instead is own by %s. Ignoring key.Fi��8�rzBPath %s in %s must be accessible by user %s, check its permissions�zRPath %s in %s must not give writepermission to group or world users. Ignoring key.T)rZ	get_ownerrR�debugZget_permissionsZ	get_groupZget_user_groups)
riZcurrent_path�	full_path�is_file�strictmodesZminimal_permissions�ownerZparent_permissionZgroup_ownerZuser_groupsr'r'r(�check_permissionssD





r|cCs�t|�d}td�d}�y�|jd�dd�}d}tjj|j�}x�|D]�}|d|7}tjj|�rrtjd|�dStjj	|�r�tjd|�dS|j
|�sF||jkr�qFtjj|��stj
|��Pd}	|j}
|j}|j
|j�r�d	}	|j}
|j}tj||	d
d�tj||
|�WdQRXt|||d|�}|sFdSqFWtjj|��sJtjj|��rZtjd|�dStjj|��s�tj|dd
d
d�tj||j|j�t|||d
|�}|�s�dSWn6ttfk
�r�}
ztjtt|
��dSd}
~
XnXd
S)Nr5rsrnr>z-Invalid directory. Symlink exists in path: %sFz*Invalid directory. File exists in path: %si�i�T)�mode�exist_okz%s is not a file!i�)r}Zensure_dir_exists���)rkr@rJrK�dirnamerg�islinkrRrwrLrE�existsr�SeLinuxGuardZpw_uidZpw_gid�makedirsZ	chownbyidr|�isdir�
write_filerOrPrQr\)ri�filenamerzZ
user_pwentZ
root_pwentZdirectoriesZ
parent_folderZhome_folderZ	directoryr}Zuid�gidZpermissions�er'r'r(�check_create_pathJsb


r�c
Cs"t|�\}}tjj|d�}|}g}tj|dd��ny2t|�}|jdd�}|jdd�}	t||j	|�}Wn4t
tfk
r�||d<tjt
d	t|d�YnXWdQRXxXt|j�|�D]F\}
}td
|
kd|
k|jdj|j	��g�r�t|||	dk�}|r�|}Pq�W||k�rt
jd
|�|t|g�fS)NZauthorized_keysT)�	recursiveZauthorizedkeysfilez%h/.ssh/authorized_keysrz�yesrzhFailed extracting 'AuthorizedKeysFile' in SSH config from %r, using 'AuthorizedKeysFile' file %r insteadz%uz%hz{}/zAAuthorizedKeysFile has an user-specific authorized_keys, using %s)rkrJrKr-rr��parse_ssh_config_map�getrrrgrOrPrQrR�DEF_SSHD_CFG�zipr@�anyrE�formatr�rwrX)
riZ
sshd_cfg_file�ssh_dirrjZdefault_authorizedkeys_fileZuser_authorizedkeys_fileZauth_key_fnsZssh_cfgZ	key_pathsrzZkey_path�auth_key_fnZpermissions_okr'r'r(�extract_authorized_keys�sF
r�c
Cs�t�}g}x$|D]}|j|jt|�|d��qWt|�\}}tjj|�}tj	|dd�� t
||�}	tj||	dd�WdQRXdS)N)r#T)r�)�
preserve_mode)r3r,rHr\r�rJrKr�rr�rdr�)
rbrir#rUZkey_entriesrZr�Zauth_key_entriesr��contentr'r'r(�setup_user_keys�s

r�c@s*eZdZddd�Zedd��Zdd�ZdS)	�SshdConfigLineNcCs||_||_||_dS)N)rG�_keyrp)r&rGrZ�vr'r'r(r)�szSshdConfigLine.__init__cCs|jdkrdS|jj�S)N)r��lower)r&r'r'r(rc�s
zSshdConfigLine.keycCs>|jdkrt|j�St|j�}|jr6|dt|j�7}|SdS)Nr+)r�r\rGrp)r&r�r'r'r(r/�s


zSshdConfigLine.__str__)NN)r0r1r2r)�propertyrcr/r'r'r'r(r��s
r�)�returncCs"tjj|�sgSttj|�j��S)N)rJrKrL�parse_ssh_config_linesrrMrN)rWr'r'r(�parse_ssh_config�sr�cCs�g}x�|D]�}|j�}|s&|jd�r6|jt|��q
y|jdd�\}}WnLtk
r�y|jdd�\}}Wn"tk
r�tjd|�w
YnXYnX|jt|||��q
W|S)Nr=r5�=z;sshd_config: option "%s" has no key/value pair, skipping it)rFrEr,r�r@�
ValueErrorrRrw)rT�retrGrc�valr'r'r(r��s$
r�cCs:t|�}|siSi}x |D]}|js&q|j||j<qW|S)N)r�rcrp)rWrTr�rGr'r'r(r�s
r�)rWr�cCsNtjj|�sdSt|d��*}x"|D]}|jd|�d��r"dSq"WWdQRXdS)NF�rzInclude z	.d/*.confT)rJrKrL�openrE)rW�frGr'r'r(�_includes_dconf%s
r�cCs^t|�rZtjj|�d��s.tj|�d�dd�tjj|�d�d�}tjj|�sZtj|d�|S)Nz.di�)r}z50-cloud-init.confi�)	r�rJrKr�rZ
ensure_dirr-rLZensure_file)rWr'r'r(�"_ensure_cloud_init_ssh_config_file/sr�cCsPt|�}t|�}t||d�}|rDtj|djdd�|D��ddd�t|�dkS)z�Read fname, and update if changes are necessary.

    @param updates: dictionary of desired values {Option: value}
    @return: boolean indicating if an update was done.)rT�updatesr^cSsg|]}t|��qSr')r\)rYrGr'r'r(r[Esz%update_ssh_config.<locals>.<listcomp>T)r�r)r�r��update_ssh_config_linesrr�r-r7)r�rWrT�changedr'r'r(�update_ssh_config:sr�c	Cst�}g}tdd�|j�D��}x�t|dd�D]v\}}|js>q.|j|kr.||j}||}|j|�|j|kr�tjd|||�q.|j	|�tjd|||j|�||_q.Wt
|�t
|�k�r
xN|j�D]B\}}||kr�q�|j	|�|j	td||��tjdt
|�||�q�W|S)	z�Update the SSH config lines per updates.

    @param lines: array of SshdConfigLine.  This array is updated in place.
    @param updates: dictionary of desired values {Option: value}
    @return: A list of keys in updates that were changed.cSsg|]}|j�|f�qSr')r�)rYrZr'r'r(r[Usz+update_ssh_config_lines.<locals>.<listcomp>r5)�startz$line %d: option %s already set to %sz#line %d: option %s updated %s -> %sr>z line %d: option %s added with %s)
�set�dictrb�	enumeraterc�addrprRrwr,r7�itemsr�)	rTr��foundr�Zcasemapr:rGrcrpr'r'r(r�Ks<






r�)rTcCs>|sdSt|�}dd�|D�}tj|dj|�dddd�dS)Ncss |]\}}|�d|��VqdS)r+Nr')rYrZr�r'r'r(�	<genexpr>}sz$append_ssh_config.<locals>.<genexpr>r^ZabT)Zomoder�)r�rr�r-)rTrWr�r'r'r(�append_ssh_configysr�cCspd}ttj�� tjddgddgd�\}}WdQRXd}x2|jd	�D]$}|j|�rD|t|�|jd
��SqDWdS)z�Get the full version of the OpenSSH sshd daemon on the system.

    On an ubuntu system, this would look something like:
    1.2p1 Ubuntu-1ubuntu0.1

    If we can't find `sshd` or parse the version number, return None.
    r>Zsshdz-Vrr5)�rcsNZOpenSSH_r^�,)rrZProcessExecutionErrorr@rEr7�find)�err�_�prefixrGr'r'r(�get_opensshd_version�s
$
r�cCs�d}t�}|dkrtjj|�Sd|kr:|d|jd��}n d|krV|d|jd��}n|}ytjj|�}|Sttfk
r�tjd|�YnXdS)z�Get the upstream version of the OpenSSH sshd dameon on the system.

    This will NOT include the portable number, so if the Ubuntu version looks
    like `1.2p1 Ubuntu-1ubuntu0.1`, then this function would return
    `1.2`
    z9.0N�pr+z Could not parse sshd version: %s)	r�rZVersionZfrom_strr�r�rArRZwarning)Zupstream_versionZfull_versionr'r'r(�get_opensshd_upstream_version�sr�)rr	r
rrr
rrrrrrrrrrrrrrrr)N)*ZloggingrJre�
contextlibrZtypingrrrZ	cloudinitrrZ	getLoggerr0rRr�rBZ_DISABLE_USER_SSH_EXITr\ZDISABLE_USER_OPTSr r3rXrdrkrrr|r�r�r�r�r�r�r��boolr�r�r�r�r�r�r�r'r'r'r(�<module>	sh
YEO9

.


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
apport.cpython-36.opt-1.pyc File 5.92 KB 0644
apport.cpython-36.pyc File 5.96 KB 0644
atomic_helper.cpython-36.opt-1.pyc File 2.05 KB 0644
atomic_helper.cpython-36.pyc File 2.05 KB 0644
cloud.cpython-36.opt-1.pyc File 3.08 KB 0644
cloud.cpython-36.pyc File 3.08 KB 0644
dmi.cpython-36.opt-1.pyc File 5.32 KB 0644
dmi.cpython-36.pyc File 5.32 KB 0644
event.cpython-36.opt-1.pyc File 1.97 KB 0644
event.cpython-36.pyc File 1.97 KB 0644
features.cpython-36.opt-1.pyc File 1.47 KB 0644
features.cpython-36.pyc File 1.47 KB 0644
gpg.cpython-36.opt-1.pyc File 3.76 KB 0644
gpg.cpython-36.pyc File 3.76 KB 0644
helpers.cpython-36.opt-1.pyc File 13.31 KB 0644
helpers.cpython-36.pyc File 13.31 KB 0644
importer.cpython-36.opt-1.pyc File 1.68 KB 0644
importer.cpython-36.pyc File 1.68 KB 0644
log.cpython-36.opt-1.pyc File 4.61 KB 0644
log.cpython-36.pyc File 4.61 KB 0644
netinfo.cpython-36.opt-1.pyc File 12.67 KB 0644
netinfo.cpython-36.pyc File 12.67 KB 0644
persistence.cpython-36.opt-1.pyc File 2.82 KB 0644
persistence.cpython-36.pyc File 2.82 KB 0644
registry.cpython-36.opt-1.pyc File 1.38 KB 0644
registry.cpython-36.pyc File 1.38 KB 0644
safeyaml.cpython-36.opt-1.pyc File 8 KB 0644
safeyaml.cpython-36.pyc File 8 KB 0644
settings.cpython-36.opt-1.pyc File 1.14 KB 0644
settings.cpython-36.pyc File 1.14 KB 0644
signal_handler.cpython-36.opt-1.pyc File 1.58 KB 0644
signal_handler.cpython-36.pyc File 1.58 KB 0644
simpletable.cpython-36.opt-1.pyc File 2.53 KB 0644
simpletable.cpython-36.pyc File 2.53 KB 0644
ssh_util.cpython-36.opt-1.pyc File 15.36 KB 0644
ssh_util.cpython-36.pyc File 15.36 KB 0644
stages.cpython-36.opt-1.pyc File 25.15 KB 0644
stages.cpython-36.pyc File 25.15 KB 0644
subp.cpython-36.opt-1.pyc File 9.97 KB 0644
subp.cpython-36.pyc File 9.97 KB 0644
temp_utils.cpython-36.opt-1.pyc File 2.81 KB 0644
temp_utils.cpython-36.pyc File 2.81 KB 0644
templater.cpython-36.opt-1.pyc File 4.55 KB 0644
templater.cpython-36.pyc File 4.55 KB 0644
type_utils.cpython-36.opt-1.pyc File 437 B 0644
type_utils.cpython-36.pyc File 437 B 0644
url_helper.cpython-36.opt-1.pyc File 21.03 KB 0644
url_helper.cpython-36.pyc File 21.03 KB 0644
user_data.cpython-36.opt-1.pyc File 8.25 KB 0644
user_data.cpython-36.pyc File 8.25 KB 0644
util.cpython-36.opt-1.pyc File 73.64 KB 0644
util.cpython-36.pyc File 73.64 KB 0644
version.cpython-36.opt-1.pyc File 429 B 0644
version.cpython-36.pyc File 429 B 0644
warnings.cpython-36.opt-1.pyc File 3.25 KB 0644
warnings.cpython-36.pyc File 3.25 KB 0644