mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
DARKNET: Add extra hint to sorted echo puzzle at high levels (#2465)
This commit is contained in:
committed by
GitHub
parent
451aed153f
commit
60a8996707
@@ -124,6 +124,23 @@ export const checkPassword = (
|
||||
`${altitude}`,
|
||||
);
|
||||
}
|
||||
case ModelIds.SortedEchoVuln: {
|
||||
if (server.password.length < 5 || attemptedPassword.length !== server.password.length) {
|
||||
return getFailureResponse(attemptedPassword, server.staticPasswordHint, server.passwordHintData);
|
||||
}
|
||||
let squaredError = 0;
|
||||
for (let i = 0; i < attemptedPassword.length; i++) {
|
||||
const attempted = Number(attemptedPassword[i]);
|
||||
const actual = Number(server.password[i]);
|
||||
if (!Number.isFinite(attempted)) {
|
||||
return getFailureResponse(attemptedPassword, server.staticPasswordHint, server.passwordHintData);
|
||||
}
|
||||
squaredError += (attempted - actual) ** 2;
|
||||
}
|
||||
const rmsd = Math.sqrt(squaredError / attemptedPassword.length);
|
||||
const rmsdMessage = `${server.passwordHintData}; RMS Deviation:${rmsd.toFixed(3)}`;
|
||||
return getFailureResponse(attemptedPassword, server.staticPasswordHint, rmsdMessage);
|
||||
}
|
||||
default:
|
||||
return getFailureResponse(attemptedPassword, server.staticPasswordHint, server.passwordHintData);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
getXorMaskEncryptedPasswordConfig,
|
||||
getTripleModuloConfig,
|
||||
getKingOfTheHillConfig,
|
||||
getSortedEchoVulnConfig,
|
||||
} from "../../../src/DarkNet/controllers/ServerGenerator";
|
||||
import {
|
||||
commonPasswordDictionary,
|
||||
@@ -616,6 +617,33 @@ describe("Password Tests", () => {
|
||||
expect(successResult.response.code).toBe(ResponseCodeEnum.Success);
|
||||
});
|
||||
|
||||
test("sortedEchoVuln creates a valid password and hint", () => {
|
||||
const sortedEchoVulnServer = serverFactory(getSortedEchoVulnConfig, 20, 0, 0);
|
||||
sortedEchoVulnServer.password = "12345";
|
||||
sortedEchoVulnServer.passwordHintData = "41532";
|
||||
|
||||
expect(sortedEchoVulnServer).toBeDefined();
|
||||
const failedAttemptResponse = getAuthResult(sortedEchoVulnServer, "23456", 1);
|
||||
expect(failedAttemptResponse.result.code).toBe(ResponseCodeEnum.AuthFailure);
|
||||
const logs1 = getMostRecentAuthLog(sortedEchoVulnServer.hostname);
|
||||
expect(logs1?.data).toBe(`${sortedEchoVulnServer.passwordHintData}; RMS Deviation:1.000`);
|
||||
|
||||
getAuthResult(sortedEchoVulnServer, "23579", 1);
|
||||
expect(failedAttemptResponse.result.code).toBe(ResponseCodeEnum.AuthFailure);
|
||||
const logs2 = getMostRecentAuthLog(sortedEchoVulnServer.hostname);
|
||||
expect(logs2?.data).toBe(`${sortedEchoVulnServer.passwordHintData}; RMS Deviation:2.490`);
|
||||
|
||||
getAuthResult(sortedEchoVulnServer, "12355", 1);
|
||||
expect(failedAttemptResponse.result.code).toBe(ResponseCodeEnum.AuthFailure);
|
||||
const logs3 = getMostRecentAuthLog(sortedEchoVulnServer.hostname);
|
||||
expect(logs3?.data).toBe(`${sortedEchoVulnServer.passwordHintData}; RMS Deviation:0.447`);
|
||||
|
||||
expect(getAuthResult(sortedEchoVulnServer, sortedEchoVulnServer.password, 1).result.code).toBe(
|
||||
ResponseCodeEnum.Success,
|
||||
);
|
||||
expect(sortedEchoVulnServer.hasAdminRights).toBe(true);
|
||||
});
|
||||
|
||||
test("kingOfTheHill server creates a valid password and hint", () => {
|
||||
const kingOfTheHillServer = serverFactory(getKingOfTheHillConfig, 60, 0, 0);
|
||||
const password = Number(kingOfTheHillServer.password);
|
||||
|
||||
Reference in New Issue
Block a user