⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.101
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
lib
/
fm-agent
/
library
/
__pycache__
/
View File Name :
aggregator.cpython-39.pyc
a �������f�;����������������������@���s.��d�dl�m�Z��zd�dlZW�n���d�dlmZ�Y�n0�d�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZzd�dlZW�n$���d�dl mZ�d�dlmZ�Y�n0�zd�dlZW�n6�ey����zd�dlZW�n�ey����dZY�n0�Y�n0�zd�dlZW�n���dZY�n0�d�dlmZmZmZ�G�dd��de�ZdS�)�����)�datetimeN)�get_fqdn�get_server_name�get_platform_uuidsc�������������������@���s����e�Zd�ZdZddd�Zdd��Zdd��Zi�d fd d�Zdd ��Zdi�di�i�fdd�Z ddd�Z ddd�Zddd�Zdd��Z dd��ZdS�)�Clientzy This is a client used for communicating with an aggregator, either *the* Aggregator or an Onsight instance. Nc�����������������C���s����t��|�jj�|�_||�_||�_||�_||�_d|�_ d�|�_ d}|d�urz|�dd�}t|�td�krv|� ��}|dv�rrd}nd}|}|r�|��|�|�_ d�S�)N����T�enabled��)�0�falseF)�logging� getLogger� __class__�__name__�log�customer_key� server_key�agg_url�version�call_timeout�proxy�get�type�lower�parse_proxy_info)�selfr���r���r���r����proxy_configZproxies_enabledZpev��r����'/usr/lib/fm-agent/library/aggregator.py�__init__-���s$����zClient.__init__c�����������������C���s~���d�}|s|S�z2dD�]&}|��|�}|s&qt�|�}|��W�S�W�d�S��tyx���t���d�}t|�}|�j�d�|���Y�d�S�0�d�S�)N)�https�http����zparse_proxy_info error: {}) r����urlparse� Exception�sys�exc_info�strr����info�format)r���r���Z proxy_val�schemeZ parsed_uri�err�errorr���r���r���r���O���s ���� zClient.parse_proxy_infoc�����������������C���s����d�}|dv�r�dt�jv�r,tj||t���d�}q�|�j�t�j��trvt td�rv|�j�dt td���tj|||�j t���d�}q�t�jdkr�tj|||�j d�}q�t�||�}n4t�jdkr�dt�jvr�tj|||�j d�}nt�||�}|S�) N)���i� ��zhp-ux)�context�_create_unverified_contextz0ssl has _create_unverified_context attribute: %s��timeoutr.���)��������r���)r1���)r%����platform�httplib�HTTPSConnection�sslr/���r����debug�version_info�hasattrr����HTTPConnection)r����url�port� connectionr���r���r����create_connectionb���s���� zClient.create_connection�POSTc�������������� ���C���s��dd��|�j��d�D��}t�|��d�}|D��]�}zTt�|�}|d�dksR|d�dkr`t�d|��}|d�dvsx|d�dkr�td ��W�n�ty����td ��Y�n0�|d�}d|v�r�|�d�\}} t| p�d�} n|}d} d |v�r�|d�|�d ���}|�j � d||| ��d�} d|�j|f�}|dk�r\|�j|d<�d|d<�t� t�������|d<�|�j �d|���t�|�} ddd�}|�j�rx|�j|d<�d�} |�j�r(tj|�jj|�jj|�jt���d�} |�j � d�| j| j���|�jj}|�jj }|�r|�rd�||�}t!�"t#|d���$d�}d�|�}| j%|| d|id��n| �%|| ��n|��&|| �} z�|�j �d ||| |f���| �'||| |��| �(��}|dk�r�t|j)�d!k�r�t|j*��n$|dk�r�t|j)�d"k�r�t|j*��t�+|�,���$d��W���S��t�y���t-�.��d�}t/|�}|�j �0d#|���Y�q(Y�q(0�q(t|��d�S�)$Nc�����������������S���s���g�|�]}|����r|�����qS�r���)�strip)�.0r<���r���r���r���� <listcomp>~��������zClient.call.<locals>.<listcomp>�,r���r ���r"���zhttp://)r!���r ���zInvalid aggregator URLzInvalid aggregator URL format.�:r-���z/vzaggregator call %r to %r:%dz/v%s/%sr@���Z agent_versionZv3Zmetadata_versionZ agent_timezData: %rzapplication/json)zContent-type�Accept� Authorizationr0���zConnection via proxy {}:{}z{}:{}zutf-8zBasic {}zProxy-Authorization)�headersz%s - %s - %s - %s����������zUnable to connect: %s)1r����split�random�shuffler#���r$���� ValueError�int�indexr���r(���r����time�mktimer����now� timetupler8����json�dumpsr���r���r5���r6����hostnamer=���r���r7���r/���r)����host�username�password�base64� b64encode�bytes�decode� set_tunnelr?����request�getresponse�status�reason�loads�readr%���r&���r'���r,���)r����action�data�methodZagg_urlsr,���r���Z url_partsr<���r=����params�urirI���r>����unameZpswd�credsZ auth_hashZ auth_value�respr+���r���r���r����call}���s����� � � � � � zClient.callc�����������������C���s����t���t�jt�j���}|�d��d|�j�d�d�v�rL|�j�d�d��d�\}}n |�j}d}|�j�d�||���|� |t |�f��|���d�W��d�����S�1�s�0����Y��d�S�)Ng������@rF���rE���r���z*get_local_ip: creating connection to {} {})�socket�AF_INET� SOCK_DGRAM� settimeoutr���rL���r���r(���r)����connectrP����getsockname)r����clientrY���r=���r���r���r����get_local_ip����s���� zClient.get_local_ipFc�����������������C���st���t�||||||||||| | ||| |d�}|r>t��}|r>||d<�|r\|���D�]}||�||<�qJ|rh||d<�|��d|�S�)N)�results� outage_events�metadata�countermeasures_metadata�facts�discovered_containers�deleted_containers�force_send_schedules�command_results�register�register_custom_metrics� incidents�config�ips�auto_topo_scans�dem_enabled�fm_server_identifiers�fortisase_attributes�sync)�dictr����keysro���)r���rx���ry���rz���r{���r|���r}���r~���r����r����r����r����r����r����r���r����r�����dem_service_resultsr�����payload�platform_uuidsZdsr���r���r���r��������s8�����zClient.syncc�����������������C���sT���d}|�j��d��z|�jdd|id��W�n���|�j��d��Y�n0�|�j��d��d}|S�) NFz beginning uninstall notification� uninstall�remove_instance)rh���zerror connectingznotified successfullyT)r���r(���ro���r,���)r���r�����successr���r���r����notify_of_uninstall��s����zClient.notify_of_uninstallc�����������������C���s���|�j��d��t��}|�j||d�}t��}|r2||d<�|�dd����dkr�ddlm}�dd l m }�z2|��} | ���|d <�|�d��t ��} | r�| |d<�W�n ���|�j��d��|d ��Y�n0�t��}|r�||d<�|�|��|�|��||���|�j��d��|�j��tj|dd���d�}d}d} d�}d�}zP|��d|�}|�j��|��|d�}|d�}d|v��rdd|d�v��rd|d�d�}W�n4�t�y����t���d�}|�j��d|���|}Y�n0�d} |�j��d|��|�d��s�|�d��s�d}d} d|v��rz|�d��rzd} |d�dk�r�d}n~|d�dk�rd}nj|d�d k�r$d!}nV|d�d"k�r8d#}nB|d�d$k�rLd%}n.|d��d&��rrd'|d��d(d)��}n|d�}|�j��d*| |||��| ||||fS�)+NzBeginning handshake)r���rX���r����r�����handshake_typeZstandard�forticlientr���)�_exit)�ForticlientHelperZforticlient_metadata�server_namezHandshake error���zHandshaking with aggregator:r"���)�indentF� handshaker����found_server�commands� log_levelzError connecting: %sTz/Connected successfully! Received server key: %rzIError performing handshake with the aggregator, please check connectivityr,���Zinvalid_credentialszIncorrect username/passwordZinvalid_customer_keyzUnknown/invalid customer keyZinvalid_server_groupzUnknown server groupZinactive_customerzCustomer inactiveZno_user_found_for_customerz%No active user found for the customerZinvalid_template_idzUnknown template id %szinvalid_template_id:r ���z8Success: %s, server key: %s, found server: %s, error: %s)r���r(���r���r���r���r���r����osr�����forticlient_helperr�����get_handshake_data�popr���� exception�update�parse_attributesrV���rW���ro���r8���r$���r%���r&���r,���� startswith�replace)r���r����� properties� attributesrX���rh���r����r����r�����helperr����r���r����r����r,���r����r+���r���r���r���r����&��s������ ��zClient.handshakec�����������������C���s���||r |pg�d�}|���d|�S�)a�� Request to the aggregator that it starts a maintenance for our server. It requires the duration of the maintenance in minutes, and accepts an optional list of tags to mark metrics that are going to be affected by it. )�duration�metric_tags�maintenance�ro���)r���r����r����r����r���r���r���r����}��s���� �zClient.maintenancec�����������������C���s ���|���d�S�)z� Request to the aggregator that it ends all active maintenances for our server. POST call with no parameters. �end_maintenancer����)r���r���r���r���r�������s����zClient.end_maintenancec�����������������C���s ���d|v�r|rd|ipi�S�i�S�dS�)z� Receive a dictionary containing the attributes stored in the manifest file. Parse them accordingly and store them in an attribute dictionary. Attributes get parsed only if the customer key is present in the properties. r���r����Nr���)r���r����r����r���r���r���r�������s����zClient.parse_attributes)NNN)F)N)N)r���� __module__�__qualname__�__doc__r���r���r?���ro���rw���r����r����r����r����r����r����r���r���r���r���r���'���s"��� "Z� 5 W r���)r���r5����http.clientrv���r\���r���rM����rerp���r%���rR���� tracebackr#����urllib.requestra���� urlrequest�urllib.parse�parserV����ImportError� simplejsonr7���� inspectorr���r���r����objectr���r���r���r���r����<module>���s6���