![]() Server : Apache/2.4.52 (Ubuntu) System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 User : www-data ( 33) PHP Version : 8.1.2-1ubuntu2.21 Disable Function : NONE Directory : /lib/python3/dist-packages/twisted/protocols/__pycache__/ |
o �b� � @ s� d Z ddlZddlZddlZddlZddlZddlZz ddlZddlZW n e y1 d ZZY nw ddl mZmZ ddl mZ ddlmZmZmZmZ ddlmZmZmZmZmZ ddlmZmZ ddlmZmZm Z d Z!d Z"dZ#dZ$d Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7d Z8d!Z9d"Z:d#Z;d$Z<d%Z=d&Z>d'Z?d(Z@d)ZAd*ZBd+ZCd,ZDd-ZEd.ZFd/ZGd0ZHd1ZId2ZJd3ZKd4ZLd5ZMd6ZNd7ZOd8ZPd9ZQd:ZRd;ZSd<ZTd=ZUd>ZVd?ZWd@ZXdAZYdBZZi e!dC�e"dD�e#dE�e$dF�e%dG�e&dH�e'dI�e(dJ�e)dK�e*dLdMg�e+dN�e,dO�e-dP�e.dQ�e0dR�e/dS�e1dT�i e2dU�e3dV�e4dW�e5dX�e6dY�e7dZ�e8d[�e9d\�e:d]�e;d^�e<d_�e=d`�e>da�e?db�e@dc�eAdd�eBde��i eCdf�eDdg�eEdh�eFdi�eGdj�eHdk�eIdl�eJdm�eKdn�eLdo�eMdp�eNdq�eOdr�ePds�eQdt�eRdu�eSdv��eTdweVdxeWdyeUdzeXd{eYd|eZd}i�Z[G d~d� de\�Z]d�d�� Z^d�d�� Z_e�`d��Zad�d�d��ZbG d�d�� d�e\�ZcG d�d�� d�ec�ZdG d�d�� d�ec�ZeG d�d�� d�ec�ZfG d�d�� d�ec�ZgG d�d�� d�ec�ZhG d�d�� d�ec�ZiG d�d�� d�ec�ZjG d�d�� d�ec�ZkG d�d�� d�ec�ZlG d�d�� d�ec�ZmG d�d�� d�e\�ZnG d�d�� d�e\�ZoG d�d�� d�ec�ZpG d�d�� d�ec�Zqd�d�� Zrg d��Zseejt�G d�d�� d�eju��ZvG d�d�� d�ejw�ZxG d�d�� d��Zyeejt�G d�d�� d���ZzG d�d�� d�ej{�Z|G d�d�� d�ej{ej}�Z~G d�d�� d�ej�Z�G d�d�� d�e�Z�G d�d�� d�e�Z�G d�d�� d�e�Z�d�d�� Z�d�d�d��Z�ee��G d�d d�Z�ee��G d�dĄ dă�Z�G d�dƄ d�e��Z�ee��G d�dȄ dȃ�Z�eej��G d�dʄ dʃ�Z�G d�d̄ d�e��Z�G d�d΄ d�e��Z�G d�dЄ d�en�Z�G d�d҄ d�en�Z�G d�dԄ d�en�Z�G d�dք d�en�Z�G d�d d�en�Z�G d�dڄ dڃZ�G d�d܄ d�eju�Z�G d�dބ d�ejt�Z�ee��G d�d� d�eju��Z�d�d� Z�d�d� Z�d�d� Z�G d�d� d�ej��Z�G d�d� d�ej{�Z�G d�d� d�ejw�Z�G d�d� d�e��Z�G d�d� d�ej{�Z�d�d� Z�dS )�z An FTP protocol implementation � N)� Interface�implementer)� copyright)�checkers�credentials�error�portal)�deferr � interfaces�protocol�reactor)�basic�policies)�failure�filepath�log�100�120�125�150z200.1z200.2z200.3�202z211.1z211.2�212�213�214�215z220.1z220.2z221.1z221.2�225z226.1z226.2�227�229z230.1z230.2�250z257.1z257.2z331.1z331.2�332�350z421.1z421.2�425�426�450�451�452�500�501z502.1z502.2�503�504z530.1z530.2�532z550.1z550.2z550.3z550.4z550.5z550.6z550.7�551�552�553z110 MARK yyyy-mmmmz120 service ready in %s minutesz3125 Data connection already open, starting transferz4150 File status okay; about to open data connection.z200 Command OKz200 Type set to %s.z200 PORT OKz5202 Command not implemented, superfluous at this sitez211 System status replyz 211-Features:z211 Endz212 %sz213 %sz214 help: %sz215 UNIX Type: L8z220 %sz220 Service readyz&221 Service closing control connectionz221 Goodbye.z1225 data connection open, no transfer in progressz226 Abort successfulz226 Transfer Complete.z227 Entering Passive Mode (%s).z,229 Entering Extended Passive Mode (|||%s|).z230 User logged in, proceedz2230 Anonymous login ok, access restrictions apply.z&250 Requested File Action Completed OKz257 "%s"z257 "%s" createdz331 Password required for %s.z8331 Guest login ok, type your email address as password.z332 Need account for login.z6350 Requested file action pending further information.z6421 Service not available, closing control connection.z9421 Too many users right now, try again in a few minutes.z425 Can't open data connection.z.426 Transfer aborted. Data connection closed.z/450 Requested action aborted. File unavailable.z8451 Requested action aborted. Local error in processing.z3452 Requested action aborted. Insufficient storage.z500 Syntax error: %sz#501 syntax error in argument(s) %s.z 502 Command '%s' not implementedz 502 Option '%s' not implemented.z&503 Incorrect sequence of commands: %sz'504 Not implemented for parameter '%s'.z$530 Please login with USER and PASS.z!530 Sorry, Authentication failed.z%532 Need an account for storing filesz"550 %s: No such file or directory.z550 %s: Permission denied.z:550 Anonymous users are forbidden to change the filesystemz%550 Cannot rmd, %s is not a directoryz550 %s: File existsz550 %s: is a directoryz"550 Requested action not taken: %sz551 Page type unknownzC552 Requested file action aborted, exceeded file storage allocationz5553 Requested action not taken, file name not allowedc @ s e Zd ZdZdS )�InvalidPathzL Internal exception used to signify an error during parsing a path. N)�__name__� __module__�__qualname__�__doc__� r3 r3 �7/usr/lib/python3/dist-packages/twisted/protocols/ftp.pyr. � s r. c C s� |� d�rg }n| dd� }|�d�D ]-}|dks|dkrq|dkr.|r)|�� qt| |��d|v s6d|v r;t| |��|�|� q|S )zn Normalize a path, as represented by a list of strings each representing one segment of the path. �/N�.� �..� )� startswith�split�popr. �append)�cwd�path�segs�sr3 r3 r4 � toSegments� s rB c C s� | t jkrt�t|��S | t jks| t jkrt�t|��S | t jkr)t�t |��S | t j kr5t�t|��S | t jkrAt�t |��S t�� S )z? Map C{OSError} and C{IOError} to standard FTP errors. )�errno�ENOENTr �fail�FileNotFoundError�EACCES�EPERM�PermissionDeniedError�ENOTDIR�IsNotADirectoryError�EEXIST�FileExistsError�EISDIR�IsADirectoryError)�er? r3 r3 r4 �errnoToFailure� s rQ �TESTc C s8 | sdS | d }t �|�}t�d|d�}||krdS dS )a� Helper for checking if a FTPShell `segments` contains a wildcard Unix expression. Only filename globbing is supported. This means that wildcards can only be presents in the last element of `segments`. @type segments: C{list} @param segments: List of path elements as used by the FTP server protocol. @rtype: Boolean @return: True if `segments` contains a globbing expression. F���rR � T)�fnmatch� translate�_testTranslation�replace)�segments� globCandidate�globTranslations�nonGlobTranslationsr3 r3 r4 �_isGlobbingExpression� s r] c @ � e Zd ZdZdd� Zdd� ZdS )�FTPCmdErrorz- Generic exception for FTP commands. c G s t j| g|�R � || _d S �N)� Exception�__init__�errorMessage)�self�msgr3 r3 r4 rb s zFTPCmdError.__init__c C s t | j | j S )zA Generate a FTP response message for this error. )�RESPONSE� errorCoderc �rd r3 r3 r4 �response s zFTPCmdError.responseN)r/ r0 r1 r2 rb ri r3 r3 r3 r4 r_ s r_ c @ � e Zd ZdZeZdS )rF zH Raised when trying to access a non existent file or directory. N)r/ r0 r1 r2 �FILE_NOT_FOUNDrg r3 r3 r3 r4 rF � rF c @ rj )�AnonUserDeniedErrorz[ Raised when an anonymous user issues a command that will alter the filesystem N)r/ r0 r1 r2 �ANON_USER_DENIEDrg r3 r3 r3 r4 rm " � rm c @ rj )rI z[ Raised when access is attempted to a resource to which access is not allowed. N)r/ r0 r1 r2 �PERMISSION_DENIEDrg r3 r3 r3 r4 rI + ro rI c @ rj )rK zE Raised when RMD is called on a path that isn't a directory. N)r/ r0 r1 r2 �IS_NOT_A_DIRrg r3 r3 r3 r4 rK 4 rl rK c @ rj )rM zA Raised when attempted to override an existing resource. N)r/ r0 r1 r2 �FILE_EXISTSrg r3 r3 r3 r4 rM < rl rM c @ rj )rO zC Raised when DELE is called on a path that is a directory. N)r/ r0 r1 r2 �IS_A_DIRrg r3 r3 r3 r4 rO D rl rO c @ rj )�CmdSyntaxErrorz0 Raised when a command syntax is wrong. N)r/ r0 r1 r2 � SYNTAX_ERRrg r3 r3 r3 r4 rt L rl rt c @ rj )�CmdArgSyntaxErrorz^ Raised when a command is called with wrong value or a wrong number of arguments. N)r/ r0 r1 r2 �SYNTAX_ERR_IN_ARGSrg r3 r3 r3 r4 rv T ro rv c @ rj )�CmdNotImplementedErrorzF Raised when an unimplemented command is given to the server. N)r/ r0 r1 r2 �CMD_NOT_IMPLMNTDrg r3 r3 r3 r4 rx ] rl rx c @ rj )�CmdNotImplementedForArgErrorze Raised when the handling of a parameter for a command is not implemented by the server. N)r/ r0 r1 r2 �CMD_NOT_IMPLMNTD_FOR_PARAMrg r3 r3 r3 r4 rz e ro rz c @ � e Zd ZdS )�FTPErrorN�r/ r0 r1 r3 r3 r3 r4 r} n � r} c @ r| )�PortConnectionErrorNr~ r3 r3 r3 r4 r� r r r� c @ rj )�BadCmdSequenceErrorzS Raised when a client sends a series of commands in an illogical sequence. N)r/ r0 r1 r2 �BAD_CMD_SEQrg r3 r3 r3 r4 r� v rl r� c @ rj )�AuthorizationErrorz2 Raised when client authentication fails. N)r/ r0 r1 r2 �AUTH_FAILURErg r3 r3 r3 r4 r� ~ rl r� c G s t jdt|� dd� d S )NzdebugDeferred(): %sT��debug)r re �str)rd �_r3 r3 r4 � debugDeferred� s r� ) N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc @ s� e Zd ZdZdZdZdZdZdd� Zdd� Z dd � Z d d� Zdd � Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� ZdS )"�DTPFN�latin-1c C s d| _ | jj�d � g | _d S �NT)�isConnected�factory�deferred�callback�_bufferrh r3 r3 r4 �connectionMade� s zDTP.connectionMadec C s$ d| _ | jd ur| j�d � d S d S �NF)r� �_onConnLostr� �rd �reasonr3 r3 r4 �connectionLost� s �zDTP.connectionLostc C s | j �|d � dS )zv Send a line to data channel. @param line: The line to be sent. @type line: L{bytes} s N�� transport�write�rd �liner3 r3 r4 �sendLine� s zDTP.sendLinec C sZ dd� } d} | |rdpd|� � ||dd� |dd� || t�|��d� �| j�}|| S ) a Helper method to format one entry's info into a text entry like: 'drwxrwxrwx 0 user group 0 Jan 01 1970 filename.txt' @param name: C{bytes} name of the entry (file or directory or link) @param size: C{int} size of the entry @param directory: evals to C{bool} - whether the entry is a directory @param permissions: L{twisted.python.filepath.Permissions} object representing that entry's permissions @param hardlinks: C{int} number of hardlinks @param modified: C{float} - entry's last modified time in seconds since the epoch @param owner: C{str} username of the owner @param group: C{str} group name of the owner @return: C{str} in the requisite format c S sB t �� }t| j | j| j| j| jd�}|j| jkrd| S d| S )N)�month�day�year�hour�minutez%(month)s %(day)02d %(year)5dz+%(month)s %(day)02d %(hour)02d:%(minute)02d)�time�gmtime�_months�tm_mon�tm_mday�tm_year�tm_hour�tm_min)�mtime�now�infor3 r3 r4 � formatDate� s �z.DTP._formatOneListResponse.<locals>.formatDatezY%(directory)s%(permissions)s%(hardlinks)4d %(owner)-9s %(group)-9s %(size)15d %(date)12s �d�-N� )� directory�permissions� hardlinks�owner�group�size�date)� shorthandr� r� �encode� _encoding)rd �namer� r� r� r� �modifiedr� r� r� �formatre r3 r3 r4 �_formatOneListResponse� s � �� �zDTP._formatOneListResponsec C s | � | j|g|�R � � d S r` )r� r� )rd r� ri r3 r3 r4 �sendListResponse� s zDTP.sendListResponsec C s | j �||�S r` �r� �registerProducer�rd �producer� streamingr3 r3 r4 r� � � zDTP.registerProducerc C s | j �� | j �� d S r` )r� �unregisterProducer�loseConnectionrh r3 r3 r4 r� � s zDTP.unregisterProducerc C s | j r | j�|�S td��)NzCrap damn crap damn crap damn)r� r� r� ra �rd �datar3 r3 r4 r� � s z DTP.writec C s2 z | j �|� W d S ty | j�� Y d S w r` )�_consr� � BaseExceptionr� �errback�rd �bytesr3 r3 r4 � _conswrite s �zDTP._conswritec C s( | j d ur| �|� d S | j�|� d S r` )r� r� r� r= r� r3 r3 r4 �dataReceived s zDTP.dataReceivedc C s | j �� d | _ | `|S r` )r� r� r� �rd �ignoredr3 r3 r4 �_unregConsumer s zDTP._unregConsumerc C s| | j d u sJ �|| _ | j �| d� | jD ]}| �|� qd | _| jr1t�� | _}|�| j � |S | j � � d | _ t�d �S r� )r� r� r� r� r� r �Deferredr� �addBothr� r� �succeed)rd �cons�chunkr� r3 r3 r4 �registerConsumer s zDTP.registerConsumerc C � | j �� d S r` )r� �resumeProducingrh r3 r3 r4 r� # r� zDTP.resumeProducingc C r� r` )r� �pauseProducingrh r3 r3 r4 r� & r� zDTP.pauseProducingc C r� r` )r� � stopProducingrh r3 r3 r4 r� ) r� zDTP.stopProducing)r/ r0 r1 r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r� r3 r3 r3 r4 r� � s* 6r� c @ sd e Zd ZdZe� Ze� Ze� ZeZdZ ddd�Z dd� Zdd � Zd d� Z dd � Zdd� Zdd� ZdS )� DTPFactorya Client factory for I{data transfer process} protocols. @ivar peerCheck: perform checks to make sure the ftp-pi's peer is the same as the dtp's @ivar pi: a reference to this factory's protocol interpreter @ivar _state: Indicates the current state of the DTPFactory. Initially, this is L{_IN_PROGRESS}. If the connection fails or times out, it is L{_FAILED}. If the connection succeeds before the timeout, it is L{_FINISHED}. @cvar _IN_PROGRESS: Token to signal that connection is active. @type _IN_PROGRESS: L{object}. @cvar _FAILED: Token to signal that connection has failed. @type _FAILED: L{object}. @cvar _FINISHED: Token to signal that connection was successfully closed. @type _FINISHED: L{object}. FNc C s: || _ || _t�� | _d| _|du rddlm} || _dS )z� Constructor @param pi: this factory's protocol interpreter @param peerHost: if peerCheck is True, this is the tuple that the generated instance will use to perform security checks Nr �r ) �pi�peerHostr r� r� �delayedCall�twisted.internetr �_reactor)rd r� r� r r3 r3 r4 rb N s zDTPFactory.__init__c C sN t jddd� | j| jurd S | j| _| �� t� }| |_| j|_|| j_ |S )N�DTPFactory.buildProtocolTr� ) r re �_state�_IN_PROGRESS� _FINISHED� cancelTimeoutr� r� r� �dtpInstance�rd �addr�pr3 r3 r4 � buildProtocol_ s r� c C s t jddd� | �� d S )NzdtpFactory.stopFactoryTr� )r re r� rh r3 r3 r4 �stopFactorym s zDTPFactory.stopFactoryc C sF t �d� | j| jur d S | j| _| j}d | _|�tt� d��� d S )Nz$timed out waiting for DTP connectionzDTPFactory timeout) r re r� r� �_FAILEDr� r� r� r �TimeoutError)rd r� r3 r3 r4 �timeoutFactoryq s zDTPFactory.timeoutFactoryc C s8 | j d ur| j �� rtjddd� | j �� d S d S d S )Nzcancelling DTP timeoutTr� )r� �activer re �cancelrh r3 r3 r4 r� { s �zDTPFactory.cancelTimeoutc C s$ t �d| � | j�|| j�| _d S )Nz'DTPFactory.setTimeout set to %s seconds)r re r� � callLaterr� r� )rd �secondsr3 r3 r4 � setTimeout� s zDTPFactory.setTimeoutc C s6 | j | jurd S | j| _ | j}d | _|�t|�� d S r` )r� r� r� r� r� r� )rd � connectorr� r� r3 r3 r4 �clientConnectionFailed� s z!DTPFactory.clientConnectionFailed)NN)r/ r0 r1 r2 �objectr� r� r� r� � peerCheckrb r� r� r� r� r r r3 r3 r3 r4 r� - s r� c @ s e Zd Zdd� Zdd� ZdS )�ASCIIConsumerWrapperc C sP || _ |j| _|j| _tjdksttj�dksJ d��tjdkr&|j| _d S d S )N� rT z6Unsupported platform (yea right like this even exists))r� r� r� �os�linesep�lenr� )rd r� r3 r3 r4 rb � s � �zASCIIConsumerWrapper.__init__c C s | j �|�tjd��S )Nr )r� r� rX r r r� r3 r3 r4 r� � s zASCIIConsumerWrapper.writeN)r/ r0 r1 rb r� r3 r3 r3 r4 r � s r c @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )�FileConsumerz� A consumer for FTP input that writes data to a file. @ivar fObj: a file object opened for writing, used to write data received. @type fObj: C{file} c C � || _ d S r` )�fObj�rd r r3 r3 r4 rb � � zFileConsumer.__init__c C s || _ |sJ �d S r` )r� r� r3 r3 r4 r� � � zFileConsumer.registerProducerc C s d | _ | j�� d S r` )r� r �closerh r3 r3 r4 r� � s zFileConsumer.unregisterProducerc C � | j �|� d S r` )r r� r� r3 r3 r4 r� � � zFileConsumer.writeN)r/ r0 r1 r2 rb r� r� r� r3 r3 r3 r4 r � s r c @ � e Zd ZdZdZdd� ZdS )�FTPOverflowProtocolz:FTP mini-protocol for when there are too many connections.r� c C s$ | � tt �| j�� | j�� d S r` )r� rf �TOO_MANY_CONNECTIONSr� r� r� r� rh r3 r3 r4 r� � s z"FTPOverflowProtocol.connectionMadeN)r/ r0 r1 r2 r� r� r3 r3 r3 r4 r � s r c s� e Zd ZdZdZed�\ZZZZ dZ dZdZdZ dZdZdZddgZg d �Zed d�ZejZdZd d� Z� fdd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Z dd � Z!d!d"� Z"d#d$� Z#d%d&� Z$d\d(d)�Z%d*d+� Z&d,d-� Z'd.d/� Z(d0d1� Z)d2d3� Z*d4d5� Z+d6d7� Z,d8d9� Z-d:d;� Z.d<d=� Z/d>d?� Z0d@dA� Z1dBdC� Z2dDdE� Z3dFdG� Z4dHdI� Z5dJdK� Z6dLdM� Z7dNdO� Z8dPdQ� Z9dRdS� Z:dTdU� Z;dVdW� Z<dXdY� Z=dZd[� Z>� Z?S )]�FTPa; Protocol Interpreter for the File Transfer Protocol @ivar state: The current server state. One of L{UNAUTH}, L{INAUTH}, L{AUTHED}, L{RENAMING}. @ivar shell: The connected avatar @ivar binary: The transfer mode. If false, ASCII. @ivar dtpFactory: Generates a single DTP for this session @ivar dtpPort: Port returned from listenTCP @ivar listenFactory: A callable with the signature of L{twisted.internet.interfaces.IReactorTCP.listenTCP} which will be used to create Ports for passive connections (mainly for testing). @ivar passivePortRange: iterator used as source of passive port numbers. @type passivePortRange: C{iterator} @cvar UNAUTH: Command channel is not yet authenticated. @type UNAUTH: L{int} @cvar INAUTH: Command channel is in the process of being authenticated. @type INAUTH: L{int} @cvar AUTHED: Command channel was successfully authenticated. @type AUTHED: L{int} @cvar RENAMING: Command channel is between the renaming command sequence. @type RENAMING: L{int} F� � NT�FEAT�QUIT)r �MDTM�PASV�SIZEzTYPE A;Ir rT r� c G s t | | }| �|� d S r` )rf r� )rd �key�argsre r3 r3 r4 �reply� s z FTP.replyc s&