From e61b0bfdcad98ae24920f4cc2ad0af3f5236663c Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 14 Jul 2022 16:48:27 +0200 Subject: [PATCH] UI: Add credentials parsing functionalities --- .../report-components/credentialParsing.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js b/monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js new file mode 100644 index 000000000..73ece9502 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js @@ -0,0 +1,66 @@ +export function getAllUsernames(stolen, configured){ + let usernames = []; + usernames.push(...getCredentialsUsernames(stolen)); + usernames.push(...getCredentialsUsernames(configured)); + return usernames; +} + +export function getCredentialsSecrets(credentials, credential_type) { + let secrets = []; + + for(let i = 0; i < credentials.length; i++){ + secrets.push(credentials[i]['secrets'][0][credential_type]); + } + return secrets; +} + +export function getCredentialsUsernames(credentials) { + let usernames = []; + for(let i = 0; i < credentials.length; i++){ + usernames.push(credentials[i]['identities'][0]['username']); + } + return usernames; +} + +export function getAllSecrets(stolen, configured){ + let secrets = []; + for(let i = 0; i < stolen.length; i++){ + secrets.push(getSecretsFromCredential(stolen[i]['secrets'][0])); + } + for(let i = 0; i < configured.length; i++){ + secrets.push(getSecretsFromCredential(configured[i]['secrets'][0])); + } + return secrets; +} + +function getSecretsFromCredential(credential) { + if(credential['credential_type'] === 'SSH_KEYPAIR'){ + return {'type': 'SSH keypair', 'content': credential['private_key']} + } + if(credential['credential_type'] === 'NT_HASH'){ + return {'type': 'NT hash', 'content': credential['nt_hash']} + } + if(credential['credential_type'] === 'LM_HASH'){ + return {'type': 'LM hash', 'content': credential['lm_hash']} + } + if(credential['credential_type'] === 'PASSWORD'){ + return {'type': 'Password', 'content': credential['password']} + } +} + +export function getCredentialsTableData(credentials) { + + let table_data = []; + + let identites = getCredentialsUsernames(credentials); + let secrets = getAllSecrets(credentials, []) + + for(let i=0; i