From 792895a25cf09e06f1e642b42f4a9beffac63a8d Mon Sep 17 00:00:00 2001
From: vakaris_zilius
Date: Tue, 6 Sep 2022 12:56:06 +0000
Subject: [PATCH] UI: Improve the naming/handling of credential types in the UI
---
.../configuration-components/ReformatHook.js | 10 +++++-----
.../report-components/credentialParsing.js | 12 ++++++------
.../report-components/security/StolenPasswords.js | 2 +-
.../report-components/security/UsedCredentials.js | 2 +-
.../{CredentialTypes.js => CredentialTitles.js} | 6 +++++-
5 files changed, 18 insertions(+), 14 deletions(-)
rename monkey/monkey_island/cc/ui/src/components/utils/{CredentialTypes.js => CredentialTitles.js} (73%)
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 335427b70..239d0c5a0 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
@@ -1,5 +1,5 @@
import {defaultCredentials} from '../../services/configuration/propagation/credentials';
-import {CredentialTypes, SecretTypes} from '../utils/CredentialTypes.js';
+import {PlaintextTypes, SecretTypes} from '../utils/CredentialTitles.js';
import _ from 'lodash';
export function reformatConfig(config, reverse = false) {
@@ -37,16 +37,16 @@ export function formatCredentialsForForm(credentials) {
let secret = credentials[i]['secret'];
if(secret !== null){
if (secret.hasOwnProperty(SecretTypes.Password)) {
- formattedCredentials['exploit_password_list'].push(secret['password'])
+ formattedCredentials['exploit_password_list'].push(secret[SecretTypes.Password])
}
if (secret.hasOwnProperty(SecretTypes.NTHash)) {
- formattedCredentials['exploit_ntlm_hash_list'].push(secret['nt_hash'])
+ formattedCredentials['exploit_ntlm_hash_list'].push(secret[SecretTypes.NTHash])
}
if (secret.hasOwnProperty(SecretTypes.LMHash)) {
- formattedCredentials['exploit_lm_hash_list'].push(secret['lm_hash'])
+ formattedCredentials['exploit_lm_hash_list'].push(secret[SecretTypes.LMHash])
}
if (secret.hasOwnProperty(SecretTypes.PrivateKey)) {
- let keypair = {'public_key': secret['public_key'], 'private_key': secret['private_key']}
+ let keypair = {'public_key': secret[PlaintextTypes.PublicKey], 'private_key': secret[SecretTypes.PrivateKey]}
formattedCredentials['exploit_ssh_keys'].push(keypair)
}
}
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
index fa5660d4e..affc9d967 100644
--- a/monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js
+++ b/monkey/monkey_island/cc/ui/src/components/report-components/credentialParsing.js
@@ -1,4 +1,4 @@
-import {CredentialTypes, SecretTypes} from '../utils/CredentialTypes.js';
+import {CredentialTitles, SecretTypes} from '../utils/CredentialTitles.js';
export function getAllUsernames(stolen, configured) {
let usernames = new Set();
@@ -37,17 +37,17 @@ export function getAllSecrets(stolen, configured) {
function reformatSecret(secret) {
if (secret.hasOwnProperty(SecretTypes.Password)) {
- return {'type': CredentialTypes.Password, 'content': secret[SecretTypes.Password]}
+ return {'title': CredentialTitles.Password, 'content': secret[SecretTypes.Password]}
}
if (secret.hasOwnProperty(SecretTypes.NTHash)) {
- return {'type': CredentialTypes.NTHash, 'content': secret[SecretTypes.NTHash]}
+ return {'title': CredentialTitles.NTHash, 'content': secret[SecretTypes.NTHash]}
}
if (secret.hasOwnProperty(SecretTypes.LMHash)) {
- return {'type': CredentialTypes.LMHash, 'content': secret[SecretTypes.LMHash]}
+ return {'title': CredentialTitles.LMHash, 'content': secret[SecretTypes.LMHash]}
}
if (secret.hasOwnProperty(SecretTypes.PrivateKey)) {
return {
- 'type': CredentialTypes.SSHKeys,
+ 'title': CredentialTitles.SSHKeys,
'content': secret[SecretTypes.PrivateKey]
}
}
@@ -62,7 +62,7 @@ export function getCredentialsTableData(credentials) {
for (let i = 0; i < credentials.length; i++) {
let row_data = {};
row_data['username'] = identites[i];
- row_data['type'] = secrets[i]['type'];
+ row_data['title'] = secrets[i]['title'];
table_data.push(row_data);
}
diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/security/StolenPasswords.js b/monkey/monkey_island/cc/ui/src/components/report-components/security/StolenPasswords.js
index 441bac8b1..b1b6ac5c2 100644
--- a/monkey/monkey_island/cc/ui/src/components/report-components/security/StolenPasswords.js
+++ b/monkey/monkey_island/cc/ui/src/components/report-components/security/StolenPasswords.js
@@ -7,7 +7,7 @@ const columns = [
Header: 'Stolen Credentials',
columns: [
{Header: 'Username', accessor: 'username'},
- {Header: 'Type', accessor: 'type'}
+ {Header: 'Type', accessor: 'title'}
]
}
];
diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/security/UsedCredentials.js b/monkey/monkey_island/cc/ui/src/components/report-components/security/UsedCredentials.js
index 7a5becde7..536ec5ec7 100644
--- a/monkey/monkey_island/cc/ui/src/components/report-components/security/UsedCredentials.js
+++ b/monkey/monkey_island/cc/ui/src/components/report-components/security/UsedCredentials.js
@@ -24,7 +24,7 @@ class UsedCredentials extends React.Component {
{allSecrets.map((x, index) => - {x['type']}: {x['content'].substr(0, 3) + '******'}
)}
+ key={index}>{x['title']}: {x['content'].substr(0, 3) + '******'})}
>
:
diff --git a/monkey/monkey_island/cc/ui/src/components/utils/CredentialTypes.js b/monkey/monkey_island/cc/ui/src/components/utils/CredentialTitles.js
similarity index 73%
rename from monkey/monkey_island/cc/ui/src/components/utils/CredentialTypes.js
rename to monkey/monkey_island/cc/ui/src/components/utils/CredentialTitles.js
index 494e5b36f..d24c1e3e1 100644
--- a/monkey/monkey_island/cc/ui/src/components/utils/CredentialTypes.js
+++ b/monkey/monkey_island/cc/ui/src/components/utils/CredentialTitles.js
@@ -1,4 +1,4 @@
-export const CredentialTypes = {
+export const CredentialTitles = {
Password: 'Clear Password',
SSHKeys: 'Clear SSH private key',
LMHash: 'LM hash',
@@ -12,3 +12,7 @@ export const SecretTypes = {
LMHash: 'lm_hash',
NTHash: 'nt_hash'
}
+
+export const PlaintextTypes = {
+ PublicKey: 'public_key'
+}