shell bypass 403

UnknownSec Shell

Uname: Linux dedi-15171674.espacofacial.com.br 5.14.0-687.48.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Sep 16 12:22:07 EDT 2026 x86_64
Software: Apache
PHP version: 8.2.33 [ PHP INFO ] PHP os: Linux
Server Ip: 172.67.154.186
Your Ip: 216.73.217.13
User: espa7358 (1004) | Group: espa7358 (1003)
Safe Mode: OFF
Disable Function:
NONE

name : utilities.cpython-39.pyc
a

�1j�n�
@s�ddlZddlZddlZddlZddlmZmZmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZddlmZzddlmZWney�ddlmZYn0e�d�ZdZzddlZe�e �d	ZWnDee!f�y8dd
l"m#Z#dZ$e�%de#e$d
dd��d��Yn0dZ&gd�Z'dd�Z(dVdd�Z)dd�Z*dWdd�Z+dd�Z,dd�Z-dd�Z.dXd d!�Z/d"d#�Z0dYd$d%�Z1e2d&�d'd(�Z3e&ddddddddddddf
d)d*�Z4dZd+d,�Z5d[d-d.�Z6d\d0d1�Z7d]d3d4�Z8ej9fd5d6�Z:d7d8�Z;d9d:�Z<d;d<�Z=d=d>�Z>d?d@�Z?ej@dA�dBdC�ZAdDdE�ZBgfdFdG�ZCGdHdI�dIejD�ZEGdJdK�dK�ZFGdLdM�dMejD�ZGGdNdO�dOejD�ZHGdPdQ�dQ�ZIGdRdS�dS�ZJGdTdU�dUeK�ZLdS)^�N)�Popen�PIPE�STDOUT)�closing)�deque)�parse)�
parse_versionZsosFT)�fillz�WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module.
�
�H)Zreplace_whitespacei,)�TIMEOUT_DEFAULT�ImporterHelper�SoSTimeoutError�TempFileUtil�bold�file_is_binary�fileobj�find�get_human_readable�grep�
import_module�
is_executable�listdirr�path_exists�
path_isdir�path_isfile�path_islink�	path_join�recursive_dict_values_by_key�	shell_out�sos_get_command_output�tac_logs�tailc
Cs�t�d�}zF|j|dd�\}}}|s*|WSt�dd|��d�}|�d|��}|WSty�}z&t�d|�d	|���|WYd
}~Sd
}~00d
S)z< Convert the version into a PEP440 compliant version scheme.z2^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?�)�maxsplitz[+~]+�.�-�+zUnable to format z to pep440 format: N)�re�compile�split�sub�strip�	Exception�log�debug)�verZpublic_version_re�_Zpublic�localZsanitized_localZpep440_version�err�r4�1/usr/lib/python3.9/site-packages/sos/utilities.py�format_version_to_pep440Ps�r6cCs|rt|�}t|�St|�S)z6 Converts the version to PEP440 format before parsing )r6r)r0Zpep440Z
ver_pep440r4r4r5�sos_parse_versionasr7cCsTt|d��6}t�|�j|kr*|�|d�|��Wd�S1sF0YdS)z,Returns the last number_of_bytes of filename�rb�N)�open�os�stat�st_size�seek�read)�filenameZnumber_of_bytes�fr4r4r5r"jsr"�rcCsZt|t�rNzt||dd�WStyJt�d|�d��tt���YS0nt|�SdS)z@Returns a file-like object that can be used as a context manager�utf-8��encodingz	fileobj: z could not be openedN)	�
isinstance�strr:�IOErrorr.r/r�io�StringIO)Zpath_or_file�moder4r4r5rrs
rcCsHddddd�}|��D]*\}}||krt|�|d�|��Sq|�S)zCConverts a number of bytes to a shorter, more human friendly formatli@��)�T�G�M�Kz.1f)�items�float)Z	num_bytesZsizes�symbol�sizer4r4r5�
convert_bytes~s
rVcCs�|dd�dvr�t|ddd��P}|��}t�d|�rDWd�dSt�d	|�r`Wd�d
SWd�n1st0YdSdS)a�Helper to determine if a given file is a certificate or not.

    This is especially helpful for `sos clean`, which cannot obfuscate
    certificate files content and instead, by default, will keep them as is.

    :param fname:   The full path of the file to check
    :type fname:    ``str``

    :returns:   The type of the certificate or ``None``
    :rtype:     ``string`` or ``None``
    ���N)z.csrz.crtz.pemrBrCrDz-----BEGIN CERTIFICATE-----Zcertificatez"-----BEGIN [A-Z]+ PRIVATE KEY-----Zcertificatekey)r:r?r(�search)�fnamerAZcontentr4r4r5�file_is_certificate�s.rZc	s�tr`zHt�|��ddg}�jdkoJt�fdd�|D��oJtt�d|��WSty^Yn0t	|ddd	��N}z|�
