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 :  /lib/python3/dist-packages/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

Current File : /lib/python3/dist-packages/__pycache__/problem_report.cpython-310.pyc
o

�v�f�h�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZddlmZejddkrRdd	lmZed
ZnddlmZdZGd
d�d�ZGdd�de�ZdS)z(Store, load, and handle problem reports.�N)�
encode_base64)�
MIMEMultipart)�MIMEBase)�MIMEText)�BytesIO�3)�IterableUserDictT)�UserDictFc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�CompressedValuez9Represent a ProblemReport value which is gzip compressed.NcCs(d|_||_d|_|r|�|�dSdS)zAInitialize an empty CompressedValue object with an optional name.NF)�	gzipvalue�name�legacy_zlib�	set_value)�self�valuer�r�0/usr/lib/python3/dist-packages/problem_report.py�__init__"s�zCompressedValue.__init__cCs4t�}tj|jd|dd��|�|��|_d|_dS)zSet uncompressed value.�wbr��mode�fileobj�mtimeFN)r�gzip�GzipFiler�write�getvaluerr
)rr�outrrrr/s

zCompressedValue.set_valuecCs2|jsdS|jrt�|j�Stjt|j�d���S)zReturn uncompressed value.N�r)rr
�zlib�
decompressrrr�read�rrrr�	get_value7s
zCompressedValue.get_valuecCsX|jsJ�|jr|�t�|j��dStjt|j�d�}	|�d�}|s&dS|�|�q)z5Write uncompressed value into given file-like object.NrT�)	rr
rrr rrrr!)r�file�gz�blockrrrrAs


�zCompressedValue.writecCs:|jsJ�|jrt|���Stt�d|jdd��d�S)z$Return length of uncompressed value.�<L���Nr)rr
�lenr#�int�struct�unpackr"rrr�__len__Qs
zCompressedValue.__len__cCs|����S)z.Behaves like splitlines() for a normal string.)r#�
splitlinesr"rrrr/YszCompressedValue.splitlines)NN)
�__name__�
__module__�__qualname__�__doc__rrr#rr.r/rrrrr
s


