CasperSecurity

Current Path : /lib/python3/dist-packages/cloudinit/sources/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceRbxCloud.cpython-310.pyc

o

쑛hg�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
mZe�e�ZdZdd�Zd	ed
efdd�Zd
ejefd
d�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de	j�Zee	j ffgZ!dd�Z"dS)zr
This file contains code used to gather the user data passed to an
instance on rootbox / hyperone cloud platforms
�N)�IPv4Address)�sources�subp�util)�
EventScope�	EventTypez
/etc/hostscCs.tjtdd�}|rt�d�dSt�d�dS)NT)�quietz5/etc/hosts exists - setting manage_etc_hosts to FalseFz=/etc/hosts does not exists - setting manage_etc_hosts to True)r�load_text_file�	ETC_HOSTS�LOG�debug)�hosts�r�F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceRbxCloud.py�get_manage_etc_hostss

r�inc�returncCstttt|��|��S�N)�strr�int)�addrrrrr�increment_ip#srcCs|t|d�t|d�gS)z�Return a list of 3 IP addresses: [addr, addr + 2, addr + 3]

    @param addr: an object that is passed to IPvAddress
    @return: list of strings
    ��)r)rrrr�
get_three_ips's�rcCst�dg|�S)z�
    Uses the preferred cloud-init subprocess def of subp.subp
    and runs arping.  Breaking this to a separate function
    for later use in mocking and unittests
    �arping)r)�cmdrrr�_sub_arp4srcCs|d}|jdvr	d}|D]0}ztdd||d|dg�Wqtjy;}zt�d|d|d|�WYd}~qd}~wwdS)	Nz-S)�fedora�centos�rhelz-sz-c�2�source�destinationz&Failed to arping from "%s" to "%s": %s)�namerr�ProcessExecutionErrorr�warning)�items�distro�source_param�item�errorrrr�gratuitous_arp=s$
�����r,cCs�tt�d�t�d��}|sdS|D]>}ztj|tgd�d�}|r&|WSWqty@}z
|jtjkr6�WYd}~qd}~wtjyPt�	t
d|�Yqwt
�dd	�|��dS)
zAReturns False (not found or error) or a dictionary with metadata.z
LABEL=CLOUDMDz
LABEL=cloudmdF)�vfat�fat�msdosfs)�device�callback�mtypeNz-Failed to mount %s when looking for user dataz0Did not find RbxCloud data, searched devices: %s�,)
�setr�find_devs_with�mount_cb�read_user_data_callback�OSError�errno�ENOENT�MountFailedError�logexcrr�join)�devicesr0�rbx_data�errrrr�get_mdRs>���
�����
�rAcCsddd�t|�D�d�S)z�Generate network configuration

    @param netadps: A list of network adapter settings

    @returns: A dict containing network config
    �csBg|]\}�dd�t|���d���fdd��dD�d��qS)�physicalzeth{}�
macaddressc	s>g|]}d|d�ddd�dd�dddd��qS)	�static�address�network�netmask�auto�gateway�dns�nameservers)�typerFrH�controlrJ�dns_nameserversr)�.0�ip��netadprr�
<listcomp>s�


���z6generate_network_config.<locals>.<listcomp>.<listcomp>rQ)rMr$�mac_address�subnets)�formatr�lower)rP�irrRrrTzs�

���z+generate_network_config.<locals>.<listcomp>)�version�config)�	enumerate)�netadpsrrr�generate_network_configqs
��r^c
Cstjtjtj�|d�d�d�}tjtj�|d�dd�}d|vs#d|vr+t�td	�d
S|�	di��	d�}|�	di��	d
g�}d
}|�	di��	d�rQ|ddd}t
|d�}||dd|ddgd�dd�|dD�ddd||dg|d|d�i|t�d�d�}t�d�t�|�|S)aThis callback will be applied by util.mount_cb() on the mounted
    drive.

    @param mount_dir: String representing path of directory where mounted drive
    is available

    @returns: A dict containing userdata, metadata and cfg based on metadata.
    z
cloud.json)�fname)�textz	user.dataT)r_r�vmrSz(Failed to load metadata. Invalid format.N�additionalMetadata�username�sshKeys�password�sha512�_idr$)zinstance-idzlocal-hostname�public-keyscSs>g|]}|dD]}t|dd�D]	}|d|d��qqqS)rQrGrJrF)r"r#)r)rPrSrQ�targetrrrrT�s���
�z+read_user_data_callback.<locals>.<listcomp>�default_userzALL=(ALL) NOPASSWD:ALLF)r$�gecos�sudo�passwd�lock_passwd�ssh_authorized_keys)�
ssh_pwauth�disable_root�system_info�network_config�manage_etc_hosts)�userdata�metadatar,�cfgzreturning DATA object:)
r�	load_json�load_binary_file�os�pathr=r	r<r�getr^rr)�	mount_dir�	meta_data�	user_datarc�ssh_keys�hashrG�datarrrr7�sR	��

����
��

r7c@sjeZdZdZejejejej	hiZ
dd�Zdd�Zdd�Z
edd	��Zd
d�Zdd
�Zdd�Zdd�ZdS)�DataSourceRbxCloud�RbxCloudcCs(tj�||||�d|_d|_d|_dSr)r�
DataSource�__init__�seedr,rw)�self�sys_cfgr(�pathsrrrr��s
zDataSourceRbxCloud.__init__cCstj�|�}d||jfS)Nz%s [seed=%s])rr��__str__r�)r��rootrrrr��szDataSourceRbxCloud.__str__cCs>t�}|dur	dS|d|_|d|_|d|_|d|_dS)zw
        Metadata is passed to the launching instance which
        is used to perform instance configuration.
        Frurvr,rwT)rA�userdata_rawrvr,rw)r�r?rrr�	_get_data�s



zDataSourceRbxCloud._get_datacC�
|jdS)Nrs�rw�r�rrrrs�s
z!DataSourceRbxCloud.network_configcCr�)Nrh)rvr�rrr�get_public_ssh_keys�s
z&DataSourceRbxCloud.get_public_ssh_keyscC�|jSr)r�r�rrr�get_userdata_raw��z#DataSourceRbxCloud.get_userdata_rawcCr�rr�r�rrr�get_config_obj�r�z!DataSourceRbxCloud.get_config_objcCst|j|j�dSr)r,r()r�rw�is_new_instancerrr�activateszDataSourceRbxCloud.activateN)�__name__�
__module__�__qualname__�dsnamer�NETWORKr�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�default_update_eventsr�r�r��propertyrsr�r�r�r�rrrrr��s"��
r�cCst�|t�Sr)r�list_from_depends�datasources)�dependsrrr�get_datasource_listsr�)#�__doc__r9�loggingrz�os.path�typing�	ipaddressr�	cloudinitrrr�cloudinit.eventrr�	getLoggerr�rr
rrrr�Listrrr,rAr^r7r�r��DEP_FILESYSTEMr�r�rrrr�<module>s.
	
	!@
5�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY