Tryag File Manager
Home
-
Turbo Force
Current Path :
/
proc
/
self
/
root
/
usr
/
lib
/
python2.4
/
site-packages
/
sepolgen
/
Upload File :
New :
File
Dir
//proc/self/root/usr/lib/python2.4/site-packages/sepolgen/audit.pyc
mò ö"žQc�����������@���sî���d��k��Z��d��k�Z�d��k�Z�d�„��Z�d�„��Z�d�f��d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ�d �e�f�d �„��ƒ��YZ�d�e�f�d�„��ƒ��YZ �d �e�f�d�„��ƒ��YZ �d�e�f�d�„��ƒ��YZ�d�f��d�„��ƒ��YZ�d�f��d�„��ƒ��YZ �d��S(���Nc����������C���s8���d�k��}�|�i�d�d�d�g�d�|�i�ƒi�ƒ��d�}��|��S(���s ��Obtain all of the avc and policy load messages from the audit log. This function uses ausearch and requires that the current process have sufficient rights to run ausearch. Returns: string contain all of the audit messages returned by ausearch. Ns���/sbin/ausearchs���-ms)���AVC,USER_AVC,MAC_POLICY_LOAD,DAEMON_STARTt���stdouti����(���t ���subprocesst���Popent���PIPEt���communicatet���output(���R���R���(����(����t2���/usr/lib/python2.4/site-packages/sepolgen/audit.pyt���get_audit_msgs���s ����� c����������C���s2���d�k��}�|�i�d�g�d�|�i�ƒi�ƒ��d�}��|��S(���s•���Obtain all of the avc and policy load messages from /bin/dmesg. Returns: string contain all of the audit messages returned by dmesg. Ns ���/bin/dmesgR����i����(���R���R���R���R���R���(���R���R���(����(����R���t���get_dmesg_msgs'���s ����� t���AuditMessagec�����������B���s ���t��Z�d��Z�d�„��Z�d�„��Z�RS(���sã���Base class for all objects representing audit messages. AuditMessage is a base class for all audit messages and only provides storage for the raw message (as a string) and a parsing function that does nothing. c���������C���s���|�|��_��d�|��_�d��S(���Nt����(���t���messaget���selft���header(���R���R���(����(����R���t���__init__;���s���� c���������C���s†���x�|�D]w�}�|�i�d�ƒ�}�t�|�ƒ�d�j�o)�|�d� d�j�o�|�|��_�d�SqX�q�n�|�d�d�j�o�|�d�|��_�d�Sq�q�Wd�S( ���sà���Parse a string that has been split into records by space into an audit message. This method should be overridden by subclasses. Error reporting should be done by raise ValueError exceptions. t���=i���i���s���audit(Ni����t���msgi���(���t���recsR���t���splitt���fieldst���lenR���R ���(���R���R���R���R���(����(����R���t���from_split_string?���s������ (���t���__name__t ���__module__t���__doc__R���R���(����(����(����R���R ���4���s���� t���InvalidMessagec�����������B���s���t��Z�d��Z�d�„��Z�RS(���sþ���Class representing invalid audit messages. This is used to differentiate between audit messages that aren't recognized (that should return None from the audit message parser) and a message that is recognized but is malformed in some way. c���������C���s���t��i�|��|�ƒ�d��S(���N(���R ���R���R���R���(���R���R���(����(����R���R���Z���s����(���R���R���R���R���(����(����(����R���R���T���s����t���PathMessagec�����������B���s ���t��Z�d��Z�d�„��Z�d�„��Z�RS(���s!���Class representing a path messagec���������C���s���t��i�|��|�ƒ�d�|��_�d��S(���NR ���(���R ���R���R���R���t���path(���R���R���(����(����R���R���_���s����c���������C���s{���t��i�|��|�ƒ�xd�|�D]\�}�|�i�d�ƒ�}�t�|�ƒ�d�j�o�q�n�|�d�d�j�o�|�d�d�d�!|��_�d��Sq�q�Wd��S(���NR���i���i����R���i���iÿÿÿÿ( ���R ���R���R���R���R���R���R���R���R���(���R���R���R���R���(����(����R���R���c���s�����(���R���R���R���R���R���(����(����(����R���R���]���s���� t ���AVCMessagec�����������B���s)���t��Z�d��Z�d�„��Z�d�„��Z�d�„��Z�RS(���sk��AVC message representing an access denial or granted message. This is a very basic class and does not represent all possible fields in an avc message. Currently the fields are: scontext - context for the source (process) that generated the message tcontext - context for the target tclass - object class for the target (only one) comm - the process name exe - the on-disc binary path - the path of the target access - list of accesses that were allowed or denied denial - boolean indicating whether this was a denial (True) or granted (False) message. An example audit message generated from the audit daemon looks like (line breaks added): 'type=AVC msg=audit(1155568085.407:10877): avc: denied { search } for pid=677 comm="python" name="modules" dev=dm-0 ino=13716388 scontext=user_u:system_r:setroubleshootd_t:s0 tcontext=system_u:object_r:modules_object_t:s0 tclass=dir' An example audit message stored in syslog (not processed by the audit daemon - line breaks added): 'Sep 12 08:26:43 dhcp83-5 kernel: audit(1158064002.046:4): avc: denied { read } for pid=2 496 comm="bluez-pin" name=".gdm1K3IFT" dev=dm-0 ino=3601333 scontext=user_u:system_r:bluetooth_helper_t:s0-s0:c0 tcontext=system_u:object_r:xdm_tmp_t:s0 tclass=file c���������C���sh���t��i�|��|�ƒ�t�i�ƒ��|��_�t�i�ƒ��|��_�d�|��_�d�|��_ �d�|��_ �d�|��_�g��|��_�t �|��_�d��S(���NR ���(���R ���R���R���R���t ���refpolicyt���SecurityContextt���scontextt���tcontextt���tclasst���commt���exeR���t���accessest���Truet���denial(���R���R���(����(����R���R���‹���s���� c���������C���sµ���t��}�|�}�|�t�|�ƒ�d�j�o�t�d�|��i�ƒ�‚�n�xR�|�t�|�ƒ�j��o>�|�|�d�j�o�t �}�Pn�|��i �i�|�|�ƒ�|�d�}�q=�W|�p�t�d�|��i�ƒ�‚�n�|�d�S(���Ni���s#���AVC message in invalid format [%s] t���}(���t���Falset���found_closet���startt���iR���R���t ���ValueErrorR���R���R%���R$���t���append(���R���R���R*���R+���R)���(����(����R���t���__parse_access–���s�����c���������C���sÛ��t��i�|��|�ƒ�t�}�t�}�t�}�t�}�xut �t �|�ƒ�ƒ�D]a}�|�|�d�j�o#�|��i�|�|�d�ƒ�}�t �}�q;�n�|�|�d�j�o �t�|��_�n�|�|�i�d�ƒ�}�t �|�ƒ�d�j�o�q;�n�|�d�d�j�o �t�i�|�d�ƒ�|��_�t �}�q;�|�d�d�j�o �t�i�|�d�ƒ�|��_�t �}�q;�|�d�d �j�o�|�d�|��_�t �}�q;�|�d�d �j�o�|�d�d�d�!|��_�q;�|�d�d�j�o�|�d�d�d�!|��_�q;�q;�W|�p�|�p�|�p�|�o�t�d �|��i�ƒ�‚�n�d��S(���Nt���{i���t���grantedR���i���i����R���R ���R!���R"���iÿÿÿÿR#���s#���AVC message in invalid format [%s] (���R ���R���R���R���R(���t ���found_srct ���found_tgtt���found_classt���found_accesst���rangeR���R+���t���_AVCMessage__parse_accessR%���R&���R���R���R���R���R���R ���R!���R"���R#���R,���R���(���R���R���R1���R+���R���R3���R2���R4���(����(����R���R���¬���s>����� (���R���R���R���R���R6���R���(����(����(����R���R���n���s���� t���PolicyLoadMessagec�����������B���s���t��Z�d��Z�d�„��Z�RS(���s6���Audit message indicating that the policy was reloaded.c���������C���s���t��i�|��|�ƒ�d��S(���N(���R ���R���R���R���(���R���R���(����(����R���R���Ó���s����(���R���R���R���R���(����(����(����R���R7���Ñ���s����t���DaemonStartMessagec�����������B���s ���t��Z�d��Z�d�„��Z�d�„��Z�RS(���s3���Audit message indicating that a daemon was started.c���������C���s���t��i�|��|�ƒ�t�|��_�d��S(���N(���R ���R���R���R���R(���t���auditd(���R���R���(����(����R���R���Ø���s����c���������C���s.���t��i�|��|�ƒ�d�|�j�o �t�|��_�n�d��S(���NR9���(���R ���R���R���R���R%���R9���(���R���R���(����(����R���R���Ü���s���� (���R���R���R���R���R���(����(����(����R���R8���Ö���s���� t���ComputeSidMessagec�����������B���s ���t��Z�d��Z�d�„��Z�d�„��Z�RS(���s†��Audit message indicating that a sid was not valid. Compute sid messages are generated on attempting to create a security context that is not valid. Security contexts are invalid if the role is not authorized for the user or the type is not authorized for the role. This class does not store all of the fields from the compute sid message - just the type and role. c���������C���s&���t��i�|��|�ƒ�d�|��_�d�|��_�d��S(���NR ���(���R ���R���R���R���t���typet���role(���R���R���(����(����R���R���ì���s���� c���������C���s²���t��i�|��|�ƒ�h��}�xI�|�D]A�}�|�i�d�ƒ�}�t�|�ƒ�d�j��o�q�n�|�d�|�|�d�<q�Wy6�t �i �|�d�ƒ�i�|��_�t �i �|�d�ƒ�i�|��_�Wn�t �d�ƒ�‚�n�Xd��S(���NR���i���i���i����R���R ���s;���Split string does not represent a valid compute sid message(���R ���R���R���R���t���dictR+���R���t���tR���R���R���R<���R;���R,���(���R���R���R+���R=���R>���(����(����R���R���ñ���s�����(���R���R���R���R���R���(����(����(����R���R:���â���s��� � t���AuditParserc�����������B���s_���t��Z�d��Z�e�d�„�Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z �d�„��Z �e�e�d�„�Z �RS( ���s»��Parser for audit messages. This class parses audit messages and stores them according to their message type. This is not a general purpose audit message parser - it only extracts selinux related messages. Each audit messages are stored in one of four lists: avc_msgs - avc denial or granted messages. Messages are stored in AVCMessage objects. comput_sid_messages - invalid sid messages. Messages are stored in ComputSidMessage objects. invalid_msgs - selinux related messages that are not valid. Messages are stored in InvalidMessageObjects. policy_load_messages - policy load messages. Messages are stored in PolicyLoadMessage objects. These lists will be reset when a policy load message is seen if AuditParser.last_load_only is set to true. It is assumed that messages are fed to the parser in chronological order - time stamps are not parsed. c���������C���s���|��i�ƒ��|�|��_�d��S(���N(���R���t���_AuditParser__initializet���last_load_only(���R���RA���(����(����R���R�����s���� c���������C���s:���g��|��_�g��|��_�g��|��_�g��|��_�g��|��_�h��|��_�d��S(���N(���R���t���avc_msgst���compute_sid_msgst���invalid_msgst���policy_load_msgst ���path_msgst ���by_header(���R���(����(����R���t���__initialize��s���� c���������C���s2��|�i�ƒ��}�x|�D]}�t�}�|�d�j�p�|�d�j�p �|�d�j�o�t�|�ƒ�}�t�}�n�|�d�j�o�t �|�ƒ�}�t�}�nj�|�d�j�o�t �|�ƒ�}�t�}�nG�|�d�j�o�t�|�ƒ�}�t�}�n$�|�d�j�o�t�t �ƒ�}�t�}�n�|�o;�y�|�i�|�ƒ�Wn�t�j �o�t�|�ƒ�}�n�X|�Sq�q�Wd��S(���Ns���avc:s���message=avc:s ���msg='avc:s���security_compute_sid:s���type=MAC_POLICY_LOADs ���type=AVC_PATHs���type=DAEMON_START(���t���lineR���t���recR+���R(���t���foundR���R���R%���R:���R7���R���R8���t���listR���R,���R���t���None(���R���RI���R+���RK���R���RJ���(����(����R���t���__parse_line0��s4�����' c���������C���s‚��|��i�|�ƒ�}�|�d��j�o�d��Sn�t�|�t�ƒ�o�|��i�o�|��i�ƒ��q&n×�t�|�t �ƒ�o6�|�i �o�|��i�o�|��i�ƒ��n�|��i�i�|�ƒ�n‘�t�|�t �ƒ�o�|��i�i�|�ƒ�nm�t�|�t�ƒ�o�|��i�i�|�ƒ�nI�t�|�t�ƒ�o�|��i�i�|�ƒ�n%�t�|�t�ƒ�o�|��i�i�|�ƒ�n�|�i�d�j�oH�|��i�i�|�i�ƒ�o�|��i�|�i�i�|�ƒ�q~|�g�|��i�|�i�<n�d��S(���NR ���(���R���t���_AuditParser__parse_lineRI���R���RM���t ���isinstanceR7���RA���R@���R8���R9���RE���R-���R���RB���R:���RC���R���RD���R���RF���R ���RG���t���has_key(���R���RI���R���(����(����R���t���__parseQ��s,���� c���������C���s±���xª�|��i�i�ƒ��D]™�}�g��}�d��}�xI�|�D]A�}�t�|�t �ƒ�o �|�}�q)�t�|�t �ƒ�o�|�i�|�ƒ�q)�q)�Wt�|�ƒ�d�j�o(�|�o!�x�|�D]�}�|�i�|�_�q�Wq�q�Wd��S(���Ni����(���R���RG���t���valuest���valuet���avcRM���R���R���RP���R���R���R-���R���t���a(���R���RV���RT���R���R���RU���(����(����R���t���__post_processv��s������ �c���������C���sB���|�i�ƒ��}�x%�|�o�|��i�|�ƒ�|�i�ƒ��}�q�W|��i�ƒ��d�S(���sp���Parse the contents of a file object. This method can be called multiple times (along with parse_string).N(���t���inputt���readlineRI���R���t���_AuditParser__parset���_AuditParser__post_process(���R���RX���RI���(����(����R���t ���parse_fileƒ��s������ c���������C���s;���|�i�d�ƒ�}�x�|�D]�}�|��i�|�ƒ�q�W|��i�ƒ��d�S(���s§���Parse a string containing audit messages - messages should be separated by new lines. This method can be called multiple times (along with parse_file).s��� N(���RX���R���t���linest���lR���RZ���R[���(���R���RX���R]���R^���(����(����R���t���parse_stringŒ��s������c���������C���s·���t��i�ƒ��}�x¤�|��i�D]™�}�|�i�t�j�o�|�o�q�n�|�oC�|�i �|�ƒ�o/�|�i�|�i�i �|�i�i �|�i�|�i�|�ƒ�q¯�q�|�i�|�i�i �|�i�i �|�i�|�i�|�ƒ�q�W|�S(���s‚��Convert the audit logs access into a an access vector set. Convert the audit logs into an access vector set, optionally filtering the restults with the passed in filter object. Filter objects are object instances with a .filter method that takes and access vector and returns True if the message should be included in the final output and False otherwise. Params: avc_filter - [optional] Filter object used to filter the output. Returns: Access vector set representing the denied access in the audit logs parsed by this object. N(���t���accesst���AccessVectorSett���av_setR���RB���RU���R&���R%���t���only_denialst ���avc_filtert���filtert���addR���R;���R ���R!���R$���(���R���Rd���Rc���Rb���RU���(����(����R���t ���to_access•��s����� �(���R���R���R���R(���R���R@���RO���RZ���R[���R\���R_���RM���R%���Rg���(����(����(����R���R?�����s���� ! % t ���TypeFilterc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��i�|�ƒ�|��_�d��S(���N(���t���ret���compilet���regexR���(���R���Rk���(����(����R���R���´��s����c���������C���sF���|��i�i�|�i�i�ƒ�o�t�Sn�|��i�i�|�i�i�ƒ�o�t�Sn�t�S(���N( ���R���Rk���t���matchRU���R���R;���R%���R ���R(���(���R���RU���(����(����R���Re���·��s ����(���R���R���R���Re���(����(����(����R���Rh���³��s��� (���R���R`���Ri���R���R���R ���R���R���R���R7���R8���R:���R?���Rh���(���R���R���R���R ���R���R���R?���R8���R`���Ri���R7���Rh���R���R:���(����(����R���t���?���s��� c²