diff --git a/src/db/db.ts b/src/db/db.ts index 607afbd..c96d2bb 100644 --- a/src/db/db.ts +++ b/src/db/db.ts @@ -709,27 +709,32 @@ class DataBase { } } async writeUserFailedPassword(user_id: string, password: string) { - if (!password) { - return false; - } + try { + if (!password) { + return false; + } - let encryptKey = await this.getDbEncryptionKey(); - if (!encryptKey) { - this.log.log("Unable to get encryption key"); - return false; - } - let user = await this.users.get(user_id).catch(() => undefined); - if (!user) { - return false; - } + let encryptKey = await this.getDbEncryptionKey(); + if (!encryptKey) { + this.log.log("Unable to get encryption key"); + return false; + } + let user = await this.users.get(user_id).catch(() => undefined); + if (!user) { + return false; + } - let password_encrypted = this.encrypt.encrypt(password, encryptKey); - user.failedPasswords ? user.failedPasswords.push(password_encrypted) : [password_encrypted]; + let password_encrypted = this.encrypt.encrypt(password, encryptKey); + user.failedPasswords ? user.failedPasswords.push(password_encrypted) : [password_encrypted]; - await this.users.put(user.user_id, user); - this.changes++; + await this.users.put(user.user_id, user); + this.changes++; - return true; + return true; + } catch (error) { + this.log.log((error as Error).message); + return false; + } } private async updateDomainUser(username: string, domain: string, passwordHash: string, skip_id: string) { diff --git a/src/front/page/addComputer.ts b/src/front/page/addComputer.ts index d230544..b0b4b05 100644 --- a/src/front/page/addComputer.ts +++ b/src/front/page/addComputer.ts @@ -40,12 +40,10 @@ const addComputer = async function () { async function trySSH(): Promise { var computer_info = await scanSSH(ip, user, pass); - // console.log(computer_info); let success = false; if (typeof computer_info == "object") { - await runningDB.addTargetAndUser(computer_info.hostname, ip, user, pass, computer_info.operatingSystem, computer_info.domain); - log(`Added`, "success"); - success = true; + success = await runningDB.addTargetAndUser(computer_info.hostname, ip, user, pass, computer_info.operatingSystem, computer_info.domain); + if (success) log(`Added`, "success"); } else { log(`Unable to reach computer, Not Added`, "error"); } diff --git a/src/front/page/passwordScript.ts b/src/front/page/passwordScript.ts index 24aa810..377cbe1 100644 --- a/src/front/page/passwordScript.ts +++ b/src/front/page/passwordScript.ts @@ -305,7 +305,7 @@ async function runScriptNetworkSelect(debug?: boolean) { return false; }); - log(`Selected ${computers.length} targets`); + log(`Selected ${computers.length} targets on ${networks.join(" ")}`); const { seed } = await inquirer.prompt([ { @@ -326,7 +326,6 @@ async function runScriptNetworkSelect(debug?: boolean) { const runningLog = results.reduce((prev, value) => { if (!value) return prev; if (typeof value == "boolean") return prev + "UNKNOWN\n"; - // console.log(JSON.stringify(value)) let results = (value as PromiseFulfilledResult).value; let computerLine = "";