d
�WWd�dSty�YWd�d
S0Wd�n1s�0YdS)azHelper to determine if a given file contains binary content or not.

    This is especially helpful for `sos clean`, which cannot obfuscate binary
    data and instead, by default, will remove binary files.

    :param fname:   The full path of the file to check binaryness of
    :type fname:    ``str``

    :returns:   True if binary, else False
    :rtype:     ``bool``
    ztext/zinode/�binaryc3s|]}�j�|�VqdS�N)Z	mime_type�
startswith)�.0Z_mt�Z_ftupr4r5�	<genexpr>��z!file_is_binary.<locals>.<genexpr>zaudit\.log(?:\.[1-9]\d*)?$�trrCrDr#NFT)�	magic_mod�magic�detect_from_filenamerE�any�boolr(rXr-r:r?�UnicodeDecodeError)rYZ_mimesZtfiler4r_r5r�s$

���
rc	cs�|r"tj�|��tjj�}||7}t�|�D]^\}}}|rV|�tjj�|krV|dd�=|rht�||�shq,t�||�D]}tj�||�Vqtq,dS)z�Generator function to find files recursively.
    Usage::

        for filename in find("*.properties", "/var/log/foobar"):
            print filename
    N)	r;�path�dirname�count�sep�walk�fnmatch�filter�join)	Zfile_patternZtop_dirZ	max_depth�path_patternZ
base_depthri�dirlistZfilelist�namer4r4r5r�s
rc	sRg}|D]D}t|��(}|��fdd�|D��Wd�q1sB0Yq|S)z�Returns lines matched in fnames, where fnames can either be pathnames to
    files to grep through or open file objects to grep through line by linec3s|]}t��|�r|VqdSr\)r(�match)r^�line��patternr4r5r`�razgrep.<locals>.<genexpr>N)r�extend)rwZfiles_or_paths�matchesZfop�for4rvr5r�s

8rcs\tj�dd��tjj�}�g�fdd�|D�}�rJ|�fdd�|D�7}tdd�|D��S)z6Returns if a command matches an executable on the PATH�PATH�csg|]}tj�|���qSr4)r;rirp)r^�p)�commandr4r5�
<listcomp>�raz!is_executable.<locals>.<listcomp>cs g|]}tj��|�d���qS)�/)r;rirp�lstrip)r^�c��sysrootr4r5r�scss|]}t�|tj�VqdSr\)r;�access�X_OK)r^rir4r4r5r`�raz is_executable.<locals>.<genexpr>)r;�environ�getr*ri�pathseprf)r~r��pathsZ
candidatesr4)r~r�r5r�s�r)�urlcCs�ddlm}m}zd||�}|js&|jrpd}|jr:||j7}|jrP|d|j��7}||j||j|j	|j
|jf�WS|WSty�|YS0dS)zK
    Replace username:password@ with ********@ in proxy URL if present
    r)�urlparse�
urlunparsez	********@�:N)
�urllib.parser�r��username�password�hostname�port�schemeri�params�query�fragmentr-)r�r�r�Z
parsed_url�netlocr4r4r5�scrub_url_credential�s 

