Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/firewall/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/firewall/functions.pyo
�
�c�`c#@sXdddddddddd	d
ddd
ddddddddddddddddddd d!d"g#Zd#d$lZd#d$lZd#d$lZd#d$lZd#d$lZd#d$lZd#d$lZd#d$lZd#d%l	m
Z
d#d&lmZm
Z
ejd'kZd(�Zd)�Zd*d+�Zd,�Zd-�Zd.�Zd/�Zd0�Zd1�Zd2�Zd3�Zd4�Zd5�Zd6�Zd7�Zd8�Zd9�Z d:�Z!d;�Z"d<�Z#d=�Z$d>�Z%d?�Z&d@�Z'dA�Z(dB�Z)dC�Z*dD�Z+dE�Z,dF�Z-dG�Z.dH�Z/dI�Z0dJ�Z1dK�Z2dL�Z3dM�Z4d$S(NtPY2t	getPortIDtgetPortRangetportStrtgetServiceNametcheckIPtcheckIP6tcheckIPnMaskt
checkIP6nMaskt
checkProtocoltcheckInterfacetcheckUINT32tfirewalld_is_activettempFiletreadfilet	writefiletenable_ip_forwardingtget_nf_conntrack_helper_settingtset_nf_conntrack_helper_settingt
check_portt
check_addresstcheck_single_addresst	check_mactuniqifytppid_of_pidtmax_zone_name_lent	checkUsertcheckUidtcheckCommandtcheckContexttjoinArgst	splitArgstb2utu2bt
u2b_if_py2i����N(tlog(tFIREWALLD_TEMPDIRtFIREWALLD_PIDFILEt3cCs�t|t�r|}nd|r-|j�}nyt|�}Wn<tk
r{ytj|�}Wq|tjk
rwdSXnX|dkr�dS|S(s� Check and Get port id from port string or port id using socket.getservbyname

    @param port port string or port id
    @return Port id if valid, -1 if port can not be found and -2 if port is too big
    i����i��i����(t
isinstancetinttstript
ValueErrortsockett
getservbynameterror(tportt_id((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR.s	
	c	Cs>t|t�s|j�r>t|�}|dkr:|fS|S|jd�}t|�dkr�|dj�r�|dj�r�t|d�}t|d�}|dkr�|dkr�||kr�||fS||kr�||fS|fSq�ng}xtt|�dd�D]�}tdj|| ��}dj||�}t|�dkr�t|�}|dkr|dkr||kr�|j||f�q�||kr�|j||f�q�|j|f�qq|dkr|j|f�|t|�krPqqqWt|�dkr dSt|�dkr6dS|dS(sI Get port range for port range string or single port id

    @param ports an integer or port string or port range string
    @return Array containing start and end port id for a valid range or -1 if port can not be found and -2 if port is too big for integer input or -1 for invalid ranges or None if the range is ambiguous.
    it-iii����N(
R'R(tisdigitRtsplittlentrangetjointappendtNone(tportstid1tsplitstid2tmatchedtitport2((s6/usr/lib/python2.7/site-packages/firewall/functions.pyREsH2


t:cCsr|dkrdSt|�}t|t�r;|dkr;dSt|�dkrUd|Sd|d||dfSdS(s Create port and port range string

    @param port port or port range int or [int, int]
    @param delimiter of the output string for port ranges, default ':'
    @return Port or port range string, empty string if port isn't specified, None if port or port range is not valid
    tiis%ss%s%s%sN(RR'R(R7R3(R.t	delimitert_range((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR{scCs�t|�}t|�}t|�dkr>|t|d�kSt|�dkr�|t|d�kr�|t|d�kr�tStS(Niii(RRR3tTruetFalse(R.R4t_portRB((s6/usr/lib/python2.7/site-packages/firewall/functions.pytportInPortRange�s,cCs8ytjt|�|�}Wntjk
r3dSX|S(s� Check and Get service name from port and proto string combination using socket.getservbyport

    @param port string or id
    @param protocol string
    @return Service name if port and protocol are valid, else None
    N(R+t
getservbyportR(R-R7(R.tprototname((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s
cCs3ytjtj|�Wntjk
r.tSXtS(sl Check IPv4 address.
    
    @param ip address string
    @return True if address is valid, else False
    (R+t	inet_ptontAF_INETR-RDRC(tip((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s
cCs
|jd�S(s� Normalize the IPv6 address

    This is mostly about converting URL-like IPv6 address to normal ones.
    e.g. [1234::4321] --> 1234:4321
    s[](R)(RL((s6/usr/lib/python2.7/site-packages/firewall/functions.pytnormalizeIP6�scCs9ytjtjt|��Wntjk
r4tSXtS(sl Check IPv6 address.
    
    @param ip address string
    @return True if address is valid, else False
    (R+RJtAF_INET6RMR-RDRC(RL((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s
cCs�d|kra||jd� }||jd�d}t|�dksZt|�dkrmtSn|}d}t|�s}tS|r�d|kr�t|�Syt|�}Wntk
r�tSX|dks�|dkr�tSntS(Nt/it.ii (tindexR3RDR7RR(R*RC(RLtaddrtmaskR=((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s&$

cCs�d|kra||jd� }||jd�d}t|�dksZt|�dkrmtSn|}d}t|�s}tS|r�yt|�}Wntk
r�tSX|dks�|dkr�tSntS(NROiii�(RQR3RDR7RR(R*RC(RLRRRSR=((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s"$
cCsmyt|�}Wn:tk
rLytj|�Wqitjk
rHtSXnX|dkse|dkritStS(Nii�(R(R*R+tgetprotobynameR-RDRC(tprotocolR=((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR	�s
	cCsN|st|�dkrtSx*ddddgD]}||kr0tSq0WtS(s� Check interface string

    @param interface string
    @return True if interface is valid (maximum 16 chars and does not contain ' ', '/', '!', ':', '*'), else False
    it ROt!t*(R3RDRC(tifacetch((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR
scCsHyt|d�}Wntk
r'tSX|dkrD|dkrDtStS(NiI����(R(R*RDRC(tvaltx((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRs
cCs�tjjt�stSy(ttd��}|j�}WdQXWntk
rRtSXtjjd|�smtSy,td|d��}|j�}WdQXWntk
r�tSXd|kr�tStS(sv Check if firewalld is active

    @return True if there is a firewalld pid file and the pid is used by firewalld
    trNs/proc/%ss/proc/%s/cmdlinet	firewalld(	tostpathtexistsR%RDtopentreadlinet	ExceptionRC(tfdtpidtcmdline((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR!s"

c	CsyyKtjjt�s(tjtd�ntjdddddtdt�SWn'tk
rt}t	j
d|��nXdS(	Ni�tmodetwttprefixstemp.tdirtdeletes#Failed to create temporary file: %s(R_R`RaR$tmkdirttempfiletNamedTemporaryFileRDRdR#R-R7(tmsg((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR
>scCsWy&t|d��}|j�SWdQXWn*tk
rR}tjd||f�nXdS(NR]sFailed to read file "%s": %s(Rbt	readlinesRdR#R-R7(tfilenametfte((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRJscCs[y)t|d��}|j|�WdQXWn+tk
rV}tjd||f�tSXtS(Ntws Failed to write to file "%s": %s(RbtwriteRdR#R-RDRC(RrtlineRsRt((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRRscCs6|dkrtdd�S|dkr2tdd�StS(Ntipv4s/proc/sys/net/ipv4/ip_forwards1
tipv6s&/proc/sys/net/ipv6/conf/all/forwarding(RRD(tipv((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR[s


cCs|jdd�jdd�S(Nt_R0s
nf-conntrack-R@(treplace(tmodule((s6/usr/lib/python2.7/site-packages/firewall/functions.pytget_nf_conntrack_short_namebscCs>yttd�d�SWntk
r9tjd�dSXdS(Ns+/proc/sys/net/netfilter/nf_conntrack_helperis3Failed to get and parse nf_conntrack_helper setting(R(RRdR#twarning(((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRes


cCstd|rdnd�S(Ns+/proc/sys/net/netfilter/nf_conntrack_helpers1
s0
(R(tflag((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRlscCs�t|�}|dksV|dksV|dksVt|�dkr�|d|dkr�|dkrvtjd|�nz|dkr�tjd|�nZ|dkr�tjd|�n:t|�dkr�|d|dkr�tjd	|�ntStS(
Ni����i����iiis'%s': port > 65535s'%s': port is invalids'%s': port is ambiguouss'%s': range start >= end(RR7R3R#tdebug2RDRC(R.RB((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRps$&&cCs4|dkrt|�S|dkr,t|�StSdS(NRxRy(RRRD(Rztsource((s6/usr/lib/python2.7/site-packages/firewall/functions.pyRs


cCs4|dkrt|�S|dkr,t|�StSdS(NRxRy(RRRD(RzR�((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s


cCsgt|�dkrcx"dD]}||dkrtSqWx%dD]}||tjkr>tSq>WtStS(NiiiiiiR?iiiiiii	i
i
iii(iiiii(iiiiiii	i
ii
ii(R3RDtstringt	hexdigitsRC(tmacR=((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s

cCs7g}x*|D]"}||kr
|j|�q
q
W|S(N(R6(t_listtoutputR\((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s

cCsVy=tjd|�}t|j�dj��}|j�Wntk
rQdSX|S(s Get parent for pid sps -o ppid -h -p %d 2>/dev/nulliN(R_tpopenR(RqR)tcloseRdR7(RfRs((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s
cCs=ddlm}ttt|j���}d|td�S(s�
    Netfilter limits length of chain to (currently) 28 chars.
    The longest chain we create is FWDI_<zone>_allow,
    which leaves 28 - 11 = 17 chars for <zone>.
    i����(t	SHORTCUTSit__allow(tfirewall.core.baseR�tmaxtmapR3tvalues(R�tlongest_shortcut((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�sc	Cstt|�dks-t|�tjd�kr1tSx<|D]4}|tjkr8|tjkr8|dkr8tSq8WtS(NitSC_LOGIN_NAME_MAXRPR0R{t$(RPR0R{R�(R3R_tsysconfRDR�t
ascii_letterstdigitsRC(tusertc((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s-
cCsWt|t�r7yt|�}Wq7tk
r3tSXn|dkrS|dkrStStS(NiiiiI�i���(R'tstrR(R*RDRC(tuid((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s
cCsjt|�dks$t|�dkr(tSx'dddgD]}||kr8tSq8W|ddkrftStS(Niit|s
tiRO(R3RDRC(tcommandRZ((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s$cCs�|jd�}t|�d
kr%tS|ddkrM|dddkrMtS|ddd	kretS|d
ddkr}tSt|d�dkr�tStS(NR?iiitrooti����t_uit_rit_ti(ii(R2R3RDRC(tcontextR:((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s$cCsDdtt�kr)djd�|D��Sdjd�|D��SdS(NtquoteRVcss|]}tj|�VqdS(N(tshlexR�(t.0ta((s6/usr/lib/python2.7/site-packages/firewall/functions.pys	<genexpr>�scss|]}tj|�VqdS(N(tpipesR�(R�R�((s6/usr/lib/python2.7/site-packages/firewall/functions.pys	<genexpr>�s(RkR�R5(targs((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�scCsNtr=t|t�r=t|�}tj|�}tt|�Stj|�SdS(N(RR'tunicodeR!R�R2R�R (t_stringR:((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR�s

cCs#t|t�r|jdd�S|S(s bytes to unicode sUTF-8R|(R'tbytestdecode(R�((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR �scCs#t|t�s|jdd�S|S(s unicode to bytes sUTF-8R|(R'R�tencode(R�((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR!�scCs)tr%t|t�r%|jdd�S|S(s" unicode to bytes only if Python 2sUTF-8R|(RR'R�R�(R�((s6/usr/lib/python2.7/site-packages/firewall/functions.pyR"s(5t__all__R+R_tos.pathR�R�R�tsysRntfirewall.core.loggerR#tfirewall.configR$R%tversionRRRRRFRRRMRRRR	R
RRR
RRRR~RRRRRRRRRRRRRRRR R!R"(((s6/usr/lib/python2.7/site-packages/firewall/functions.pyt<module>sr					6			
		
					
															
	
	
	
	
						

ZeroDay Forums Mini