r
c@s�eZdZd%dd�Zd&dd�Zdd	�Zd
efdd�Zd
d�Ze	dd��Z
e	dd��Zd'dd�Zd'dd�Z
diddfdd�Zdd�Zdd�Ze	dd ��Ze	d!d"��Ze	d#d$��ZdS)(�
ProblemReport�CrashNcCs(|durt��}||d�|_t�|_dS)z�Initialize a fresh problem report.

        type can be 'Crash', 'Packaging', 'KernelCrash' or 'KernelOops'.
        date is the desired date/time string; if None (default), the
        current local time is used.
        N)�ProblemType�Date)�time�asctime�data�set�old_keys)r�type�daterrrr`szProblemReport.__init__Tc	Cs@|�|�|j��d}d}d}d}|rt|�}nd}|D]�}	|	�d�r�|r+|s+d}q|dur3|dus5J�|r�t�|	�}
|rF||�|
�7}q|dkr_|jdkrW|
�d�sWd|_	|j|
7_q|
�d�rtt
�t
j�}|�|�
|
��}qt
��}||�|
�7}qt|�dkr�|d	7}|	�d	�r�||	d
d�7}q||	d
d�7}q|r�|r�||��7}d}d}|r�|dur�z|�|�|�|�|j|<|s�d}Wn?Wnty�Yn	w|�|�|j|<|	�dd
�\}}ts�|�d
�}|��}|dk�r|dk�rt|���}d|_nd}d}q|du�r|�|�|j|<t|j���|_dS)a�Initialize problem report from a file-like object.

        If binary is False, binary data is not loaded; the dictionary key is
        created, but its value will be an empty string. If it is True, it is
        transparently uncompressed and available as dictionary byte array values.
        If binary is 'compressed', the compressed value is retained, and the
        dictionary value will be a CompressedValue object. This is useful if
        the compressed value is still useful (to avoid recompression if the
        file needs to be written back).

        file needs to be opened in binary mode.

        If key_filter is given, only those keys will be loaded.

        Files are in RFC822 format, but with case sensitive keys.
        NF� �
compressed���Tr�
�����:�ASCII�base64)�_assert_bin_moder:�clearr;�
startswith�base64�	b64decoder rr
r�
decompressobj�	MAX_WBITS�_strip_gzip_headerr*�endswith�flush�remove�_try_unicode�KeyError�split�_python2�decode�stripr
�encode�keysr<)rr%�binary�
key_filter�keyr�	b64_block�bd�remaining_keys�liner'rrr�loadns�







��


�
zProblemReport.loadc
Cs�|�|�t|t�r
|g}d}d}t|�}i}d}d}	|D]�}
|
�d�s�|
�dd�\}}ts3|�d�}||vr8n�d||<|�|�|�	�}|dkr�d}d	||<zkd}t
tj�
||�d
��U}	|D]J}
|
�d�r�|durn|duspJ�||r�t�|
�}|r�|	�|�|��q_|�d�r�t�tj�}|	�|�|�|���q_t��}|	�|�|��q_Wd�n1s�wYWnty�tdtj�
||���wn|
�d�r$q|r�td
d�
|���d|��vr�tddd�|��D���dS)z�Extract only one binary element from the problem_report

        Binary elements like kernel crash dumps can be very big. This method
        extracts directly files without loading the report into memory.
        Nr?rFrDrGFrHrATrrBzunable to open %szCannot find %s in reportz, z%s has no binary contentcSsg|]
\}}|dur|�qS�Fr)�.0�item�elementrrr�
<listcomp>sz.ProblemReport.extract_keys.<locals>.<listcomp>)rI�
isinstance�str�listrKrVrWrXrSrY�open�os�path�joinrLrMrr rrNrOrP�IOErrorrU�values�
ValueError�items)rr%�bin_keys�dirr^r�missing_keysr_r`rrbr'rrr�extract_keys�sn







�����
��(��zProblemReport.extract_keys�returnc
Cs�t�tj�}z:z1zt�tjd�tt�t�|d���WWt�tj|�WSty8YWt�tj|�WdSwt�tj|�wtj	yKYdSw)zgGet timestamp (seconds since epoch) from Date field

        Return None if it is not present.
        �Cr7N)
�locale�	getlocale�LC_TIME�	setlocaler+r8�mktime�strptimerU�Error)r�
orig_ctimerrr�
get_timestamps���zProblemReport.get_timestampcCsd|��vS)z~Check if the report has any keys which were not loaded.

        This could happen when using binary=False in load().
        N)rqr"rrr�has_removed_fields#sz ProblemReport.has_removed_fieldscCs4t|�tkr|D]}|dkrt|���sdSqdS)z0Check if the given strings contains binary data.� TF)r=�bytes�chr�isspace)�klass�string�crrr�
_is_binary*s�zProblemReport._is_binarycCs>t|�tkr|�|�sz|�d�WSty|YSw|S)z)Try to convert bytearray value to unicode�UTF-8)r=r�r�rX�UnicodeDecodeError)r�rrrrrT4s�zProblemReport._try_unicodeFc	Cs�|�|�g}g}|j��D]?}|r||jvrq|j|}t|d�r3|�|�r-|�|�q|�|�qt|t�sHt	|�dkrH|dsH|�|�q|�|�q|�
�d|vra|�d�|�dd�|�
�|D]�}|j|}t|d�s�t	|�dkr�|ddur�|d}nd}t	|�dko�|d}t|dd	�r�|d�
�}nt|dd
��}	|	�
�}Wd�n1s�wY|r�t	|�dkr�td|��|dur�t	|�|kr�|j|=qgt|t�r�|�d�}|�|�d
��d|vr�|�d�|�|�dd��n
|�d�|�|�|�d�qg|D�]K}|j|}d}d}
|��}|�|�d
��|�d�t|t��r@|�t�|j��|�d��q
d|�d�d}|�t�|��|�d�t�d�}
t�dtjtjtjd�}t|d��r�|
t	|�7}
t�||
�}
|�|�}|�r�|�t�|��|�d�n�t	|�dk�r�|ddu�r�|d}t|dd	��r�|d}	nt|dd
�}		|	�
d�}|
t	|�7}
t�||
�}
|du�r�|
|k�r�|�|�|� |�|j|=d}
n|�r�|�|�}|�r�|�t�|��|�d�nn�q�t|dd	��s|	�!�t	|�dk�r(|d�r(|
dk�r(td|t|d�f��|�r0|
|k�rX|�"�}|
�rK|t#�$d|
d@�7}|t#�$d|
d@�7}|�t�|��|�d��q
dS)a�Write information into the given file-like object.

        If only_new is True, only keys which have been added since the last
        load() are written (i. e. those returned by new_keys()).

        If a value is a string, it is written directly. Otherwise it must be a
        tuple of the form (file, encode=True, limit=None, fail_on_empty=False).
        The first argument can be a file name or a file-like object,
        which will be read and its content will become the value of this key.
        'encode' specifies whether the contents will be
        gzip compressed and base64-encoded (this defaults to True). If limit is
        set to a positive integer, the file is not attached if it's larger
        than the given limit, and the entire key will be removed. If
        fail_on_empty is True, reading zero bytes will cause an IOError.

        file needs to be opened in binary mode.

        Files are written in RFC822 format.
        �find�rDr6r�N�r!�rbzdid not get any data for field r�rGrCs:
 s
 s: s
: base64
 s
���rA�Tr$z)did not get any data for field %s from %sr(l��)%rIr:r[r<�hasattrr��appendrir
r*�sortrS�insertr!rlrprjrZr�replace�tellrL�	b64encoderr�crc32�compressobj�DEFLATEDrO�
DEF_MEM_LEVEL�compress�seek�truncate�closerRr,�pack)rr%�only_new�asckeys�binkeys�k�v�limit�
fail_on_empty�f�size�curr_pos�gzip_header�crc�bc�outblockr'rrrr?s�








�










�

�







��

��zProblemReport.writecCs�t�|�}z*t|d�}t�|d�|�|�|��W|r't�||j|jf�t�||j	�dS|r<t�||j|jf�t�||j	�w)aAdd this report's data to an already existing report file.

        The file will be temporarily chmod'ed to 000 to prevent frontends
        from picking up a hal-updated report file. If keep_times
        is True, then the file's atime and mtime restored after updating.
        �abrN)
rm�statrl�chmodrr��utime�st_atime�st_mtime�st_mode)r�
reportfile�
keep_times�str�rrr�add_to_existing�s