�r�c 
s���fdd�}�fdd�}�rfzt���}WntyLdddd�YS0|�|j�|j�d��tj��}d	|d
<|r�|��D]"\}}|r�|||<q�|�	|d�q�|r�t
d�r�d
|r�dnd�d|�d|��}t�|�}g}|D]L}|�
d��r&d|v�r&t�|�}|�r|�|�n
|�|�q�|�|�q�|
�rl|�rDt}n&|�r`tjtj�|
�d�}n
t|
d�}nt}|
du�r~tnd}�zp�z�t|d|||�r�tntd|d|d�	���}d}�zf|
�r
|�r�|�r�tjtj�|
�d�}n
t|
d�}t|j|||�}n
t||�}nt|j||�}|
du�r.t|j|
�}��rJ|j�r6||��q4n�z|� |�rZ|nd�Wn�t!�y4|�"�|
�r�|�r�t|
d��}t#||d�Wd�n1�s�0Yd|_d|�$�|j%d�YW|du�r|�&�|j'�rt(�)d|�d|j'���Wd�WWt*|d��r2|�+�S0|�,�du�rH�q6|
�r�|�r�t|
d��*}t#|||j%�pv|j-dk�Wd�n1�s�0Y|j-dv�r�d}n|�$�}|j-||j%d�W|du�r�|�&�|j'�r�t(�)d|�d|j'���Wd�WWt*|d��r|�+�Sn4|du�rR|�&�|j'�rRt(�)d|�d|j'���0Wd�n1�sj0YWnft.�y�}zL|j/t/j0k�r�dddd�WYd}~Wt*|d��r�|�+�S|�WYd}~n
d}~00Wt*|d��r|�+�nt*|d��r
|�+�0dS) arExecute a command and return a dictionary of status and output,
    optionally changing root or current working directory before
    executing command.

    :param stdin: If not ``None``, open a pipe to the child's stdin and
        write this value (``str`` is encoded as UTF-8, ``bytes`` is sent
        as-is). If ``None``, the child inherits the parent's stdin.
    csb�r�dkrt����rPt�t���j�t�t���j�t�t���j	��r^t���dS�Nr�)
r;�chroot�setgid�pwd�getpwnam�pw_gid�setuid�pw_uid�chdir�pw_dirr4)r�r��runasr4r5�_child_prep_fns
z.sos_get_command_output.<locals>._child_prep_fncs,��s|��dkr|��t�t�d�dS)N�|�{�G�z�?)�poll�	terminater�time�sleep)�proc)�pollerr4r5�
_check_poller"sz-sos_get_command_output.<locals>._check_poller�r|)�status�outputZ	truncated)�HOMEZLOGNAMEZPWDZUSERzC.UTF-8�LC_ALLN�timeoutztimeout z--foreground� zs r��*��dir�wbF���T)�shell�stdin�stdout�stderr�bufsize�envZ	close_fdsZ
preexec_fnr�zPassing stdin to command z raised an error: �closer)�~r�ra)1r�r��KeyError�updater�r;r��copyrR�popr�shlexr*r]�globrx�appendr�tempfileZ
TemporaryFilerirjr:rr�
HeadReaderr��
FakeReader�
TailReader�StdinWriterr��running�waitr-r�r!�get_contents�is_fullrp�errorr.�warning�hasattrr�r��
returncode�OSError�errno�ENOENT) r~r�r�r�r�r�Z
foregroundr[�	sizelimitr�Zto_fileZtacr�r�r�r�Zpwd_userZcmd_env�key�value�argsZ
expanded_args�argZexpanded_argZ_output�_stdinr}Zstdin_writer�reader�f_dstr��er4)r�r�r�r�r5r s
�

�


�
�

�
,�

��"��$�
�����
�.�
�r c	Cs�d}d}d}|��t�|���jdkr,dStj|��dtjd���}|��d}}|||krdd}|dkr�|�|d|�}||d|kr�|d	krdq�qd|r�d
}n|�	||d|d��|}qdWd�n1s�0YdS)z�Python implementation of the tac utility with support
    for multiline logs (starting with space). It is intended
    to reverse the output of 'journalctl --reverse'.
    �
�
� rN)r�r#Tr�F)
�flushr;�fstat�filenor=�mmapZACCESS_READrU�rfind�write)	�f_srcr�Z
drop_last_logZ	NEWLINE_BZ	NEWLINE_IZSPACE_IZmmZsep1Zsep2r4r4r5r!�s(r!c
s���d�d}zt�t�t�|g�}Wn@tyf}z(td��d|jj���|�WYd}~n
d}~00�fdd�t�	|tj
�D�}�r��fdd�|D�}|S)	aImports the module module_fqname and returns a list of defined classes
    from that module. If superclasses is defined then the classes returned will
    be subclasses of the specified superclass or superclasses. If superclasses
    is plural it must be a tuple of classes.r%r�z"Error while trying to load module z:  Ncsg|]\}}|j�kr|�qSr4)�
__module__)r^Zcname�class_)�
module_fqnamer4r5r�s
�z!import_module.<locals>.<listcomp>csg|]}t|��r|�qSr4)�
issubclass)r^�m)�superclassesr4r5r�ra)�
rpartition�
__import__�globals�locals�ImportError�print�	__class__�__name__�inspectZ
getmembersZisclass)r�r�Zmodule_name�moduler��modulesr4)r�r�r5r�s
�
�r�cCst||||d�dS)zeShell out to an external command and return the output or the empty
    string in case of error.
    )r�r�r�r�)r )�cmdr�r�Zrunatr4r4r5r�s
��rr9cCsHgd�}d}|dkr.|dkr.|d7}|d}q|d|�d��||��S)	N)�BZKiBZMiBZGiBZTiBrrM�r#g�@r%rAr4)rUZ	precision�suffixesZsuffixindexr4r4r5r�s
rcCs>|r,|tjkr,|�|�s,tj�||�d��}t||�}||�Sr�)r;rlr]rirpr��getattr)rir��methodr�Z_methr4r4r5�_os_wrapper�s


rcCs$d|vrt||dtd�St||d�S)Nr�r�)r��exists)rr��rir�r4r4r5rsrcCst||d�S)N�isdir�rrr4r4r5rsrcCst||d�S)N�isfiler	rr4r4r5rsrcCst||d�S)N�islinkr	rr4r4r5rsrcCst||dt�S)Nr)rr;rr4r4r5rsrr�cGs8|r$|�|�s$tj�||�tj��}tjj|g|�R�Sr\)r]r;rirpr�rl)rir�r}r4r4r5rsrcCsd|dS)a"Helper to make text bold in console output, without pulling in
    dependencies to the project unneccessarily.

    :param text:    The text to make bold
    :type text:     ``str``

    :returns:       The text wrapped in the ASCII codes to display as bold
    :rtype:         ``str``
    zzr4)�textr4r4r5r"s
rc	s�g}g�|�|�t|t�r�|��D]~\}���|�|rB||vrR|�t���q$t�t�r$z$|�t�fdd�|D��d�Wnty�Yn0������q$n
|�|��fdd�|D�S)a	Recursively compile all elements of a potentially nested dict by a set
    of keys. If a given key is a dict within ``dobj``, then _all_ elements
    within that dict, regardless of child keys, will be returned.

    For example, if a Plugin searches the devices dict for the 'storage' key,
    then all storage devices under the that dict (e.g. block, fibre, etc...)
    will be returned. However, if the Plugin specifies 'block' via ``keys``,
    then only the block devices within the devices['storage'] dict will be
    returned.

    Any elements passed here that are _not_ keys within the dict or any nested
    dicts will also be returned.

    :param dobj:    The 'top-level' dict to intially search by
    :type dobj:     ``dict``

    :param keys:    Which keys to compile elements from within ``dobj``. If no
                    keys are given, all nested elements are returned
    :param keys:    ``list`` of ``str``

    :returns:       All elements within the dict and any nested dicts
    :rtype:         ``list``
    c3s|]}|�vr�|VqdSr\r4)r^r�)�vr4r5r`Vsz/recursive_dict_values_by_key.<locals>.<genexpr>rcsg|]}|�vr|�qSr4r4)r^�d)�_filtr4r5rbraz0recursive_dict_values_by_key.<locals>.<listcomp>)rxrF�dictrRr�r�
