CasperSecurity

Current Path : /usr/lib/python3/dist-packages/ufw/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/ufw/__pycache__/applications.cpython-310.pyc

o

�Fa��@s�dZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
Z
e
jddkr0ddlZnddl
Z
dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)z'applications.py: common classes for ufw�N)�debug�warn)�UFWError�cCs6tj�|�std�}t|��d}i}t�|�}|��d}t�d�}|D�]s}|d|}tj�	|�s4q$|�
|�r@td|�q$|�d�s^|�d�s^|�d	�s^|�d
�s^|�d�s^|�d�retd
|�q$d}	z
t�
|�t
j}	Wnty�td�|}
t|
�Yq$w|	|kr�td�|}
t|
�q$||	|kr�td�|}
t|
�q$||	7}tjddkr�t��}nt��}z|�|�Wnty�td�|}
t|
�Yq$w|��D]�}t|�dkr�td�|}
t|
�q�t|�s�td�|}
t|
�q�ztj�|�td�|}
t|
�Wq�t�yYnwd}
|�|�D]2\}}t|�dk�r7td�|}
t|
�d}
nt|�dk�rOtd�||d�}
t|
�d}
n�q|
�rUq�||v�rdtd�|}
t|
�i}|�|�D]	\}}|||<�qkzt||�|||<Wq�t�y�}z
t|�WYd}~q�d}~wwq$|S)zwGet profiles found in profiles database.  Returns dictionary with
       profile name as key and tuples for fields
    z!Profiles directory does not existi�rz^\.�/zSkipping '%s': hidden filez	.dpkg-newz	.dpkg-oldz
.dpkg-distz.rpmnewz.rpmsave�~z
Skipping '%s'zSkipping '%s': couldn't statzSkipping '%s': too bigz*Skipping '%s': too many files read alreadyrzSkipping '%s': couldn't process�@zSkipping '%s': name too longzSkipping '%s': invalid namez$Skipping '%s': also in /etc/servicesFzSkipping '%s': field too longTiz4Skipping '%(value)s': value too long for '%(field)s')�value�fieldz(Duplicate profile '%s', using last foundN)�os�path�isdir�_r�listdir�sort�re�compile�isfile�searchr�endswith�stat�ST_SIZE�	Exceptionr�sys�version_info�ConfigParser�RawConfigParser�configparser�read�sections�len�valid_profile_name�ufw�util�get_services_proto�items�verify_profile)�profiles_dir�err_msg�max_size�profiles�files�
total_size�pat�f�abs_path�size�warn_msg�cdict�p�skip�keyr	�pdict�e�r8�2/usr/lib/python3/dist-packages/ufw/applications.py�get_profiles s�



�����
����

���3r:cCsB|dkrdSzt|�WdStyYnwt�d|�rdSdS)z0Only accept a limited set of characters for name�allFz ^[a-zA-Z0-9][a-zA-Z0-9 _\-\.+]*$T)�intrr�match)�namer8r8r9r!�s�r!c
Cs�gd�}|D]$}||vrtd�||d�}t|��||s*td�||d�}t|��q|d�d�}z,|D]&}tj�|�\}}|dkrOd|vsKd	|vrOt|��tj�d
||�}	t|	�q5Wd
St	yx}
zt|
�td�|}t|��d}
~
ww)z'Make sure profile has everything needed)�title�description�portsz/Profile '%(fn)s' missing required field '%(f)s')�fnr.z1Profile '%(fn)s' has empty required field '%(f)s'rA�|�any�:�,�ACCEPTzInvalid ports in profile '%s'NT)
rr�splitr"r#�parse_port_proto�common�UFWRulerr)r>�profile�
app_fieldsr.r(rAr3�port�proto�ruler7r8r8r9r&�s:���
����r&cC�$d}d}||vr||r||}|S)z#Retrieve the title from the profile�r?r8�rL�sr
r8r8r9�	get_title��
rUcCrQ)z)Retrieve the description from the profilerRr@r8rSr8r8r9�get_description�rVrWcCs*g}d}||vr||r||�d�}|S)z'Retrieve a list of ports from a profilerArC)rH)rLrAr
r8r8r9�	get_ports�s
rX)�__doc__rrr�ufw.utilr"rr�
ufw.commonrrrrrr:r!r&rUrWrXr8r8r8r9�<module>s"
x 		
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