CasperSecurity

Current Path : /lib/python3/dist-packages/debian/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/debian/__pycache__/debfile.cpython-310.pyc

o

a~bM>�@stdZddlZddlZddlZddlZddlZz$ddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZddlmZWneyIesGdd�ZYnwddlmZmZmZddlmZdd	lmZd
ZdZ gd�Z!d
Z"gd�Z#dZ$dZ%dZ&dZ'Gdd�de�Z(Gdd�de)�Z*Gdd�de*�Z+Gdd�de*�Z,Gdd�de�Z-e.dkr�e-ej/dd�Z0e0j1�2�Z2e3e2�4d��dSdS) zX Representation of Debian binary package (.deb) files


Debfile Classes
===============
�N)�Any�BinaryIO�Dict�IO�Iterator�List�Optional�Text�TypeVar�Union�overload�
TYPE_CHECKING)�LiteralcC�dS�N�)�frr�0/usr/lib/python3/dist-packages/debian/debfile.py�<lambda>4sr)�ArFile�ArError�ArMember)�	Changelog)�Deb822zdata.tarzcontrol.tar)�gz�bz2�xz�lzma�zstz
debian-binary)�preinst�postinst�prerm�postrm�config�controlzusr/share/doc/%s/changelog.gzz$usr/share/doc/%s/changelog.Debian.gz�md5sumsc@�eZdZdS)�DebErrorN��__name__�
__module__�__qualname__rrrrr'Hsr'c@s�eZdZdZdd�Zdd�Zedd��Zdd	�Ze	ddd��Z
e	dd
d��Z
ddd�Z
e		
	
ddd��Ze		
ddd��Z	
	
ddd�Zdd�Zdd�Z
dd�Zdd�Zd
S)�DebParta�'Part' of a .deb binary package.

    A .deb package is considered as made of 2 parts: a 'data' part
    (corresponding to the possibly compressed 'data.tar' archive embedded
    in a .deb) and a 'control' part (the 'control.tar.gz' archive). Each of
    them is represented by an instance of this class. Each archive should
    be a compressed tar archive although an uncompressed data.tar is permitted;
    supported compression formats are: .tar.gz, .tar.bz2, .tar.xz .

    When referring to file members of the underlying .tar.gz archive, file
    names can be specified in one of 3 formats "file", "./file", "/file". In
    all cases the file is considered relative to the root of the archive. For
    the control part the preferred mechanism is the first one (as in
    deb.control.get_content('control') ); for the data part the preferred
    mechanism is the third one (as in deb.data.get_file('/etc/vim/vimrc') ).
    cCs||_d|_dSr)�_DebPart__member�
_DebPart__tgz)�self�memberrrr�__init__^s
zDebPart.__init__c
s��fdd�}�jdur^�jj}tj�|�ddd�}|tvs'|tks'|tkrX|dkr2|ddg�}n�j}zt	j
|dd	��_W�jSt	jt	jfyW}zt
d
|��d}~wwt
d|���jS)z�Return a TarFile object corresponding to this part of a .deb
        package.

        Despite the name, this method gives access to various kind of
        compressed tar archives, not only gzipped ones.
        c
s�zddl}ddl�ddl}|j||j|jd�fdd�d�}Wnttfy2}ztd|��d}~ww|��j	�
��d}|jdkrItd|j��|�|�S)NrFcs���j�j�Sr)�signal�SIGPIPE�SIG_DFLr�r2rrrxsz9DebPart.tgz.<locals>._custom_decompress.<locals>.<lambda>)�stdin�stdout�universal_newlines�
preexec_fnz%sz!command has failed with code '%s')
�
subprocessr2�io�Popen�PIPE�OSError�
ValueErrorr'�communicater-�read�
returncode�BytesIO)�command_listr:r;�proc�e�data�r/r5r�_custom_decompressls(

���
�
z'DebPart.tgz.<locals>._custom_decompressN�r�unzstdz--stdoutzr:*)�fileobj�modez#tarfile has returned an error: '%s'z"part '%s' has unexpected extension)r.r-�name�os�path�splitext�	PART_EXTS�	DATA_PART�	CTRL_PART�tarfile�open�	ReadError�CompressionErrorr')r/rIrN�	extension�bufferrFrrHr�tgzcs"	
���zDebPart.tgzcCs4|�d�r
|dd�}|S|�d�r|dd�}|S)zw try (not so hard) to obtain a member file name in a form relative
        to the .tar.gz root and with no heading '.' �./�N�/rJ)�
