AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/landscape/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/landscape/lib/__pycache__/network.cpython-310.pyc
o

 ��f]&�@s�ddlmZ	ddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddgZdZ
dZdZd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd*dd �Z	!	"	d+d#d�Zd,d%d�Zd&d'�Zd(d)�ZdS)-�)�absolute_importN)�long�_PY3�get_active_device_info�get_network_traffici�iF��cCst�d�dkS)z>Returns C{True} if the platform is 64-bit, otherwise C{False}.�l�)�struct�calcsize�rr�7/usr/lib/python3/dist-packages/landscape/lib/network.py�is_64srcCs|d@S)z�Returns C{True} if the interface is up, otherwise C{False}.

    @param flags: the integer value of an interface's flags.
    @see /usr/include/linux/if.h for the meaning of the flags.
    rr)�flagsrrr
�is_upsrcCs@|�tjig�d�d�}|�tjig�d�d�}t|p|�S)zChecks if interface address data has an IP address

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    r�addr)�get�	netifaces�AF_INET�AF_INET6�bool)�ifaddresses�	inet_addr�
inet6_addrrrr
�	is_active&srcCsNi}tj|vr|tj|tj<tj|vr%dd�|tjD�}|r%||tj<|S)z�Return all IP addresses of an interfaces.

    Returns the same structure as L{ifaddresses}, but filtered to keep
    IP addresses only.

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    cSsg|]}|d�d�s|�qS)rzfe80:��
startswith)�.0rrrr
�
<listcomp>=s
�z$get_ip_addresses.<locals>.<listcomp>)rrr)r�results�global_addrsrrr
�get_ip_addresses0s


r!cC�|tjd�dd�S)z�Return the broadcast address associated to an interface.

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    r�	broadcast�0.0.0.0�rrr�rrrr
�get_broadcast_addressE�r'cCr")z�Return the network mask associated to an interface.

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    r�netmask�r%r&rrr
�get_netmaskMr(r+cCs|tjddS)z�Return the first IPv4 address associated to the interface.

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    rr)rrr&rrr
�get_ip_addressUsr,cCs$tj|vr|tjd�dd�SdS)a
    Return the hardware MAC address for an interface in human friendly form,
    ie. six colon separated groups of two hexadecimal digits, if available;
    otherwise an empty string.

    @param ifaddresses: a dict as returned by L{netifaces.ifaddresses}
    rrr*)r�AF_LINKrr&rrr
�get_mac_address]s
r.c
Cs:t�|��tt�d|dd���}t�d|dd��dS)z�Return the integer value of the interface flags for the given interface.

    @param sock: a socket instance.
    @param interface: The name of the interface.
    @see /usr/include/linux/if.h for the meaning of the flags.
    �256sN��H��r)�fcntl�ioctl�fileno�SIOCGIFFLAGSr
�pack�unpack)�sock�	interface�datarrr
�	get_flagsjs�r=cCs"t��d}dd�|��D�}|S)z:
    Returns a list of interfaces with default routes
    �defaultcSsg|]}|d�qS)rr)r�gatewayrrr
r{�z*get_default_interfaces.<locals>.<listcomp>)r�gateways�values)�
default_table�
interfacesrrr
�get_default_interfacesvsrErFc	s:g}z�t�tjtjtj�}t��D]�t�fdd�|D��rqt���}t|�s.tj	|vr.q��
�}t||�}t|�}d�i}||d<t
||�\|d<|d<|rT||d<tj|vrrt|�|d<t|�|d	<t|�|d
<t|�|d<ntj	|vr�|s�d|d<t|�|d	<d|d
<d|d<|�|�qW|��|S|��w)
z�
    Returns a dictionary containing info on each active network
    interface that passes all `filters`.

    A filter is a callable that returns True if the interface should be
    skipped.
    c3s�|]}|��VqdS�Nr)r�f�r;rr
�	<genexpr>�s�z'get_filtered_if_info.<locals>.<genexpr>r;r�speed�duplex�ip_addresses�
ip_address�mac_address�broadcast_addressr)r$)�socketr�
SOCK_DGRAM�
IPPROTO_IPrrD�anyrrr-�encoder=r!�get_network_interface_speedr,r.r'r+�append�close)	�filters�extendedrr:r�	ifencodedrrL�ifinforrHr
�get_filtered_if_infosP�
�

�
��%
�r\��loTc
sN�fdd�}dd�}dd�}t����fdd�}d	d
�}	t|	||||f|d�S)Ncs|�vSrFrrH)�skipped_interfacesrr
�filter_local��z,get_active_device_info.<locals>.filter_localcS�d|vS)N�.rrHrrr
�filter_vlan�raz+get_active_device_info.<locals>.filter_vlancSrb)N�:rrHrrr
�filter_alias�raz,get_active_device_info.<locals>.filter_aliascs�o|�vSrFrrH)�default_ifs�default_onlyrr
�filter_default�sz.get_active_device_info.<locals>.filter_defaultcSs
|�d�S)N�taprrHrrr
�
filter_tap�s
z*get_active_device_info.<locals>.filter_tap)rXrY)rEr\)
r_�	skip_vlan�
skip_aliasrYrhr`rdrfrirkr)rgrhr_r
r�s���
/proc/net/devcCs�t|d��}|��}Wd�n1swY|d�d�\}}}dd�|��D�}|�dd�|��D��i}|dd�D] }d	|vrGq@|�d	�\}	}
|	��}	tt|tt|
�����||	<q@|S)
ze
    Retrieves an array of information regarding the network activity per
    network interface.
    �rNr�|cS�g|]}d|�qS)zrecv_%sr�r�columnrrr
r�r@z'get_network_traffic.<locals>.<listcomp>cSrq)zsend_%srrrrrr
r�r@�re)	�open�	readlines�split�extend�strip�dict�zip�mapr)�source_file�netdev�lines�_�receive_columns�transmit_columns�columns�devices�line�devicer<rrr
r�s
�cCsLt��}d|vr$t�t��dtjtjtjtj�dd}d|vr$t��}|S)a
    Return the current fqdn of the machine, trying hard to return a meaningful
    name.

    In particular, it means working against a NetworkManager bug which seems to
    make C{getfqdn} return localhost6.localdomain6 for machine without a domain
    since Maverick.
    �	localhostNr�)rP�getfqdn�getaddrinfo�gethostnamerrQrR�AI_CANONNAME)�fqdnrrr
�get_fqdn�s	���r�c	
Cs�t�dtd�}t�d|�}t�d||��d�}d}zt�|t|�tr)|�	�}n|�
�}t�d|�\}}Wn2tt
fyh}z$|jtjkrLt�d�n|jtjkrZ|jtjkrZ|�d}d	}WYd
}~nd
}~ww|dkrod}|dkrud	}t|�}||fS)
a�
    Return the ethernet device's advertised link speed.

    The return value can be one of:
        * 10, 100, 1000, 2500, 10000: The interface speed in Mbps
        * -1: The interface does not support querying for max speed, such as
          virtio devices for instance.
        * 0: The cable is not connected to the interface. We cannot measure
          interface speed, but could if it was plugged in.
    �I39ss'�B�16sPr����12xHB28xzECould not determine network interface speed, operation not permitted.FNi���)r
r8�ETHTOOL_GSET�array�buffer_infor4r5�SIOCETHTOOLr�tobytes�tostringr9�IOError�OSError�errno�EPERM�logging�warning�
EOPNOTSUPP�EINVALr)	r:�interface_name�
cmd_struct�
status_cmd�packedrJ�resrK�errr
rUs2
��rU)rF)r]TTFF)rn)�
__future__rr�r4rPr
r�r�r�landscape.lib.compatrr�__all__r7r�r�rrrr!r'r+r,r.r=rEr\rrr�rUrrrr
�<module>s@	


	8
�
!

Anon7 - 2022
AnonSec Team