GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 173.249.157.85  /  Your IP : 18.218.169.79
Web Server : Apache
System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User : econtech ( 1005)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/Acronis/BackupAndRecovery/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/Acronis/BackupAndRecovery/sysinfo.py
# @copyright (c) 2002-2016 Acronis International GmbH. All rights reserved.

"""Acronis System Info Report Utility."""

import glob, os, sys
import argparse
import subprocess
import shutil
import hashlib
import sqlite3


class _SysInfoReportBase():
    # Base class for sys-info reports

    _PLATFORM_LINUX, _PLATFORM_WIN, _PLATFORM_MACOS = range(3)

    def __init__(self, platform, report_dir, cmd_name):
        # Arguments
        #   - platform: (optional) one of _PLATFORM_* constants
        #   - report_dir: path to report directory
        #   - cmd_name: name of report command (f.e. 'collect_configs')
        #     Used for diagnostic purposes only
        self.cmd_name = cmd_name
        self.report_dir = os.path.abspath(report_dir)
        self.platform = platform if platform is not None else self._detect_platform()

    @classmethod
    def _detect_platform(cls):
        if sys.platform.startswith('win32'):
            return cls._PLATFORM_WIN
        elif sys.platform.startswith('linux'):
            return cls._PLATFORM_LINUX
        elif sys.platform.startswith('darwin'):
            return cls._PLATFORM_MACOS
        assert False, "Unexpected sys.platform name: {}".format(sys.platform)

    def _get_install_paths(self):
        # get list of Acronis installation locations
        if self.platform == self._PLATFORM_LINUX:
            self._ETC_DIR = "/etc/Acronis"
            self._USR_LIB_DIR = "/usr/lib/Acronis"
            self._VAR_LIB_DIR = "/var/lib/Acronis"
            self._OPT_DIR = "/opt/acronis"
            return [self._ETC_DIR, self._USR_LIB_DIR, self._VAR_LIB_DIR, self._OPT_DIR]
        elif self.platform == self._PLATFORM_WIN:
            return self._get_install_paths_windows()
        else:
            self._ACRONIS_DIR = "/Library/Application Support/Acronis"
            return [
                self._ACRONIS_DIR,
                "/Library/Application Support/BackupClient",
                "/Library/Logs/Acronis"
            ]

    def _get_install_paths_windows(self):
        # on windows product installation path should be taken from registry
        import acrobind
        import acrort

        install_paths = set([])

        brand_name = acrort.common.BRAND_NAME

        for path_id in ('COMMONPROGRAMFILES', 'COMMONPROGRAMFILES(x86)',
                        'PROGRAMDATA', 'ALLUSERSPROFILE'):
            # paths like "C:\Program Files\Common Files\Acronis"
            #
            # %PROGRAMDATA% and %ALLUSERSPROFILE% reference the
            # same dir: usually "C:\ProgramData". But one of these variables
            # may be not present depending on Windows version.
            if path_id in os.environ:
                install_paths.add(os.path.join(os.environ[path_id], brand_name))

        key_path = r"SOFTWARE\{}\Installer".format(brand_name)
        val_name = "TargetDir"
        product_install_path = acrobind.registry_read_string(key_path, val_name)

        if product_install_path:
            install_paths.add(product_install_path)
        else:
            print(
                "Warning: Processing '{0}' report command. "
                "Product installation dir not found in registry. "
                "key_path: {1}, val_name {2}".format(self.cmd_name, key_path, val_name))

        return sorted(install_paths)

    @staticmethod
    def _dump_sqlite3_db(db_path, output_csv, exclude_tables_list):
        with sqlite3.connect(db_path) as conn:
            cursor = conn.cursor()
            tables = cursor.execute("SELECT name FROM sqlite_master WHERE type='table';").fetchall()
            if exclude_tables_list is None:
                table_names = [table[0] for table in tables]
            else:
                table_names = [table[0] for table in tables if table[0] not in exclude_tables_list]
            with open(output_csv, "w", encoding='utf-8') as csvfile:
                for table_name in table_names:
                    rows = cursor.execute("SELECT * FROM {};".format(table_name)).fetchall()
                    headers = cursor.execute("PRAGMA table_info('{}');".format(table_name)).fetchall()
                    header_names = [header[1] for header in headers]
                    csvfile.write("Table: {}\n".format(table_name))
                    csvfile.write(",".join(header_names) + "\r\n")
                    for row in rows:
                        csvfile.write(",".join(map(str, row)) + "\r\n")

    @staticmethod
    def _iter_files(top_dir, ignore_dirs, file_extentions=[], ignore_files=[]):
        # recursively yield (dir_name, file_name) for files from specified directory
        #
        # Arguments:
        #   - top_dir: top-level directory to yield files from
        #   - ignore_dirs: ignore files in this dir (usefull if report directory
        #       is inside top_dir or when you want to skip the "mount" dir where
        #       backups are mounted).
        #   - file_extentions: (optional) only yield files matching the extentions
        #   - ignore_files: (optional) ignore files ending with the given paths

        for i in range(len(ignore_dirs)):
            ignore_dirs[i] = os.path.normpath(ignore_dirs[i])
        for i in range(len(ignore_files)):
            ignore_files[i] = os.path.normpath(ignore_files[i])

        for dir_name, _sub_dirs, file_names in os.walk(top_dir):
            if ignore_dirs and \
                any(os.path.commonpath([dir_name, ignore_dir]) == ignore_dir
                    for ignore_dir in ignore_dirs):
                continue
            for file_name in file_names:
                if file_extentions:
                    if not any(file_name.endswith(ext) for ext in file_extentions):
                        continue
                if ignore_files:
                    if any(os.path.join(dir_name, file_name).endswith(ignore_file) for ignore_file in ignore_files):
                        continue
                yield (dir_name, file_name)


#########################
# collect conf files

class _CollectConfigFilesReport(_SysInfoReportBase):
    # inclde all the Acronis configuration files into the report

    def run_report(self):
        configs_report_subdir = os.path.join(self.report_dir, "configs")

        file_extentions = [".config", ".cfg", ".conf", ".xml", ".json", ".ini", ".yml", ".yaml", ".db"]
        ignore_files = ["ml_analysis.xml", "AccessVault/config/preferred.json", "MMS/user.config", "Agent/var/credentials-store/credentials_store.db"]
        install_paths = self._get_install_paths()

        src_2_tgt_dirs = {}  # {conf_file_dir: dir_in_report}

        ignore_dirs = [self.report_dir]
        if self.platform == self._PLATFORM_LINUX:
            ignore_dirs.append(os.path.join(self._VAR_LIB_DIR, "mount"))
            ignore_dirs.append(os.path.join(self._VAR_LIB_DIR, "NGMP"))
            ignore_dirs.extend(glob.glob(os.path.join(self._VAR_LIB_DIR, "sysinfo*")))
        if self.platform == self._PLATFORM_MACOS:
            ignore_dirs.extend(glob.glob(os.path.join(self._ACRONIS_DIR, "sysinfo*")))


        for top_dir in install_paths:
            for dir_name, file_name in self._iter_files(top_dir, ignore_dirs, file_extentions, ignore_files):
                if dir_name not in src_2_tgt_dirs:
                    src_2_tgt_dirs[dir_name] = self._make_tgt_dir_for_configs_report(
                        dir_name, configs_report_subdir)
                tgt_dir = src_2_tgt_dirs[dir_name]
                tgt_file = os.path.join(tgt_dir, file_name)
                src_file = os.path.join(dir_name, file_name)
                if file_name.endswith("account_server.db"):
                    tgt_file = tgt_file + '.txt'
                    tables_2_exclude = [
                        'clients',
                        'rsa_keys',
                        'keys_table',
                        '__client_old',
                        'backup_servers',
                        'identity_providers',
                        'identities',
                        'refresh_tokens',
                        'opaque_tokens']
                    acc_srv_dir = os.path.join(self.report_dir, "AccountServer")
                    if not os.path.exists(acc_srv_dir):
                        os.mkdir(acc_srv_dir)
                    self._dump_sqlite3_db(src_file, os.path.join(acc_srv_dir, "db_dump.txt"), tables_2_exclude)
                elif file_name.endswith("api_gateway.json"):
                    if self.platform in (self._PLATFORM_LINUX, self._PLATFORM_MACOS):
                        os.system('grep -vwE "{0}" "{1}" > "{2}"'.format('passphrase', src_file, tgt_file))
                    else:
                        os.system('findstr -V "{0}" "{1}" > "{2}"'.format('passphrase', src_file, tgt_file))
                elif file_name.endswith("Global.config"):
                    if self.platform in (self._PLATFORM_LINUX, self._PLATFORM_MACOS):
                        os.system('grep -vwE "{0}" "{1}" > "{2}"'.format('(Username|Password)', src_file, tgt_file))
                else:
                    shutil.copy(src_file, tgt_file)

    def _make_tgt_dir_for_configs_report(self, config_dir_name, configs_report_subdir):
        # returns abs path of dir in the report to copy the config file to.
        # Create the dir if not exist yet.
        if self.platform in (self._PLATFORM_LINUX, self._PLATFORM_MACOS):
            tgt_file_rel_path = os.path.relpath(config_dir_name, "/")
        else:  # self.platform == _PLATFORM_WIN
            drive = os.path.splitdrive(config_dir_name)[0]  # "C:"
            drive = os.path.join(drive, os.sep)             # "C:\\"
            tgt_file_rel_path = os.path.relpath(config_dir_name, drive)
        tgt_file_location = os.path.join(configs_report_subdir, tgt_file_rel_path)
        os.makedirs(tgt_file_location, exist_ok=True)
        return tgt_file_location


