403Webshell
Server IP : 182.53.201.61  /  Your IP : 216.73.217.175
Web Server : Apache/2.2.15 (Fedora)
System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python2.6/site-packages/sepolgen/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.6/site-packages/sepolgen/audit.pyc
Ñò
†·Jc@sddkZddkZddkZd„Zd„Zd„Zd„Zddd„ƒYZdefd	„ƒYZd
efd„ƒYZ	defd
„ƒYZ
defd„ƒYZdefd„ƒYZdefd„ƒYZ
ddd„ƒYZddd„ƒYZddd„ƒYZdS(iÿÿÿÿNc		Csçddk}ddk}tddƒ}t|iƒiƒdƒ}|i|i|iƒ|ƒ}|id|ƒidƒ}d|d|d	|d
f}|id|ƒ}|i	dd
dd||gd|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.
    iÿÿÿÿNs/proc/uptimetris%D/%Yt/s%s/%s/%siis%Xs/sbin/ausearchs-ms5AVC,USER_AVC,MAC_POLICY_LOAD,DAEMON_START,SELINUX_ERRs-tststdout(t
subprocessttimetopentfloattreadtsplittcloset	localtimetstrftimetPopentPIPEtcommunicate(	RRtfdtofftstdatetbootdatetboottimetoutput((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytget_audit_boot_msgsscCs;ddk}|idddgd|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.
    iÿÿÿÿNs/sbin/ausearchs-ms5AVC,USER_AVC,MAC_POLICY_LOAD,DAEMON_START,SELINUX_ERRRi(RRR
R(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytget_audit_msgs/scCs5ddk}|idgd|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.
    iÿÿÿÿNs
/bin/dmesgRi(RRR
R(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytget_dmesg_msgs<scCs;ddk}|idddgd|iƒiƒd}|S(s¨Obtain all of the avc and policy load messages from /var/log/messages.

    Returns:
       string contain all of the audit messages returned by /var/log/messages.
    iÿÿÿÿNs	/bin/greptavcs/var/log/messagesRi(RRR
R(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytget_log_msgsGstAuditMessagecBs eZdZd„Zd„ZRS(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.
    cCs||_d|_dS(Nt(tmessagetheader(tselfR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__init__[s	cCs€xy|D]q}|idƒ}t|ƒdjo&|d djo||_dSqn|ddjo|d|_dSqWdS(	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=iisaudit(Nitmsgi(RtlenR(RtrecsR"tfields((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytfrom_split_string_s	
(t__name__t
__module__t__doc__R R&(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRTs	tInvalidMessagecBseZdZd„ZRS(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.
    cCsti||ƒdS(N(RR (RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR zs(R'R(R)R (((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR*tstPathMessagecBs eZdZd„Zd„ZRS(s!Class representing a path messagecCsti||ƒd|_dS(NR(RR tpath(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR scCsxti||ƒxa|D]Y}|idƒ}t|ƒdjoqn|ddjo|ddd!|_dSqWdS(NR!iiR,iiÿÿÿÿ(RR&RR#R,(RR$R"R%((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR&ƒs(R'R(R)R R&(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR+}s	t
AVCMessagecBs)eZdZd„Zd„Zd„ZRS(skAVC 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
    cCshti||ƒtiƒ|_tiƒ|_d|_d|_d|_d|_	g|_
t|_dS(NR(
RR t	refpolicytSecurityContexttscontextttcontextttclasstcommtexeR,taccessestTruetdenial(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR «s					cCsµt}|}|t|ƒdjotd|iƒ‚nxR|t|ƒjo>||djot}Pn|ii||ƒ|d}q=W|ptd|iƒ‚n|dS(Nis#AVC message in invalid format [%s]
t}(tFalseR#t
ValueErrorRR6R5tappend(RR$tstarttfound_closeti((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__parse_access¶scCsÛti||ƒt}t}t}t}xutt|ƒƒD]a}||djo#|i||dƒ}t}q;n||djo
t|_n||idƒ}t|ƒdjoq;n|ddjo t	i
|dƒ|_t}q;|ddjo t	i
|dƒ|_t}q;|dd	jo|d|_
t}q;|dd
jo|ddd!|_q;|ddjo|ddd!|_q;q;W|p|p|p|otd
|iƒ‚ndS(Nt{itgrantedR!iiR0R1R2R3iÿÿÿÿR4s#AVC message in invalid format [%s]
(RR&R9trangeR#t_AVCMessage__parse_accessR6R7RR.R/R0R1R2R3R4R:R(RR$t	found_srct	found_tgttfound_classtfound_accessR>R%((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR&Ìs>




 (R'R(R)R RCR&(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR-Žs		tPolicyLoadMessagecBseZdZd„ZRS(s6Audit message indicating that the policy was reloaded.cCsti||ƒdS(N(RR (RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR ós(R'R(R)R (((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRHñstDaemonStartMessagecBs eZdZd„Zd„ZRS(s3Audit message indicating that a daemon was started.cCsti||ƒt|_dS(N(RR R9tauditd(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR øscCs.ti||ƒd|jo
t|_ndS(NRJ(RR&R6RJ(RR$((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR&üs
(R'R(R)R R&(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRIös	tComputeSidMessagecBs)eZdZd„Zd„Zd„ZRS(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.
    cCsJti||ƒtiƒ|_tiƒ|_tiƒ|_d|_dS(NR(RR R.R/tinvalid_contextR0R1R2(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR s
cCsÇti||ƒt|ƒdjotdƒ‚nyzti|dƒ|_ti|didƒdƒ|_ti|didƒdƒ|_	|didƒd|_
Wntdƒ‚nXdS(	Ni
s;Split string does not represent a valid compute sid messageiiR!iii	(RR&R#R:R.R/RLRR0R1R2(RR$((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR&s##cCsd|i|ifS(Nsrole %s types %s;
(trolettype(R((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRs(R'R(R)R R&R(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRKs			tAuditParsercBskeZdZed„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d
d„Zd
e
d	„ZRS(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.
    cCs|iƒ||_dS(N(t_AuditParser__initializetlast_load_only(RRQ((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR :s
cCs:g|_g|_g|_g|_g|_h|_dS(N(tavc_msgstcompute_sid_msgstinvalid_msgstpolicy_load_msgst	path_msgst	by_header(R((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__initialize>s					cCs/|iƒ}x|D]}t}|djp|djp
|djot|ƒ}t}n|djot|ƒ}t}nj|djot|ƒ}t}nG|djot|ƒ}t}n$|djottƒ}t}n|o8y|i	|ƒWnt
j
ot|ƒ}nX|SqWdS(Nsavc:smessage=avc:s	msg='avc:ssecurity_compute_sid:stype=MAC_POLICY_LOADs
type=AVC_PATHstype=DAEMON_START(
RR9R-R6RKRHR+RItlistR&R:R*tNone(RtlinetrecR>tfoundR"((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__parse_lineSs4'








	cCs|i|ƒ}|djodSt|tƒo|io|iƒq#n×t|tƒo6|io|io|iƒn|ii	|ƒn‘t|t
ƒo|ii	|ƒnmt|tƒo|i
i	|ƒnIt|tƒo|ii	|ƒn%t|tƒo|ii	|ƒn|idjoH|ii|iƒo|i|ii	|ƒq{|g|i|i<ndS(NR(t_AuditParser__parse_lineRZt
isinstanceRHRQRPRIRJRUR;R-RRRKRSR*RTR+RVRRWthas_key(RR[R"((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__parsets,

cCs±xª|iiƒD]™}g}d}xI|D]A}t|tƒo
|}q)t|tƒo|i|ƒq)q)Wt|ƒdjo(|o!x|D]}|i|_qWqqWdS(Ni(	RWtvaluesRZR`R+R-R;R#R,(RtvalueRR,R"ta((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt__post_process™s
cCsB|iƒ}x%|o|i|ƒ|iƒ}qW|iƒdS(spParse the contents of a file object. This method can be called
        multiple times (along with parse_string).N(treadlinet_AuditParser__parset_AuditParser__post_process(RtinputR[((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt
parse_file¦s
cCs;|idƒ}x|D]}|i|ƒqW|iƒdS(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(RRhRi(RRjtlinestl((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytparse_string¯s
cCs\tiƒ}xI|iD]>}|p|i|ƒo |i|ii|iiƒqqW|S(soReturn RoleAllowSet statements matching the specified filter

        Filter out types that match the filer, or all roles

        Params:
           role_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.
        (taccesstRoleTypeSetRStfiltertaddRLRMRN(Rtrole_filtert
role_typestcs((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pytto_role¸s
$cCs·tiƒ}x¤|iD]™}|itjo|oqn|oC|i|ƒo/|i|ii|i	i|i
|i|ƒq¯q|i|ii|i	i|i
|i|ƒqW|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.
        (RotAccessVectorSetRRR7R6RqRrR0RNR1R2R5(Rt
avc_filtertonly_denialstav_setR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt	to_accessËs
N(R'R(R)R9R RPR_RhRiRkRnRZRvR6R{(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRO$s		!	%	
				t
AVCTypeFiltercBseZd„Zd„ZRS(cCsti|ƒ|_dS(N(tretcompiletregex(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR êscCs@|ii|iiƒotS|ii|iiƒotStS(N(RtmatchR0RNR6R1R9(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRqís
(R'R(R Rq(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR|és	tComputeSidTypeFiltercBseZd„Zd„ZRS(cCsti|ƒ|_dS(N(R}R~R(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyR õscCs^|ii|iiƒotS|ii|iiƒotS|ii|iiƒotStS(N(RR€RLRNR6R0R1R9(RR((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRqøs(R'R(R Rq(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyRôs	(((((R.RoR}RRRRRR*R+R-RHRIRKROR|R(((s2/usr/lib/python2.6/site-packages/sepolgen/audit.pyt<module>s 		
		
 	c"Å

Youez - 2016 - github.com/yon3zu
LinuXploit