IndexError�keys)ZdobjrZ_items�kr4)rr
r5r/s,



���
rcs,eZdZdZdZ�fdd�Zdd�Z�ZS)r�zEWrite bytes to a Popen child's stdin without blocking the main threadicsLt�jdd�t|t�r"|�d�}||_|r4t|�nd|_d|_|�	�dS)NF)�daemonrCr|)
�super�__init__rFrG�encoder��
memoryview�_datar��start)�selfZ
stdin_pipe�data�r�r4r5rjs

zStdinWriter.__init__cCs6|jdurdSz�z^|jrld}t|j�}||krb|j|||j�}|j�|�}|durXq&||7}q&|j��Wn.ttfy�}z||_WYd}~n
d}~00Wz|j�	�Wn6ttfy�}z|j|7_WYd}~n
d}~00nJz|j�	�Wn8ttf�y.}z|j|7_WYd}~n
d}~000dS�Nr)
r�r�len�CHUNKr�r��BrokenPipeError�
ValueErrorr�r�)r�offset�total�chunk�n�excr4r4r5�runss.


&�zStdinWriter.run)r�r��__qualname__�__doc__r rr(�
__classcell__r4r4rr5r�es	r�c@s8eZdZdZdd�Zedd��Zdd�Zedd	��Zd
S)r�z�Used when we are writing directly to disk without sizelimits,
    this allows us to keep more simplified flows for executing,
    monitoring, and collecting command output.
    cCs||_||_dSr\)�processr[)rr,r[r4r4r5r�szFakeReader.__init__cCsdS)NFr4�rr4r4r5r��szFakeReader.is_fullcCs|js