startswith)�fnamerrr�__normalize_member�s

�zDebPart.__normalize_membercCs"t�|�}|����}d||vS)z.Check if this part contains a given file name.r\)r,�_DebPart__normalize_memberr[�getnames)r/r`�namesrrr�has_file�s
zDebPart.has_fileNcCrrr�r/r`�encoding�errorsrrr�get_file��zDebPart.get_filecCrrrrfrrrri�rjcCsHt�|�}|���d|�}|durtd��|dur"tj|||d�S|S)z�Return a file object corresponding to a given file name.

        If encoding is given, then the file object will return Unicode data;
        otherwise, it will return binary data.
        r\NzFile not found inside package�rgrh)r,rbr[�extractfiler'r;�
TextIOWrapper)r/r`rgrh�fobjrrrri�s
cCrrrrfrrr�get_content��zDebPart.get_contentcCrrrrfrrrro�rpcCs,|j|||d�}d}|r|��}|��|S)z�Return the string content of a given file, or None (e.g. for
        directories).

        If encoding is given, then the content will be a Unicode object;
        otherwise, it will contain binary data.
        rkN)rirA�close)r/r`rgrhr�contentrrrro�s
cCst|�����Sr)�iterr[rcrHrrr�__iter__�szDebPart.__iter__cC�
|�|�Sr)re�r/r`rrr�__contains__��
zDebPart.__contains__cCrur)rorvrrr�__getitem__�rxzDebPart.__getitem__cCs|j��dSr)r-rqrHrrrrq�sz
DebPart.close�NNr)r)r*r+�__doc__r1r[�staticmethodrbrerrirortrwryrqrrrrr,Ls45

��

�r,c@r&)�DebDataNr(rrrrr}sr}c@sBeZdZdd�Zdd�Zed
dd��Zeddd��Zd
d	d�ZdS)�
DebControlcCs6i}tD]}|�|�r|�|�}|dur|||<q|S)zo Return a dictionary of maintainer scripts (postinst, prerm, ...)
        mapping script names to script text. N)�
MAINT_SCRIPTSrero)r/�scriptsr`rGrrrr�s

�zDebControl.scriptscCst|�t��S)z� Return the debian/control as a Deb822 (a Debian-specific dict-like
        class) object.

        For a string representation of debian/control try
        .get_content('control') )rro�CONTROL_FILErHrrr�
debcontrolszDebControl.debcontrolNcCrrr�r/rgrhrrrr%rjzDebControl.md5sumscCrrrr�rrrr%$rjc	Cs�|�t�stdt��|jt||d�}i}d}|durd}|��D]}|�|��dd�\}}t|t�r:|�	�||<q!|||<q!|�
�|S)a� Return a dictionary mapping filenames (of the data part) to
        md5sums. Fails if the control part does not contain a 'md5sum' file.

        Keys of the returned dictionary are the left-hand side values of lines
        in the md5sums member of control.tar.gz, usually file names relative to
        the file system root (without heading '/' or './').

        The returned keys are Unicode objects if an encoding is specified,
        otherwise binary. The returned values are always Unicode.z('%s' file not found, can't list MD5 sumsrkz
Ns
rJ)re�MD5_FILEr'ri�	readlines�rstrip�split�
isinstance�bytes�decoderq)	r/rgrh�md5_file�sums�newline�line�md5r`rrrr%)s 
�

