CasperSecurity

Current Path : /usr/lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/twisted/python/__pycache__/zipstream.cpython-310.pyc

o

�b�%�@s�dZddlZddlZddlZddlZGdd�dej�ZGdd�d�ZGdd�de�Z	Gd	d
�d
e�Z
dZdd
�Zdd�Z
ddd�ZdS)z�
An incremental approach to unzipping files.  This allows you to unzip a little
bit of a file at a time, which means you can report progress as a file unzips.
�Nc@seZdZdZdd�ZdS)�ChunkingZipFilez~
    A L{zipfile.ZipFile} object which, with L{readfile}, also gives you access
    to a file-like object for each entry.
    cCs"|jdvr	td��|jstd��|�|�}|j�|jd�|j�tj�}|dd�tj	kr2t�
d��t�tj
|�}|j�|tj�}|tjrP|j�|tj�|jd@r[|�d�}n|�d	�}||jkrot�
d
|j|f��|jtjkr{t||j�S|jtjkr�t||j�St�
d|j|f��)z3
        Return file-like object for name.
        )�r�azread() requires mode "r" or "a"z3Attempt to read ZIP archive that was already closedr�z Bad magic number for file headerizutf-8�cp437z3File name in directory "%s" and header "%s" differ.z-Unsupported compression method %d for file %s)�mode�RuntimeError�fp�getinfo�seek�
header_offset�read�zipfile�sizeFileHeader�stringFileHeader�
BadZipfile�struct�unpack�structFileHeader�_FH_FILENAME_LENGTH�_FH_EXTRA_FIELD_LENGTH�	flag_bits�decode�
orig_filename�
compress_type�
ZIP_STORED�ZipFileEntry�
compress_size�ZIP_DEFLATED�DeflatedZipFileEntry)�self�name�zinfo�fheader�fname�	fname_str�r&�:/usr/lib/python3/dist-packages/twisted/python/zipstream.py�readfiles>






����zChunkingZipFile.readfileN)�__name__�
__module__�__qualname__�__doc__r(r&r&r&r'rsrc@sdeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
_FileEntrya!
    Abstract superclass of both compressed and uncompressed variants of
    file-like objects within a zip archive.

    @ivar chunkingZipFile: a chunking zip file.
    @type chunkingZipFile: L{ChunkingZipFile}

    @ivar length: The number of bytes within the zip file that represent this
    file.  (This is the size on disk, not the number of decompressed bytes
    which will result from reading it.)

    @ivar fp: the underlying file object (that contains pkzip data).  Do not
    touch this, please.  It will quite likely move or go away.

    @ivar closed: File-like 'closed' attribute; True before this file has been
    closed, False after.
    @type closed: L{bool}

    @ivar finished: An older, broken synonym for 'closed'.  Do not touch this,
    please.
    @type finished: L{int}
    cCs&||_|jj|_||_d|_d|_dS)zC
        Create a L{_FileEntry} from a L{ChunkingZipFile}.
        rFN)�chunkingZipFiler	�length�finished�closed�r r.r/r&r&r'�__init__[s


z_FileEntry.__init__cCsdS)zD
        Returns false because zip files should not be ttys
        Fr&�r r&r&r'�isattye�z_FileEntry.isattycCsd|_d|_|`dS)z/
        Close self (file-like object)
        T�N)r1r0r	r4r&r&r'�closeksz_FileEntry.closecs6d}t�fdd�d�D]
}||7}|dkr|Sq|S)z
        Read a line.
        �cs
��d�S)Nr7)r
r&r4r&r'�<lambda>xs
z%_FileEntry.readline.<locals>.<lambda>�
)�iter)r �line�byter&r4r'�readliness�z_FileEntry.readlinecCs|��}|r|St��)zi
        Implement next as file does (like readline, except raises StopIteration
        at EOF)
        )r?�
StopIteration)r �nextliner&r&r'�__next__~sz_FileEntry.__next__cCst|�S)z1
        Returns a list of all the lines
        )�listr4r&r&r'�	readlines�sz_FileEntry.readlinescC�|S�z/
        Returns an iterator (so self)
        r&r4r&r&r'�
