From 4f4bba23cfd8b36aa56dde2d075d5613abbd2b7f Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 21 Jul 2022 09:10:12 +0200 Subject: [PATCH] UI: Use simplified credentials in ReformatHook.js --- .../configuration-components/ReformatHook.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ReformatHook.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/ReformatHook.js index 5240f7080..6be6c521c 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ReformatHook.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ReformatHook.js @@ -11,15 +11,15 @@ export function reformatConfig(config, reverse = false) { } export function formatCredentialsForForm(credentials) { - console.log(credentials); let formattedCredentials = _.clone(defaultCredentials); for (let i = 0; i < credentials.length; i++) { - for (let j = 0; j < credentials[i].identities.length; j++) { - formattedCredentials['exploit_user_list'].push(credentials[i]['identities'][j].username) + let identity = credentials[i]['identity']; + if(identity !== null) { + formattedCredentials['exploit_user_list'].push(identity.username) } - for (let j = 0; j < credentials[i].secrets.length; j++) { - console.log(credentials[i]) - let secret = credentials[i]['secrets'][j]; + + let secret = credentials[i]['secret']; + if(secret !== null){ if (secret['credential_type'] === 'PASSWORD') { formattedCredentials['exploit_password_list'].push(secret['password']) } @@ -43,41 +43,41 @@ export function formatCredentialsForIsland(credentials) { let usernames = credentials['exploit_user_list']; for (let i = 0; i < usernames.length; i++) { formattedCredentials.push({ - 'identities': [{'username': usernames[i], 'credential_type': 'USERNAME'}], - 'secrets': [] + 'identity': {'username': usernames[i], 'credential_type': 'USERNAME'}, + 'secret': null }) } let passwords = credentials['exploit_password_list']; for (let i = 0; i < passwords.length; i++) { formattedCredentials.push({ - 'identities': [], - 'secrets': [{'credential_type': 'PASSWORD', 'password': passwords[i]}] + 'identity': null, + 'secret': {'credential_type': 'PASSWORD', 'password': passwords[i]} }) } let nt_hashes = credentials['exploit_ntlm_hash_list']; for (let i = 0; i < nt_hashes.length; i++) { formattedCredentials.push({ - 'identities': [], - 'secrets': [{'credential_type': 'NT_HASH', 'nt_hash': nt_hashes[i]}] + 'identity': null, + 'secret': {'credential_type': 'NT_HASH', 'nt_hash': nt_hashes[i]} }) } let lm_hashes = credentials['exploit_lm_hash_list']; for (let i = 0; i < lm_hashes.length; i++) { formattedCredentials.push({ - 'identities': [], - 'secrets': [{'credential_type': 'LM_HASH', 'lm_hash': lm_hashes[i]}] + 'identity': null, + 'secret': {'credential_type': 'LM_HASH', 'lm_hash': lm_hashes[i]} }) } let ssh_keys = credentials['exploit_ssh_keys']; for (let i = 0; i < ssh_keys.length; i++) { formattedCredentials.push({ - 'identities': [], - 'secrets': [{'credential_type': 'SSH_KEYPAIR', 'private_key': ssh_keys[i]['private_key'], - 'public_key': ssh_keys[i]['public_key']}] + 'identity': null, + 'secret': {'credential_type': 'SSH_KEYPAIR', 'private_key': ssh_keys[i]['private_key'], + 'public_key': ssh_keys[i]['public_key']} }) }