Add support for Samsung 44 hex keys

This commit is contained in:
Slava Bacherikov 2020-07-01 19:44:50 +03:00
parent bcb4f5d9c8
commit 4bd66069e3
4 changed files with 92 additions and 4 deletions

View file

@ -21,7 +21,7 @@ Latest released version available [here][bios-pw] and latest testing version (*s
* Insyde H20 (Acer, HP) — 8 decimal digits, 10 decimal digits or HP `i ` (lowercase and uppercase) prefixed 8 digits.
* Phoenix (generic) — 5 decimal digits
* Sony — 7 digit serial number
* Samsung — 12 hexadecimal digits
* Samsung — 12, 18 or 44 hexadecimal digits
## More info

View file

@ -8,7 +8,7 @@ import {
phoenixFsiLSolver, phoenixFsiPSolver, phoenixFsiSolver,
phoenixFsiSSolver, phoenixFsiXSolver, phoenixHPCompaqSolver, phoenixSolver
} from "./phoenix";
import { samsungSolver } from "./samsung";
import { samsung44HexSolver, samsungSolver } from "./samsung";
import { sonySolver } from "./sony";
import { sony4x4Solver } from "./sony_4x4";
import { Solver } from "./utils";
@ -20,6 +20,7 @@ export const solvers: Solver[] = [
acerInsyde10Solver,
sonySolver,
sony4x4Solver,
samsung44HexSolver,
samsungSolver,
hddOldSolver,
dellSolver,

View file

@ -1,4 +1,4 @@
import { samsungSolver } from "./samsung";
import { samsung44HexSolver, samsungSolver } from "./samsung";
describe("Test Samsung BIOS", () => {
it("Samsung key for 07088120410C0000 is 12345", () => {
@ -20,3 +20,34 @@ describe("Test Samsung BIOS", () => {
expect(samsungSolver("1AA9CD4638C01860000")).toEqual([]);
});
});
describe("Test Samsung 44 hex digit", () => {
it("Samsung 44 keys", () => {
expect(samsung44HexSolver("59F72F85239CC9DB6239DEDDC5C4CDB43A37D5533003")).toEqual(["justin"]);
expect(samsung44HexSolver("351EF13822577610E4ED863695BD6CB7B356A5227185")).toEqual(["Diegocoelho"]);
expect(samsung44HexSolver("D78EF5B5CA236F4869662339D9912C39B727D50BB285")).toEqual(["auroradvr23"]);
expect(samsung44HexSolver("DF6E02658349EC455407A5CD60666AC01B26C0465004")).toEqual(["20160530"]);
expect(samsung44HexSolver("7856AC492A91B6A343B267680D4CDC016C8906194004")).toEqual(["2016 714"]);
expect(samsung44HexSolver("0C2D3C17293624ABAC569559CACA5E8C97E5BCE5D206")).toEqual(["////#/eeeeee"]);
expect(samsung44HexSolver("F0AC97598FCB9BEB0E8C69478055833466C9E61BD102")).toEqual(["6793"]);
expect(samsung44HexSolver("22D8DBEF1B9A2D24AAC8663A58B1AC5AB6AD2D5AF105")).toEqual(["Kimmiecat3"]);
expect(samsung44HexSolver("0E45ED5D2EF8949498AF1A9C2763726091E4850D1105")).toEqual(["Car2096994"]);
expect(samsung44HexSolver("8DD4D28455C8CDD06C4372190E9B264D1927E6C9F107")).toEqual(["97925178294647"]);
expect(samsung44HexSolver("54574AAD6A8B1B9353F6FA66DCD2DA91B06DBD8E3204")).toEqual(["tokadmin"]);
expect(samsung44HexSolver("BF5EC2647227EDC493BDBBB8C4BD0DB53DE6BD533083")).toEqual(["jonzkho"]);
expect(samsung44HexSolver("DED9EA70EA68EB1D3CDDB32C05CCE6391807D59B8083")).toEqual(["sup0r73"]);
expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B382")).toEqual(["12345"]);
expect(samsung44HexSolver("525052DF4524459125E750FA97B7DCBDB98DA5EE7303")).toEqual(["wilson"]);
expect(samsung44HexSolver("8DD5CFD4ADBC740A9EEF381383EADE621C23CCA10302")).toEqual(["4328"]);
expect(samsung44HexSolver("AEF53EE53CD1B453CACE163989950D3A3696A1835306")).toEqual(["philthebrave"]);
expect(samsung44HexSolver("2D2FB35C18B2B4846F1F989846036E6CA968E4C87005")).toEqual(["2945670211"]);
// lowercase
expect(samsung44HexSolver("2d2fb35c18b2b4846f1f989846036e6ca968e4c87005")).toEqual(["2945670211"]);
});
it("Samsung 44 invalid keys", () => {
expect(samsung44HexSolver("2D2FB35C18B2B4846F1F989846036E6DA968E4C87005")).toEqual([]);
expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B38")).toEqual([]);
expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B3833")).toEqual([]);
expect(samsung44HexSolver("DF6E02658349EC455407A5CD60666AC01B26C046508A")).toEqual([]);
});
});

View file

@ -15,6 +15,14 @@ const rotationMatrix2 = [
3, 7, 6, 2, 1, 3, 7, 6, 5, 0, 1, 7
];
const rotationMatrix3: Uint8Array = Uint8Array.from([
3, 6, 3, 1, 6, 7, 7, 7, 2, 6, 4, 3, 4, 6, 1, 7, 2, 1, 7, 7,
5, 3, 3, 1, 2, 3, 1, 2, 1, 7, 4, 7, 6, 2, 4, 4, 1, 6, 1, 5,
6, 6, 7, 5, 7, 7, 4, 3, 1, 1, 1, 6, 3, 2, 7, 3, 7, 3, 7, 3,
5, 6, 4, 1, 1, 3, 6, 6, 1, 4, 3, 7, 6, 7, 5, 3, 6, 7, 6, 3,
1, 3, 5, 7, 5, 6, 2, 2, 7, 5, 7, 1, 2, 3, 2, 1, 6, 4, 5, 3
]);
function keyToAscii(intKeys: number[]): string | undefined {
let out = "";
@ -63,11 +71,48 @@ function samsungKeygen(serial: string): string[] {
const asciiPassword1 = keyToAscii(decryptHash(hash, key, rotationMatrix1));
const asciiPassword2 = keyToAscii(decryptHash(hash, key, rotationMatrix2));
// TODO: This might require polyfil
return [scanCodePassword, asciiPassword1, asciiPassword2].
filter((code) => code ? true : false) as string[];
}
function byte_rol(val: number, shift: number): number {
return ((val << shift) & 0xff) | (val >> (8 - shift));
}
function nonprintable(sym: number): boolean {
return sym >= 127 || sym < 32;
}
/* Samsung 44 HEX keys */
export function samsung44HexKeygen(serial: string): string | undefined {
if (serial.length !== 44) {
return undefined;
}
let hash = new Uint8Array(22);
let password = "";
for (let i = 21; i >= 0; i--) {
const low = parseInt(serial[i * 2], 16);
const high = parseInt(serial[i * 2 + 1], 16);
hash[21 - i] = (high << 4) | low;
}
const pwdLength = hash[0] >> 3;
if (pwdLength > 20) {
// length to big, probably other algorithm
return undefined;
}
const key = (hash[1] % 5) * 20;
for (let i = 0; i < pwdLength; i++) {
const shift = rotationMatrix3[key + i];
const sym = byte_rol(byte_rol(hash[i + 2], shift), 4);
if (nonprintable(sym)) {
return undefined;
}
password += String.fromCharCode(sym);
}
return password;
}
export let samsungSolver = makeSolver({
name: "samsung",
description: "Samsung",
@ -77,3 +122,14 @@ export let samsungSolver = makeSolver({
),
fun: samsungKeygen
});
export let samsung44HexSolver = makeSolver({
name: "samsung44Hex",
description: "Samsung 44 Hexdecimal",
examples: ["54574AAD6A8B1B9353F6FA66DCD2DA91B06DBD8E3204"],
inputValidator: (s) => /^[0-9ABCDEF]{44}$/i.test(s),
fun: (hash: string) => {
const pwd = samsung44HexKeygen(hash);
return (pwd) ? [pwd] : [];
}
});