xreadlines�r6z_FileEntry.xreadlinescCrErFr&r4r&r&r'�__iter__�r6z_FileEntry.__iter__cCrE�Nr&r4r&r&r'�	__enter__�sz_FileEntry.__enter__cCs|��dSrI)r8)r �exc_type�	exc_value�	tracebackr&r&r'�__exit__�sz_FileEntry.__exit__N)r)r*r+r,r3r5r8r?rB�nextrDrGrHrJrNr&r&r&r'r-Cs
r-c@�*eZdZdZdd�Zdd�Zd	dd�ZdS)
rzJ
    File-like object used to read an uncompressed entry in a ZipFile
    cCst�|||�d|_dS)Nr)r-r3�	readBytesr2r&r&r'r3�s
zZipFileEntry.__init__cC�|jSrI)rQr4r&r&r'�tell��zZipFileEntry.tellNcCsv|dur
|j|j}|dks|jrdS|jj�t||j|j��}|jt|�7_|j|jks6t|�|kr9d|_|S)Nrr9r7)r/rQr0r.r	r
�min�len)r �n�datar&r&r'r
�szZipFileEntry.readrI�r)r*r+r,r3rSr
r&r&r&r'r�s
rc@rP)
rzE
    File-like object used to read a deflated entry in a ZipFile
    cCs0t�|||�d|_d|_t�d�|_d|_dS)Nri�r9)r-r3�
returnedBytesrQ�zlib�
decompressobj�decomp�bufferr2r&r&r'r3�s

zDeflatedZipFileEntry.__init__cCrRrI)rZr4r&r&r'rS�rTzDeflatedZipFileEntry.tellNcCsd|jrdS|durF|jg}|�|j�|jj�|j|j	���|�|j�d��|�|j�
��d|_d|_d�|�}|jt
|�7_|St
|j�|kr�|jj�t|d|j|j	��}|j	t
|�7_	|s�|j|j�d�|j�
�}d|_d|_|jt
|�7_|S|j|j�|�7_t
|j�|ksM|jd|�}|j|d�|_|jt
|�7_|S)Nr9�Zr7i)r0r^�appendr]�
decompressr.r	r
r/rQ�flush�joinrZrVrU)r rW�resultrXr&r&r'r
�sF���
���zDeflatedZipFileEntry.readrIrYr&r&r&r'r�s
r�cCs,d}t|�}|��D]	}|t||�7}q
|S)zr
    Predict the number of chunks that will be extracted from the entire
    zipfile, given chunksize blocks.
    r)r�infolist�countFileChunks)�filename�	chunksize�totalchunks�zf�infor&r&r'�countZipFileChunks�s
rmcCs(t|j|�\}}|dkr|d7}|pdS)a9
    Count the number of chunks that will result from the given C{ZipInfo}.

    @param zipinfo: a C{zipfile.ZipInfo} instance describing an entry in a zip
    archive to be counted.

    @return: the number of chunks present in the zip file.  (Even an empty file
    counts as one chunk.)
    @rtype: L{int}
    rr7)�divmod�	file_size)�zipinfori�count�extrar&r&r'rgsrg�.�c	csl�t|d�}tj�|�st�|�t||�}|��}|��}t||�D]�\}}	|	j	t
@}
tj�||�}|
rHtj�|�s@t�|�|d8}|Vq#tj�|�d}tj�|�s[t�|�|sctj�|�s�|�
|�}
|	jdkrt|d8}|Vt|d��'}|
��|	jkr�|
�|�}|�|�|d8}|V|
��|	jks�Wd�n1s�wYq#|t|	|�8}|Vq#dS)z�
    Return a generator for the zipfile.  This implementation will yield after
    every chunksize uncompressed bytes, or at the end of a file, whichever
    comes first.

    The value it yields is the number of chunks left to unzip.
    rr7r�wbN)r�os�path�exists�makedirsrm�namelistrf�zip�
external_attr�DIR_BITrc�splitr(ro�openrSr
�writerg)rh�	directory�	overwriteri�czf�	remaining�names�infos�entryrl�isdir�f�fdirr	�outfile�hunkr&r&r'�unzipIterChunkysH�









�����r�)rsrrt)r,�os.pathrvrrr[�ZipFilerr-rrr}rmrgr�r&r&r&r'�<module>s3a8
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