404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.142.249.163: ~ $
3

Kl�f�.�@szdZddlmZddlmZddlmZdd�ZGdd	�d	ej�Zd
d�Z	Gdd
�d
�Z
dd�Zdd�ZGdd�d�Z
dS)aV
Classes representing basic access.

SELinux - at the most basic level - represents access as
the 4-tuple subject (type or context), target (type or context),
object class, permission. The policy language elaborates this basic
access to faciliate more concise rules (e.g., allow rules can have multiple
source or target types - see refpolicy for more information).

This module has objects for representing the most basic access (AccessVector)
and sets of that access (AccessVectorSet). These objects are used in Madison
in a variety of ways, but they are the fundamental representation of access.
�)�	refpolicy)�util�)�	audit2whycCsNt|�dkrF|ddkrFyt|dd��Wntk
r@dSXdSdSdS)z�Determine if an id is a paramater in the form $N, where N is
    an integer.

    Returns:
      True if the id is a paramater
      False if the id is not a paramater
    rr�$NFT)�len�int�
ValueError)�id�r�/usr/lib/python3.6/access.py�
is_idparam'sr
c@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�AccessVectora
    An access vector is the basic unit of access in SELinux.

    Access vectors are the most basic representation of access within
    SELinux. It represents the access a source type has to a target
    type in terms of an object class and a set of permissions.

    Access vectors are distinct from AVRules in that they can only
    store a single source type, target type, and object class. The
    simplicity of AccessVectors makes them useful for storing access
    in a form that is easy to search and compare.

    The source, target, and object are stored as string. No checking
    done to verify that the strings are valid SELinux identifiers.
    Identifiers in the form $N (where N is an integer) are reserved as
    interface parameters and are treated as wild cards in many
    circumstances.

    Properties:
     .src_type - The source type allowed access. [String or None]
     .tgt_type - The target type to which access is allowed. [String or None]
     .obj_class - The object class to which access is allowed. [String or None]
     .perms - The permissions allowed to the object class. [IdSet]
     .audit_msgs - The audit messages that generated this access vector [List of strings]
     .xperms - Extended permissions attached to the AV. [Dictionary {operation: xperm set}]
    NcCsV|r|j|�nd|_d|_d|_tj�|_g|_tj	|_
g|_i|_d|_
d|_dS)N)�	from_list�src_type�tgt_type�	obj_classr�IdSet�perms�
audit_msgsr�TERULE�type�data�xperms�__hash__Z
info_flow_dir)�selfZ	init_listrrr�__init__Ss
zAccessVector.__init__cCsRt|�dkrtdt|���|d|_|d|_|d|_tj|dd��|_dS)axInitialize an access vector from a list.

        Initialize an access vector from a list treating the list as
        positional arguments - i.e., 0 = src_type, 1 = tgt_type, etc.
        All of the list elements 3 and greater are treated as perms.
        For example, the list ['foo_t', 'bar_t', 'file', 'read', 'write']
        would create an access vector list with the source type 'foo_t',
        target type 'bar_t', object class 'file', and permissions 'read'
        and 'write'.

        This format is useful for very simple storage to strings or disc
        (see to_list) and for initializing access vectors.
        �z+List must contain at least four elements %srr��N)	rr	�strrrrrrr)r�listrrrrhs


zAccessVector.from_listcCs$|j|j|jg}|jt|j��|S)z�
        Convert an access vector to a list.

        Convert an access vector to a list treating the list as positional
        values. See from_list for more information on how an access vector
        is represented in a list.
        )rrr�extend�sortedr)r�lrrr�to_list}szAccessVector.to_listcCsP|jj|j�x<|jD]2}||jkr2tj�|j|<|j|j|j|�qWdS)z0Add permissions and extended permissions from AVN)r�updaterrZXpermSetr")r�av�oprrr�merge�s

zAccessVector.mergecCs|j�S)N)�	to_string)rrrr�__str__�szAccessVector.__str__cCsd|j|j|j|jj�fS)Nzallow %s %s:%s %s;)rrrrZto_space_str)rrrrr*�s
zAccessVector.to_stringcCspyRt|j�}|j|j|j|f}t|j�}|j�|j�|j|j|j|f}|||�Sttfk
rjtSXdS)N)	r!rrrr�sort�AttributeError�	TypeError�NotImplemented)r�other�method�x�a�y�brrr�_compare�s


zAccessVector._compare)N)�__name__�
__module__�__qualname__�__doc__rrr%r)r+r*r6rrrrr8s
	rcCsvt|t�r|gSg}x\|jD]R}xL|jD]B}x<|jD]2}t�}||_||_||_|jj	�|_|j
|�q4Wq(WqW|S)aQConvert an avrule into a list of access vectors.

    AccessVectors and AVRules are similary, but differ in that
    an AVRule can more than one source type, target type, and
    object class. This function expands a single avrule into a
    list of one or more AccessVectors representing the access
    defined in the AVRule.

    
    )�
isinstancerZ	src_typesZ	tgt_typesZobj_classesrrrr�copy�append)Zavruler3rrr�accessrrr�avrule_to_access_vectors�s
r?c@sTeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zde	j
gfd
d�Zddd�ZdS)�AccessVectorSeta/A non-overlapping set of access vectors.

    An AccessVectorSet is designed to store one or more access vectors
    that are non-overlapping. Access can be added to the set
    incrementally and access vectors will be added or merged as
    necessary.  For example, adding the following access vectors using
    add_av:
       allow $1 etc_t : read;
       allow $1 etc_t : write;
       allow $1 var_log_t : read;
    Would result in an access vector set with the access vectors:
       allow $1 etc_t : { read write};
       allow $1 var_log_t : read;
    cCsi|_d|_dS)z)Initialize an access vector set.
        N)�srcZinfo_dir)rrrrr�szAccessVectorSet.__init__ccsBx<|jj�D].}x(|j�D]}x|j�D]
}|Vq(WqWqWdS)z9Iterate over all of the unique access vectors in the set.N)rA�values)r�tgts�objsr'rrr�__iter__�szAccessVectorSet.__iter__cCs:d}x0|jj�D]"}x|j�D]}|t|�7}qWqW|S)a5Return the number of unique access vectors in the set.

        Because of the inernal representation of the access vector set,
        __len__ is not a constant time operation. Worst case is O(N)
        where N is the number of unique access vectors, but the common
        case is probably better.
        r)rArBr)rr$rCrDrrr�__len__�s
