Island, Common: Small style improvements

This commit is contained in:
vakaris_zilius 2022-09-06 13:24:03 +00:00
parent 16a59a3f5a
commit b08097b131
4 changed files with 35 additions and 25 deletions

View File

@ -12,5 +12,5 @@ class LMHash(BaseModel):
@validator("lm_hash") @validator("lm_hash")
def validate_hash_format(cls, nt_hash): def validate_hash_format(cls, nt_hash):
if not re.match(ntlm_hash_regex, nt_hash): if not re.match(ntlm_hash_regex, nt_hash):
raise ValueError(f"Invalid lm hash provided: {nt_hash}") raise ValueError(f"Invalid LM hash provided: {nt_hash}")
return nt_hash return nt_hash

View File

@ -12,5 +12,5 @@ class NTHash(InfectionMonkeyBaseModel):
@validator("nt_hash") @validator("nt_hash")
def validate_hash_format(cls, nt_hash): def validate_hash_format(cls, nt_hash):
if not re.match(ntlm_hash_regex, nt_hash): if not re.match(ntlm_hash_regex, nt_hash):
raise ValueError(f"Invalid nt hash provided: {nt_hash}") raise ValueError(f"Invalid NT hash provided: {nt_hash}")
return nt_hash return nt_hash

View File

@ -6,16 +6,21 @@ export function reformatConfig(config, reverse = false) {
let formattedConfig = _.clone(config); let formattedConfig = _.clone(config);
if (reverse) { if (reverse) {
if(formattedConfig['payloads'].length === 1){ if (formattedConfig['payloads'].length === 1) {
// Second click on Export // Second click on Export
formattedConfig['payloads'] = [{'name': 'ransomware', 'options': formattedConfig['payloads'][0]['options']}]; formattedConfig['payloads'] = [{
'name': 'ransomware',
'options': formattedConfig['payloads'][0]['options']
}];
} else { } else {
formattedConfig['payloads'] = [{'name': 'ransomware', 'options': formattedConfig['payloads']}]; formattedConfig['payloads'] = [{
'name': 'ransomware',
'options': formattedConfig['payloads']
}];
} }
formattedConfig['keep_tunnel_open_time'] = formattedConfig['advanced']['keep_tunnel_open_time']; formattedConfig['keep_tunnel_open_time'] = formattedConfig['advanced']['keep_tunnel_open_time'];
} else { } else {
if(formattedConfig['payloads'].length !== 0) if (formattedConfig['payloads'].length !== 0) {
{
formattedConfig['payloads'] = formattedConfig['payloads'][0]['options']; formattedConfig['payloads'] = formattedConfig['payloads'][0]['options'];
} else { } else {
formattedConfig['payloads'] = {'encryption': {}, 'other_behaviors': {}} formattedConfig['payloads'] = {'encryption': {}, 'other_behaviors': {}}
@ -30,23 +35,26 @@ export function formatCredentialsForForm(credentials) {
let formattedCredentials = _.clone(defaultCredentials); let formattedCredentials = _.clone(defaultCredentials);
for (let i = 0; i < credentials.length; i++) { for (let i = 0; i < credentials.length; i++) {
let identity = credentials[i]['identity']; let identity = credentials[i]['identity'];
if(identity !== null) { if (identity !== null) {
formattedCredentials['exploit_user_list'].push(identity.username) formattedCredentials['exploit_user_list'].push(identity.username)
} }
let secret = credentials[i]['secret']; let secret = credentials[i]['secret'];
if(secret !== null){ if (secret !== null) {
if (secret.hasOwnProperty(SecretTypes.Password)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.Password)) {
formattedCredentials['exploit_password_list'].push(secret[SecretTypes.Password]) formattedCredentials['exploit_password_list'].push(secret[SecretTypes.Password])
} }
if (secret.hasOwnProperty(SecretTypes.NTHash)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.NTHash)) {
formattedCredentials['exploit_ntlm_hash_list'].push(secret[SecretTypes.NTHash]) formattedCredentials['exploit_ntlm_hash_list'].push(secret[SecretTypes.NTHash])
} }
if (secret.hasOwnProperty(SecretTypes.LMHash)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.LMHash)) {
formattedCredentials['exploit_lm_hash_list'].push(secret[SecretTypes.LMHash]) formattedCredentials['exploit_lm_hash_list'].push(secret[SecretTypes.LMHash])
} }
if (secret.hasOwnProperty(SecretTypes.PrivateKey)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.PrivateKey)) {
let keypair = {'public_key': secret[PlaintextTypes.PublicKey], 'private_key': secret[SecretTypes.PrivateKey]} let keypair = {
'public_key': secret[PlaintextTypes.PublicKey],
'private_key': secret[SecretTypes.PrivateKey]
}
formattedCredentials['exploit_ssh_keys'].push(keypair) formattedCredentials['exploit_ssh_keys'].push(keypair)
} }
} }
@ -78,8 +86,10 @@ export function formatCredentialsForIsland(credentials) {
for (let i = 0; i < ssh_keys.length; i++) { for (let i = 0; i < ssh_keys.length; i++) {
formattedCredentials.push({ formattedCredentials.push({
'identity': null, 'identity': null,
'secret': {'private_key': ssh_keys[i]['private_key'], 'secret': {
'public_key': ssh_keys[i]['public_key']} 'private_key': ssh_keys[i]['private_key'],
'public_key': ssh_keys[i]['public_key']
}
}) })
} }
@ -89,10 +99,10 @@ export function formatCredentialsForIsland(credentials) {
function getFormattedCredentials(credentials, keyOfSecret) { function getFormattedCredentials(credentials, keyOfSecret) {
let formattedCredentials = []; let formattedCredentials = [];
for (let i = 0; i < credentials.length; i++) { for (let i = 0; i < credentials.length; i++) {
formattedCredentials.push({ formattedCredentials.push({
'identity': null, 'identity': null,
'secret': {[keyOfSecret]: credentials[i]} 'secret': {[keyOfSecret]: credentials[i]}
}) })
} }
return formattedCredentials; return formattedCredentials;
} }

View File

@ -36,16 +36,16 @@ export function getAllSecrets(stolen, configured) {
} }
function reformatSecret(secret) { function reformatSecret(secret) {
if (secret.hasOwnProperty(SecretTypes.Password)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.Password)) {
return {'title': CredentialTitles.Password, 'content': secret[SecretTypes.Password]} return {'title': CredentialTitles.Password, 'content': secret[SecretTypes.Password]}
} }
if (secret.hasOwnProperty(SecretTypes.NTHash)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.NTHash)) {
return {'title': CredentialTitles.NTHash, 'content': secret[SecretTypes.NTHash]} return {'title': CredentialTitles.NTHash, 'content': secret[SecretTypes.NTHash]}
} }
if (secret.hasOwnProperty(SecretTypes.LMHash)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.LMHash)) {
return {'title': CredentialTitles.LMHash, 'content': secret[SecretTypes.LMHash]} return {'title': CredentialTitles.LMHash, 'content': secret[SecretTypes.LMHash]}
} }
if (secret.hasOwnProperty(SecretTypes.PrivateKey)) { if (Object.prototype.hasOwnProperty.call(secret, SecretTypes.PrivateKey)) {
return { return {
'title': CredentialTitles.SSHKeys, 'title': CredentialTitles.SSHKeys,
'content': secret[SecretTypes.PrivateKey] 'content': secret[SecretTypes.PrivateKey]