dSdS�Nr|ra�r[r-r4r4r5r��szFakeReader.get_contentscCs|j��duSr\)r,r�r-r4r4r5r��szFakeReader.runningN)	r�r�r)r*r�propertyr�r�r�r4r4r4r5r��s
r�cs@eZdZdZdZ�fdd�Zdd�Zdd�Zed	d
��Z	�Z
S)r�zzUsed to 'head' the command output (f_src) to a given size
    without deadlocking sos. Takes a sizelimit value in MB.
    rLcs8t���||_||_|d|_||_d|_|��dS)NrLT)rrr�r��	remainingr[r�r)rr�r�r�r[rr4r5r�s

zHeadReader.__init__cCsZ|jdkrF|j�t|j|j��}|s&qF|j�|�|jt|�8_q|j��d|_	dS)z�Reads from the f_src (Popen stdout pipe) until we reach sizelimit.
        once done, close f_src to signal the program that we are done.
        rFN)
r1r�r?�min�COPY_BUFSIZEr�r�rr�r�)r�bufr4r4r5r(�s

zHeadReader.runcCs|js
dSdSr.r/r-r4r4r5r��szHeadReader.get_contentscCs
|jdkSr)r1r-r4r4r5r��szHeadReader.is_full)r�r�r)r*r3rr(r�r0r�r+r4r4rr5r��s	
r�cs<eZdZdZ�fdd�Zdd�Zdd�Zedd	��Z�Z	S)
r�z�Used to tail the command output to a given size without deadlocking
    sos.

    Takes a sizelimit value in MB, and will compile stdout from Popen into a
    string that is limited to the given sizelimit.
    cs^t���||_||_d|_d|_|r>|d}t||j�|_t|jd�|_d|_|�	�dS)NirL)�maxlenT)