zAccessVectorSet.__len__cCs$g}x|D]}|j|j��q
W|S)abReturn the unique access vectors in the set as a list.

        The format of the returned list is a set of nested lists,
        each access vector represented by a list. This format is
        designed to be simply  serializable to a file.

        For example, consider an access vector set with the following
        access vectors:
          allow $1 user_t : file read;
          allow $1 etc_t : file { read write};
        to_list would return the following:
          [[$1, user_t, file, read]
           [$1, etc_t, file, read, write]]

        See AccessVector.to_list for more information.
        )r=r%)rr$r'rrrr%�s
zAccessVectorSet.to_listcCs x|D]}|jt|��qWdS)aAdd access vectors stored in a list.

        See to list for more information on the list format that this
        method accepts.

        This will add all of the access from the list. Any existing
        access vectors in the set will be retained.
        N)�add_avr)rr$r'rrrrs	
zAccessVectorSet.from_listNc	Cs:t�}||_||_||_||_||_||_|j||�dS)z)Add an access vector to the set.
        N)rrrrrrrrG)	rrrrr�	audit_msgZavc_typerr'rrr�addszAccessVectorSet.addcCsv|jj|ji�}|j|ji�}|j|jf|krF||j|jfj|�n|||j|jf<|rr||j|jfjj|�dS)z Add an access vector to the set.N)	rA�
setdefaultrrrrr)rr=)rr'rHZtgt�clsrrrrGszAccessVectorSet.add_av)N)
r7r8r9r:rrErFr%rrrrIrGrrrrr@�s	
r@cCs2tj�}x$|D]}|j|j�|j|j�qW|S)N)rrrIrr)�avs�typesr'rrr�avs_extract_types*s

rNcCsJi}x@|D]8}|j|kr$||j}ntj�}|||j<|j|j�q
W|S)N)rrrr&r)rLrr'�srrr�avs_extract_obj_perms2s


rPc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�RoleTypeSetz�A non-overlapping set of role type statements.

    This clas allows the incremental addition of role type statements and
    maintains a non-overlapping list of statements.
    cCs
i|_dS)z Initialize an access vector set.N)�
role_types)rrrrrCszRoleTypeSet.__init__ccsx|jj�D]
}|VqWdS)zAIterate over all of the unique role allows statements in the set.N)rRrB)r�	role_typerrrrEGszRoleTypeSet.__iter__cCst|jj��S)z2Return the unique number of role allow statements.)rrR�keys)rrrrrFLszRoleTypeSet.__len__cCs>||jkr|j|}ntj�}||_||j|<|jj|�dS)N)rRrZRoleType�rolerMrI)rrUrrSrrrrIPs

zRoleTypeSet.addN)r7r8r9r:rrErFrIrrrrrQ=s
rQN)r:�rrZselinuxrr
Z
Comparisonrr?r@rNrPrQrrrr�<module> soj

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
access.cpython-36.opt-1.pyc File 11.02 KB 0644
access.cpython-36.pyc File 11.02 KB 0644
audit.cpython-36.opt-1.pyc File 17.29 KB 0644
audit.cpython-36.pyc File 17.29 KB 0644
classperms.cpython-36.opt-1.pyc File 2.43 KB 0644
classperms.cpython-36.pyc File 2.43 KB 0644
defaults.cpython-36.opt-1.pyc File 2.19 KB 0644
defaults.cpython-36.pyc File 2.19 KB 0644
interfaces.cpython-36.opt-1.pyc File 12.25 KB 0644
interfaces.cpython-36.pyc File 12.25 KB 0644
lex.cpython-36.opt-1.pyc File 20.92 KB 0644
lex.cpython-36.pyc File 20.92 KB 0644
matching.cpython-36.opt-1.pyc File 5.95 KB 0644
matching.cpython-36.pyc File 5.95 KB 0644
module.cpython-36.opt-1.pyc File 6.95 KB 0644
module.cpython-36.pyc File 6.95 KB 0644
objectmodel.cpython-36.opt-1.pyc File 3.83 KB 0644
objectmodel.cpython-36.pyc File 3.83 KB 0644
output.cpython-36.opt-1.pyc File 3.42 KB 0644
output.cpython-36.pyc File 3.42 KB 0644
policygen.cpython-36.opt-1.pyc File 12.52 KB 0644
policygen.cpython-36.pyc File 12.57 KB 0644
refparser.cpython-36.opt-1.pyc File 28.38 KB 0644
refparser.cpython-36.pyc File 28.38 KB 0644
refpolicy.cpython-36.opt-1.pyc File 39.9 KB 0644
refpolicy.cpython-36.pyc File 39.9 KB 0644
sepolgeni18n.cpython-36.opt-1.pyc File 304 B 0644
sepolgeni18n.cpython-36.pyc File 304 B 0644
util.cpython-36.opt-1.pyc File 6.22 KB 0644
util.cpython-36.pyc File 6.22 KB 0644
yacc.cpython-36.opt-1.pyc File 52.77 KB 0644
yacc.cpython-36.pyc File 52.86 KB 0644