Пример #1
0
    def download_dionaea_binaries(self):
        self.connect()
        sftp = self.ssh.open_sftp()

        storage_path = util.load_config_string(self.config, 'Samples', 'storage_path')
        binaries_path = util.load_config_string(self.config, 'Dionaea', 'binaries')

        local_binaries = os.path.join(storage_path, util.load_config_string(self.config, 'Samples',
                                                                            'dionaea_binary_path'))
        local_binaries_tmp = os.path.join(local_binaries, ".tmp")

        # Create our directories if not exist
        if not os.path.exists(local_binaries):
            self.logger.info("Local binaries path doesn't exist. Creating it now")
            os.makedirs(local_binaries)
        if not os.path.exists(local_binaries_tmp):
            os.makedirs(local_binaries_tmp)

        # Download the binaries to the temp folder
        self.logger.info("Downloading Dionaea binaries...")
        self.download_dir(binaries_path, local_binaries_tmp, sftp)

        # Zip the binaries (if in config)
        if util.load_config_boolean(self.config, 'Samples', 'zip_binaries'):
            if not file_utils.zipall(local_binaries_tmp):
                self.logger.critical("Failed to zip downloaded binaries!")

        # Move the binaries to the final location
        if util.load_config_boolean(self.config, 'Samples', 'keep_duplicate_binaries'):
            file_utils.moveall(local_binaries_tmp, local_binaries, True)
        else:
            file_utils.moveall(local_binaries_tmp, local_binaries, False)
        os.rmdir(local_binaries_tmp)
Пример #2
0
    def __init__(self, config):
        # Setup our logging
        logging.basicConfig(level=logging.DEBUG)
        self.logger = logging.getLogger(__name__)

        # Get our server info from config
        self.config = config
        self.host = util.load_config_string(self.config, 'Server', 'host')
        self.port = util.load_config_int(self.config, 'Server', 'port')
        self.allow_unknown = util.load_config_boolean(self.config, 'Server', 'allow_unknown_hosts')
        self.user = util.load_config_string(self.config, 'Auth', 'user')
        self.paswd = util.load_config_string(self.config, 'Auth', 'pass')
        self.ssh = paramiko.SSHClient()

        self.logger.debug("Using server: %s:%s" % (self.host, self.port))