rzr)r)r*r+r�r�rr%rrrrr~s
r~c@s�eZdZdZddd�Zdd�Zedd	��Zed
d��Zedd
��Z	dd�Z
dd�Zeddd��Z
ed dd��Z
ddd�Z
dd�Zdd�Zdd�Zdd�ZdS)!�DebFilea�Representation of a .deb file (a Debian binary package)

    DebFile objects have the following (read-only) properties:
        - version       debian .deb file format version (not related with the
                        contained package version), 2.0 at the time of writing
                        for all .deb packages in the Debian archive
        - data          DebPart object corresponding to the data.tar.gz (or
                        other compressed or uncompressed tar) archive contained
                        in the .deb file
        - control       DebPart object corresponding to the control.tar.gz (or
                        other compressed tar) archive contained in the .deb
                        file
    N�rcs�t�||||�t|�����fdd�}t�vrtdt��i|_t|�|t	���|jt	<t
|�|t���|jt<d|_|�t�}|�
���|_|��dS)Ncsj�fdd�tD�}�ttfvr|�����t|��}|s#td|��t|�dkr/td|��t|�dS)Ncsg|]}d�|f�qS)z%s.%sr)�.0�ext��basenamerr�
<listcomp>bszBDebFile.__init__.<locals>.compressed_part_name.<locals>.<listcomp>z9missing required part in given .deb (expected one of: %s)rJz>too many parts in given .deb (was looking for only one of: %s)r)	rRrSrT�append�intersection�setr'�len�list)r��
candidates�parts��actual_namesr�r�compressed_part_name`s"
����z.DebFile.__init__.<locals>.compressed_part_namez4missing required part in given .deb (expected: '%s'))rr1r�rc�	INFO_PARTr'�_DebFile__partsr~�	getmemberrTr}rS�_DebFile__pkgnamerA�strip�_DebFile__versionrq)r/�filenamerMrLr�rrr�rr1[s(����
zDebFile.__init__cCs|��d|_dS)N�package)r�r�rHrrr�__updatePkgName�szDebFile.__updatePkgNamecCs|jSr)r�rHrrr�version�szDebFile.versioncC�
|jtSr)r�rSrHrrrrG��
zDebFile.datacCr�r)r�rTrHrrrr$�r�zDebFile.controlcC�
|j��S)z See .control.debcontrol() )r$r�rHrrrr��r�zDebFile.debcontrolcCr�)z See .control.scripts() )r$r�rHrrrr��r�zDebFile.scriptscCrrrr�rrrr%�rjzDebFile.md5sumscCrrrr�rrrr%�rjcCs|jj||d�S)z See .control.md5sums() rk)r$r%r�rrrr%�scCsl|jdur	|��t|jt|jfD] }|j�|�r3tj|j�|�d�}|�	�}|�
�t|�SqdS)z� Return a Changelog object for the changelog.Debian.gz of the
        present .deb package. Return None if no changelog can be found. N)rL)r��_DebFile__updatePkgName�CHANGELOG_DEBIAN�CHANGELOG_NATIVErGre�gzip�GzipFilerirArqr)r/r`r�
raw_changelogrrr�	changelog�s
��zDebFile.changelogcCs|j��|j��dSr)r$rqrGrHrrrrq�s
z
DebFile.closecCs|SrrrHrrr�	__enter__�szDebFile.__enter__cCs|��dSr)rq)r/�exc_type�exc_val�exc_tbrrr�__exit__�szDebFile.__exit__)Nr�Nrzr)r)r*r+r{r1r��propertyr�rGr$r�r�rr%r�rqr�r�rrrrr�Ks*
(



r��__main__rJ)r�)5r{r�r;rU�sys�os.pathrO�typingrrrrrrrr	r
rrr
�typing_extensionsr�ImportError�
debian.arfilerrr�debian.changelogr�
debian.deb822rrSrTrRr�rr�r�r�r�r'�objectr,r}r~r�r)�argv�debr$r[�printr�rrrr�<module>sL8��5F
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY