diff --git a/monkey/monkey_island/cc/services/utils/config_encryption.py b/monkey/monkey_island/cc/services/utils/config_encryption.py index 3c3488b47..379e91c74 100644 --- a/monkey/monkey_island/cc/services/utils/config_encryption.py +++ b/monkey/monkey_island/cc/services/utils/config_encryption.py @@ -4,18 +4,18 @@ from typing import Dict import pyAesCrypt +# TODO use from pyAesCrypt BUFFER_SIZE = 64 * 1024 -def encrypt_config(config: Dict, password: str) -> bytes: +def encrypt_config(config: Dict, password: str) -> str: plaintext_config_stream = io.BytesIO(json.dumps(config).encode()) ciphertext_config_stream = io.BytesIO() pyAesCrypt.encryptStream( plaintext_config_stream, ciphertext_config_stream, password, BUFFER_SIZE ) - - ciphertext_config_bytes = ciphertext_config_stream.getvalue() + ciphertext_config_bytes = str(ciphertext_config_stream.getvalue()) return ciphertext_config_bytes diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx index 7e9458979..b2adbc694 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx @@ -1,6 +1,7 @@ import {Button, Modal, Form} from 'react-bootstrap'; import React, {useState} from 'react'; +import FileSaver from 'file-saver'; import AuthComponent from '../AuthComponent'; import '../../styles/components/configuration-components/ExportConfigModal.scss'; @@ -33,8 +34,12 @@ const ConfigExportModal = (props: Props) => { }) } ) - .then(res => { - console.log(res.json()); + .then(res => res.json()) + .then(res => { + console.log(res); + const configAsBinary = new Blob([res['encrypted_config']]); + + FileSaver.saveAs(configAsBinary, 'monkey.conf'); }) }