관리-도구
편집 파일: malware_response.cpython-311.pyc
� ��g�! � � � d Z ddlZddlZddlZddlZddlmZ ddlmZm Z ddl mZmZ ddl Z ddlmZ ddlmZmZ ddlmZmZ dd lmZmZ dd lmZ ej e� � Zej � � � ej j! z rdZ"ndZ"ej# �$ d ej% � � Z&ej# �$ dd� � Z'ej# �$ dd� � Z( e)ej# �$ dd� � � � Z*dZ+dZ,dZ- G d� de.� � Z/ G d� de.� � Z0d� Z1d)d�Z2e-fde3fd�Z4e-fd�Z5e-d �d!�Z6e G d"� d#� � � � Z7e-fd$ee3 d%e e3 fd&�Z8d'e j9 j: d%dfd(�Z;dS )*u5 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> Utilities to help upload a malicious file.� N)� dataclass)�Iterable�List)�quote_from_bytes�urljoin)�utils)�Core�Malware)� LicenseCLN�LicenseError)�IAIDTokenError�IndependentAgentIDAPI)�MalwareTunez/opt/alt/curlssl/usr/bin/curlz/opt/alt/curlssl11/usr/bin/curl�I360_MRS_API_BASE_URL�I360_MRS_ENDPOINT_UPLOADz api/v1/upload�I360_MRS_ENDPOINT_CHECKzapi/v1/check-known-hashes�IMUNIFY360_POST_FILE_TIMEOUTi �false_negative�false_positive�unknownc � � e Zd ZdZdS )�ClientErrorzcHTTP client error. It is used to hide what specific http client is used by upload_file(). N)�__name__� __module__�__qualname__�__doc__� � �[/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/utils/malware_response.pyr r = s � � � � � �� � � r r c � � e Zd ZdS )�FileTooLargeErrorN)r r r r r r r! r! D s � � � � � ��Dr r! c �� � t j � � } | d | d | d | d | d | d d�}d� |� � � D � � }|S ) N�id�limit�status�token_expire_utc�token_created_utc�sign)zI360-Idz I360-LimitzI360-StatuszI360-Token-Expire-UtczI360-Token-Created-Utcz I360-Signc �4 � i | ]\ }}|t |� � ��S r )�str)�.0�key�values r � <dictcomp>z%_token_to_headers.<locals>.<dictcomp>R s$ � �A�A�A�:�3��s�C��J�J�A�A�Ar )r � get_token�items)�token�headerss r �_token_to_headersr3 H sm � �� �"�"�E���;��G�n��X��!&�'9�!:�"'�(;�"<��6�]� � �G� B�A������A�A�A�G��Nr c � �� K � |�i }d� |� � � D � � }t t j | � � d�� � � d� � }t j t � � g|z dt |� � � d� � g|duz z ddt j | � � � d d � � � dd� � |fz d dd|� d� � gz }t j |� � � d{V ��\ }}} |dk rC|dk rt n|dk rt nt } | dj di t � � ��� � �|S )a Post *filename* as multipart/form-data to *url* with given HTTP *headers*. Return server response as bytes (http body). Raise TimeoutError on timeout. Raise ConnectionError if failed to connect to host. Raise ClientError on error. Nc �n � g | ]2\ }}d |� d� � |� d� � fz ��3S )s -H%s: %s�asciizlatin-1)�encode)r+ �headerr- s r � <listcomp>z_post_file.<locals>.<listcomp>b sN � � � � ��F�E� �v�}�}�W�-�-�u�|�|�I�/F�/F�G�G�� � r � )�safer6 s --max-times --forms file=@"%s";filename="%s"� \s \\� "s \"s --fails --silents --show-errorr � � zRFailed to post {filename} to {url}: curl: cmd={cmd}, rc={rc}, out={out}, err={err}r )r0 r �os�fsencoder7 �_CURLr* �replacer �run�ConnectionError�TimeoutErrorr �format�vars)�filename�urlr2 �timeout�headers_args�quoted_full_path�cmd�rc�out�err�Errors r � _post_filerS V s� � � � � ����� �$�]�]�_�_�� � �L� (���H�(=�(=�B�G�G�G�N�N��� �� ��U� � �� � ��#�g�,�,�-�-�g�6�6� 7�7�$�;N� O� P� �'� ��H�%�%�����(�(����v�&�&� �� � ����J�J�w��� � � �, ��3���'�'�'�'�'�'�L�B��S� �Q�w�w� �Q�w�w� �O� �R�x�x� ��� � �e� �B�� � � �v�v� � � � � � �Jr �filec � �$ K � t j � � st d� � �t j � | � � }|t j k r.t d� | |t j � � � � �t t t � � }i t � � �d|i�}t | ||t �� � � d{V ��}t! j |� � � � � }t&