#########################
# report Acronis files hashes

class _CollectFileHashes(_SysInfoReportBase):
    # calculate hashes of all the Acronis files

    def run_report(self):

        no_hash_for_exts = [".log", ]

        with open(os.path.join(self.report_dir, "file_hashes.txt"), "w+") as out_file:
            for file_path in self._iter_installed_files():
                skip_hash = (
                    any(file_path.endswith(ext) for ext in no_hash_for_exts)
                    or not os.path.isfile(file_path))

                if skip_hash:
                    hexdigest = "n/a"
                else:
                    with open(file_path, "rb") as file_data:
                        hexdigest = hashlib.md5(file_data.read()).hexdigest()
                out_file.write("{0}\t{1}\n".format(file_path, hexdigest))

    def _iter_installed_files(self):
        # yields all the files in Acronis installation directories

        ignore_dirs = [self.report_dir]
        if self.platform == self._PLATFORM_LINUX:
            ignore_dirs.append(os.path.join(self._VAR_LIB_DIR, "mount"))
            ignore_dirs.append(os.path.join(self._VAR_LIB_DIR, "NGMP"))
            ignore_dirs.extend(glob.glob(os.path.join(self._VAR_LIB_DIR, "sysinfo*")))
        if self.platform == self._PLATFORM_MACOS:
            ignore_dirs.extend(glob.glob(os.path.join(self._ACRONIS_DIR, "sysinfo*")))

        for top_loc in self._get_install_paths():
            for dir_name, file_name in self._iter_files(top_loc, ignore_dirs,
                                                        ignore_files=[".pyc", ]):
                yield os.path.join(dir_name, file_name)


#########################
# report netstat

class _CollectNetstat(_SysInfoReportBase):
    # just report 'netstat -a' output

    def run_report(self):
        rep_file_path = os.path.join(self.report_dir, "netstat.txt")

        options = "-nab"
        if self.platform == self._PLATFORM_LINUX:
            if os.path.isfile("/bin/acronis"):
                options = "-na"
            else:
                options = "-nap"

        netstat_executable = shutil.which("netstat")
        if netstat_executable is not None and len(netstat_executable) > 0:
          with open(rep_file_path, "w+") as outfile:
              subprocess.call([netstat_executable, options], stdout=outfile)


#########################
# common functionality

_REPORT_CLASSES = {
    'collect_configs': _CollectConfigFilesReport,
# Disable hash collection because perfomance degradation  ABR-121489: Collecting sysinfo loads 100% CPU and woks too long ~ 5 min
#    'collect_filehashes': _CollectFileHashes,
    'netstat': _CollectNetstat,
}


def _parse_arguments():
    parser = argparse.ArgumentParser(
        description=("Part of Acronis sysinfo utility. "
                     "!!! Not intended to be executed directly !!!"))

    parser.add_argument(
        "-o", "--output-dir",
        dest="output_dir",
        help=("(optional) Path to output report directory. "
              "Default is current directory."))

    platform_names = {
        'linux': _SysInfoReportBase._PLATFORM_LINUX,
        'macos': _SysInfoReportBase._PLATFORM_MACOS,
        'win': _SysInfoReportBase._PLATFORM_WIN}

    parser.add_argument(
        "-p", "--platform",
        dest="platform_name",
        choices=sorted(platform_names.keys()))

    parser.add_argument(
        "--optimized",
        dest="optimized",
        default=False,
        action='store_true',
        help='(optional) Optimize data collection.')

    parser.add_argument(
        "--days ",
        dest="days",
        type=int,
        help='(optional) Collect data for the last <DAYS> prior to current date.')

    parser.add_argument(
        "commands", nargs='*', metavar='command',
        choices=[[]] + sorted(_REPORT_CLASSES.keys()),
        help=("(optional) Data collection command. "
              "If not specified all commands will be executed."))

    args = parser.parse_args()

    if args.days and args.days < 1:
        raise argparse.ArgumentTypeError("{0} days number is wrong. Minimum days number is 1.".format(args.days))

    platform = platform_names.get(args.platform_name)

    output_dir = args.output_dir if args.output_dir is not None else os.getcwd()

    commands_to_execute = args.commands if args.commands else sorted(_REPORT_CLASSES.keys())

    return platform, output_dir, commands_to_execute


if __name__ == '__main__':

    platform, output_dir, commands_to_execute = _parse_arguments()

    for cmd_name in commands_to_execute:
        try:
            cmd_report = _REPORT_CLASSES[cmd_name](platform, output_dir, cmd_name)
            cmd_report.run_report()
        except:
            print("Warning: error processing '{0}' report command.".format(cmd_name))
            import traceback
            traceback.print_exc(file=sys.stdout)

Youez - 2016 - github.com/yon3zu
LinuXploit