From cf4232191ef40d113452cb3c8c7b1662b6edf40e Mon Sep 17 00:00:00 2001 From: Slava Bacherikov Date: Fri, 22 Jul 2016 17:49:43 +0300 Subject: [PATCH] Add support for Insyde bios codes --- scripts/decrypt_bios.ts | 32 ++++++++++++++++++++++++++++++++ spec/bios.spec.js | 11 +++++++++++ 2 files changed, 43 insertions(+) diff --git a/scripts/decrypt_bios.ts b/scripts/decrypt_bios.ts index ae126a9..c38df3d 100644 --- a/scripts/decrypt_bios.ts +++ b/scripts/decrypt_bios.ts @@ -161,6 +161,30 @@ function HPMiniSolver(serial: string): string[] { } } +/* Maybe need fixing for browsers where numbers is 32-bits */ +/* Some Acer, HP laptops. 8 digit */ +function InsydeSolver(serial: string): string[] { + const salt = "Iou|hj&Z"; + let password = ""; + let b = 0; + let a = 0; + let ord = (str: string) => str.charCodeAt(0); + for (let i = 0; i < 8; i++) { + b = ord(salt.charAt(i)) ^ ord(serial.charAt(i)); + a = b; + // a = (a * 0x66666667) >> 32; + a = (a * 0x66666667); + a = Math.floor(a / Math.pow(2, 32)); + a = (a >> 2) | (a & 0xC0); + if (a & 0x80000000) { + a++; + } + a *= 10; + password += (b - a).toString(); + } + return [password]; +} + export let Sony: BIOSDecoder = { model: BIOSModels.Sony, name: "Sony", @@ -190,6 +214,14 @@ export let HPMini: BIOSDecoder = { solve: HPMiniSolver }; +export let Insyde: BIOSDecoder = { + model: BIOSModels.Insyde, + name: "Insyde H2O", + examples: ["03133610"], + check: (s) => /^\d{8}$/i.test(s), + solve: InsydeSolver +}; + export let Decoders: BIOSDecoder[] = [ Sony, Samsung, HPMini ]; diff --git a/spec/bios.spec.js b/spec/bios.spec.js index 5769643..13d34bf 100644 --- a/spec/bios.spec.js +++ b/spec/bios.spec.js @@ -37,4 +37,15 @@ describe("Decryp BIOS", function() { expect(bios.HPMini.check("CNU12$4ABC")).toBe(false); expect(bios.HPMini.check("CNU12п4ABC")).toBe(false); }); + + it("Insyde key for 03133610 is 12891236", function() { + expect(bios.Insyde.solve("03133610")).toEqual(["12891236"]); + }); + + it("Insyde input validation", function() { + expect(bios.Insyde.check("12345678")).toBe(true); + expect(bios.Insyde.check("123456789")).toBe(false); + expect(bios.Insyde.check("1234o678")).toBe(false); + expect(bios.Insyde.check("12345678d")).toBe(false); + }); });