rr�chanr[�	chunksize�slots�intrr�r)rZchannelr�r[rr4r5r�s
zTailReader.__init__c	CsHz&|j�|j�}|sq$|j�|�qWnttfy<Yn0d|_dS)alReads from the channel (pipe) that is the output pipe for a
        called Popen. As we are reading from the pipe, the output is added
        to a deque. After the size of the deque exceeds the sizelimit
        earlier (older) entries are removed.

        This means the returned output is chunksize-sensitive, but is not
        really byte-sensitive.
        FN)r6r?r7rr�r"rHr�)rrur4r4r5r(�s	zTailReader.runcCsD|jrt�d�q|js.d�dd�|jD��Sd�dd�|jD��S)z-Returns the contents of the deque as a stringr�r|css|]}|�dd�VqdS)rC�ignoreN)�decode�r^Zlnr4r4r5r`�raz*TailReader.get_contents.<locals>.<genexpr>racss|]
}|VqdSr\r4r<r4r4r5r`�ra)r�r�r�r[rprr-r4r4r5r��s
zTailReader.get_contentscCs|js
dSt|j�|jkS)z?Checks if the deque is full, implying that output was truncatedF)r8rrr-r4r4r5r��szTailReader.is_full)
r�r�r)r*rr(r�r0r�r+r4r4rr5r��s

r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
r
z�Provides a list of modules that can be imported in a package.
    Importable modules are located along the module __path__ list and modules
    are files that end in .py.
    cCs
||_dS)zopackage is a package module
        import my.package.module
        helper = ImporterHelper(my.package.module)N)�package)rr=r4r4r5r	szImporterHelper.__init__cCs tj�|�}tj�|�\}}|S)z-Returns the plugin module name given the path)r;ri�basename�splitext)rri�basersr1r4r4r5�_plugin_nameszImporterHelper._plugin_namecs�fdd�|D�}|��|S)Ncs(g|] }d|vr|�d�r��|��qS)rz.py)�endswithrA)r^Zpluginr-r4r5rs�z9ImporterHelper._get_plugins_from_list.<locals>.<listcomp>)�sort)rZlist_�pluginsr4r-r5�_get_plugins_from_lists

�z%ImporterHelper._get_plugins_from_listcCs0tj�|�r,ttd|��}|�|�}|r,|SgS)Nz*.py)r;rir�listrrE)rriZpy_filesZpnamesr4r4r5�_find_plugins_in_dirs
z#ImporterHelper._find_plugins_in_dircCs2g}|jjD] }tj�|�r|�|�|��q|S)zQReturns the list of importable modules in the configured python
        package. )r=�__path__r;rirrxrG)rrDrir4r4r5�get_modules$s
zImporterHelper.get_modulesN)	r�r�r)r*rrArErGrIr4r4r4r5r
sr
c@s$eZdZdd�Zdd�Zdd�ZdS)rcCs||_g|_dSr\)�tmp_dir�files)rrJr4r4r5r1szTempFileUtil.__init__cCs2tj|jd�\}}t�|d�}|j�||f�|S)Nr�zw+)r�ZmkstemprJr;�fdopenrKr�)r�fdrYZfobjr4r4r5�new5szTempFileUtil.newc	Csd|jD]R\}}z|��|��Wnty4Yn0zt�|�WqtyVYq0qg|_dSr\)rKr�r�r-r;�unlink)rrYrAr4r4r5�clean<szTempFileUtil.cleanN)r�r�r)rrNrPr4r4r4r5r/src@seZdZdS)rN)r�r�r)r4r4r4r5rLsr)T)rB)NN)N)F)N)r�NN)r9)Mr;r�r(r��
subprocessrrrZloggingrnr�r�r�r��	threadingr�rIr��
contextlibr�collectionsrZpackaging.versionrrr�Z
pkg_resourcesZ	getLoggerr.rcrdre�__file__�AttributeError�textwrapr	�msgr�r�__all__r6r7r"rrVrZrrrrrGr�r r!rrrrirrrrrrrlrrr�Threadr�r�r�r�r
rr�rr4r4r4r5�<module>	s�

"
	
	&

�
&
*




6'%<,
© 2026 UnknownSec