�zProblemReport.add_to_existing�cCs2|�|�t|j���}d}g}d|vr|�d�|�dd�|r;d}	|D]}
|
|vr:|�|
�|�|	|
�|	d7}	q%|D�]}|rG||vrGq=|j|}d}
t|t�rW|j}
n`t	|d�s�d}
t	|dd�rj|d}nt
|dd�}|�d	�r{|��}
n$t
�}tj|d
|dd�}	|�d
�}|r�|�|�n|��nq�|��}
|��n|�|�r�|�d	�r�|}
nt||�j}
|
r�tdd�}|�d	�r�|jdd|d�n
|jdd|d	d�|�|
�t|�|�|�q=t|�}t|�tkr�|�dd�}t|t�s�J�t|���}|dk�r|dk�r|��}||d|d7}q=|dk�rB||k�rB||d7}|�d��s5|d7}||� ��!dd�d7}q=t"|dd�}|jdd|dd�|�|�q=t"|dd�}|�dd�|�d|�t#�}|�$�D]\}}|�||��qq|D]}|�%|��q|�|�&��'d��|�d�dS)a�Write MIME/Multipart RFC 2822 formatted data into file.

        file must be a file-like object, not a path.  It needs to be opened in
        binary mode.

        If a value is a string or a CompressedValue, it is written directly.
        Otherwise it must be a tuple containing the source file and an optional
        boolean value (in that order); the first argument can be a file name or
        a file-like object, which will be read and its content will become the
        value of this key.  The file will be gzip compressed, unless the key
        already ends in .gz.

        attach_treshold specifies the maximum number of lines for a value to be
        included into the first inline text part. All bigger values (as well as
        all non-ASCII ones) will become an attachment, as well as text
        values bigger than 1 kB.

        Extra MIME preamble headers can be specified, too, as a dictionary.

        skip_keys is a set/list specifying keys which are filtered out and not
        written to the destination file.

        priority_fields is a set/list specifying the order in which keys should
        appear in the destination file.
        �r6rrDNr�r!r�z.gzrrTr$�applicationzx-gzipzContent-Disposition�
attachment)�filenamer�r�i�z: �
z:
 z
 )�_charsetz.txt�inlinerC)(rI�sortedr:r[rSr�rir
rr�rlrQr!rrrrr�rr�r�
add_header�set_payloadrr�r*r=r�rXrjr/�rstriprYr�rrrs�attach�	as_stringrZ)rr%�attach_treshold�
extra_headers�	skip_keys�priority_fieldsr[�text�attachments�counter�priority_fieldr�r��attach_valuer��io�gfr'�attr��lines�msg�arrr�
write_mime�s�


�







�





zProblemReport.write_mimecCs�t|d�sJ�|�dd��dd��dd���std|��t|t�sXt|d�sXt|t�rRt|�dksDt|�dkrRt|�d	krR|dd
vrRt|dd�sXt|dd�sXtd
|��|j	�
||�S)N�isalnum�.r��-�_z[key '%s' contains invalid characters (only numbers, letters, '.', '_', and '-' are allowed)rDr�r�)TFrr!zGvalue for key %s must be a string, CompressedValue, or a file reference)r�r�r�rrrir
�tupler*�	TypeErrorr:�__setitem__)rr�r�rrrr�~s �0��zProblemReport.__setitem__cCst|j���|jS)z�Return newly added keys.

        Return the set of keys which have been added to the report since it
        was constructed or loaded.
        )r;r:r[r<r"rrr�new_keys�szProblemReport.new_keyscCs�tr|�|�S|d}d}|d@r|||d7}|d@r1||dkr-|d7}||dks#|d7}|d@rI||dkrE|d7}||dks;|d7}|d@rQ|d7}||d	�S)
z0Strip gzip header from line and return the rest.r��
r�rD�r�r�N)rW�_strip_gzip_header_py2�r�rb�flags�offsetrrrrP�s&
��z ProblemReport._strip_gzip_headercCs�t|d�}d}|d@r|||d7}|d@r0t||�dkr,|d7}t||�dks |d7}|d@rLt||�dkrH|d7}t||�dks<|d7}|d@rT|d7}||d	�S)
z;Strip gzip header from line and return the rest. (Python 2)r�r�r�rDr�rr�r�N)�ordr�rrrr��s"��z$ProblemReport._strip_gzip_header_py2cCs@trt|�tksd|jvsJd��dSdSt|d�rJd��dS)z/Assert that given file object is in binary mode�bz"file stream must be in binary mode�encodingN)rWr=rrr�)r�r%rrrrI�s&zProblemReport._assert_bin_mode)r5N)TNrd)r0r1r2rrcrwr+r�r��classmethodr�rTrr�r�r�r�rPr�rIrrrrr4_s2

c@
	



'
�

r4)r3rzrrLr8�sysrr,rm�email.encodersr�email.mime.multipartr�email.mime.baser�email.mime.textrr�r�versionr	rrW�collectionsr
r4rrrr�<module>s 8@

Anon7 - 2022
AnonSec Team