├── ci ├── requirements.txt ├── travis_deploy.sh ├── spec-bundle.js └── deploy.py ├── assets └── images │ ├── favicon.ico │ ├── bios-pw-192.png │ ├── bios-pw-512.png │ ├── apple-touch-icon.png │ └── bios-pw-logo.svg ├── webpack.config.js ├── .gitignore ├── src ├── polyfills │ ├── performancePolyfill.spec.ts │ └── performancePolyfill.ts ├── keygen │ ├── sony.spec.ts │ ├── dell │ │ ├── types.ts │ │ ├── index.ts │ │ ├── latitude.ts │ │ └── encode.ts │ ├── hpami.spec.ts │ ├── index.spec.ts │ ├── hpmini.spec.ts │ ├── sony.ts │ ├── asus.spec.ts │ ├── sony_4x4.spec.ts │ ├── hpami.ts │ ├── phoenix.spec.ts │ ├── hpmini.ts │ ├── index.ts │ ├── cryptoUtils.spec.ts │ ├── utils.ts │ ├── samsung.spec.ts │ ├── fsi.spec.ts │ ├── insyde.spec.ts │ ├── asus.ts │ ├── samsung.ts │ ├── sony_4x4.ts │ ├── insyde.ts │ ├── phoenix.ts │ ├── fsi.ts │ ├── dell.spec.ts │ └── cryptoUtils.ts ├── googleAnalytics.ts └── ui.ts ├── typings └── globals │ └── index.d.ts ├── jasmine.json ├── tsconfig.json ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ ├── bug_report.md │ └── new_laptop.md └── workflows │ ├── build-test.yml │ └── deploy.yml ├── package.json ├── README.md ├── karma.conf.js ├── webpack.base.js ├── html └── index.html ├── .eslintrc.js └── LICENSE.txt /ci/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3==1.20.52 2 | -------------------------------------------------------------------------------- /assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bacher09/pwgen-for-bios/HEAD/assets/images/favicon.ico -------------------------------------------------------------------------------- /assets/images/bios-pw-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bacher09/pwgen-for-bios/HEAD/assets/images/bios-pw-192.png -------------------------------------------------------------------------------- /assets/images/bios-pw-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bacher09/pwgen-for-bios/HEAD/assets/images/bios-pw-512.png -------------------------------------------------------------------------------- /assets/images/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bacher09/pwgen-for-bios/HEAD/assets/images/apple-touch-icon.png -------------------------------------------------------------------------------- /ci/travis_deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -n "$CI" ]; then 5 | pip3 install --user boto3 6 | fi 7 | ./ci/deploy.py ./dist/ beta.bios-pw.org 8 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const { getWebpackConfig } = require('./webpack.base'); 2 | 3 | 4 | module.exports = getWebpackConfig(process.env.PRODUCTION, process.env.GOOGLE_ANALYTICS_TAG); 5 | -------------------------------------------------------------------------------- /ci/spec-bundle.js: -------------------------------------------------------------------------------- 1 | var testContext = require.context("../src", true, /\.spec\.ts$/); 2 | 3 | function requireAll(context) { 4 | return context.keys().map(context); 5 | } 6 | 7 | var modules = requireAll(testContext); 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw[po] 2 | *.py[co] 3 | *.bak 4 | .nyc_output/ 5 | upload/ 6 | build/ 7 | temp/ 8 | typings.json 9 | node_modules/ 10 | dist/ 11 | *.env 12 | coverage/ 13 | npm-debug.log 14 | test-dist/ 15 | coverage-dist/ 16 | venv/ 17 | work/ 18 | -------------------------------------------------------------------------------- /src/polyfills/performancePolyfill.spec.ts: -------------------------------------------------------------------------------- 1 | import { monotonicTime } from "./performancePolyfill"; 2 | 3 | describe("Check performance.now polyfill", () => { 4 | it("monotonicTime should return number", () => { 5 | expect(typeof monotonicTime()).toEqual("number"); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /typings/globals/index.d.ts: -------------------------------------------------------------------------------- 1 | declare const GOOGLE_ANALYTICS_TAG: string | undefined; 2 | 3 | interface Window { 4 | dataLayer: any[]; 5 | } 6 | 7 | interface Performance { 8 | webkitNow(): number; 9 | mozNow(): number; 10 | oNow(): number; 11 | msNow(): number; 12 | } 13 | -------------------------------------------------------------------------------- /jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "reporters": [{ 3 | "name": "jasmine-spec-reporter#SpecReporter", 4 | "options": { 5 | "displayStacktrace": "all" 6 | } 7 | }], 8 | "spec_dir": "src/keygen/", 9 | "spec_files": ["**/*.spec.ts"], 10 | "helpers": [ 11 | "../node_modules/esm", 12 | "../node_modules/ts-node/register/index.js" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/keygen/sony.spec.ts: -------------------------------------------------------------------------------- 1 | import { sonySolver } from "./sony"; 2 | 3 | describe("Sony BIOS", () => { 4 | it("Sony key for 1234567 is 9648669", () => { 5 | expect(sonySolver("1234567")).toEqual(["9648669"]); 6 | }); 7 | it("test invalid keys", () => { 8 | expect(sonySolver("123456789")).toEqual([]); 9 | expect(sonySolver("123")).toEqual([]); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/keygen/dell/types.ts: -------------------------------------------------------------------------------- 1 | 2 | export enum DellTag { 3 | Tag595B = "595B", 4 | TagD35B = "D35B", 5 | Tag2A7B = "2A7B", 6 | TagA95B = "A95B", 7 | Tag1D3B = "1D3B", 8 | Tag6FF1 = "6FF1", 9 | Tag1F66 = "1F66", 10 | Tag1F5A = "1F5A", 11 | TagBF97 = "BF97", 12 | TagE7A8 = "E7A8" 13 | } 14 | 15 | export const enum SuffixType { 16 | ServiceTag, 17 | HDD 18 | } 19 | -------------------------------------------------------------------------------- /src/keygen/hpami.spec.ts: -------------------------------------------------------------------------------- 1 | import { hpAMISolver } from "./hpami"; 2 | 3 | describe("HP AMI BIOS", () => { 4 | it("Check solver", () => { 5 | expect(hpAMISolver("A7AF422F")).toEqual(["49163252"]); 6 | expect(hpAMISolver("12345678")).toEqual(["2ae211b4"]); 7 | expect(hpAMISolver("48A02676")).toEqual(["27545092"]); 8 | expect(hpAMISolver("B60BD282")).toEqual(["489b5bf9"]); 9 | expect(hpAMISolver("757EDC82")).toEqual(["edfe2edd"]); 10 | expect(hpAMISolver("7d94422f")).toEqual(["e4eea2c4"]); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es6", 4 | "lib": ["dom", "es5"], 5 | "target": "es5", 6 | "moduleResolution": "node", 7 | "noImplicitAny": true, 8 | "noImplicitReturns": true, 9 | "downlevelIteration": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "strictNullChecks": true, 13 | "strict": true, 14 | "sourceMap": true, 15 | "rootDir": "src/", 16 | "outDir": "dist/", 17 | "typeRoots": ["./typings", "./node_modules/@types/"] 18 | }, 19 | "exclude": [ 20 | "node_modules" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /src/keygen/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { keygen, solvers } from "./"; 2 | 3 | describe("BIOS keygen", () => { 4 | it("Sony key for 1234567 is 9648669", () => { 5 | let keysList = keygen("1234567"); 6 | expect(keysList[0][1]).toEqual(["9648669"]); 7 | }); 8 | it("Solvers names should be unique", () => { 9 | let names: {[key: string]: boolean} = {}; 10 | solvers.forEach((solver) => { 11 | if (solver.biosName in names) { 12 | throw Error(`${solver.biosName} isn't unique name`); 13 | } else { 14 | names[solver.biosName] = true; 15 | } 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /src/polyfills/performancePolyfill.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/unbound-method */ 2 | 3 | function makeMonotonicTime(): () => number { 4 | if (typeof performance !== "undefined" && performance) { 5 | let nowFun = performance.now || 6 | performance.webkitNow || 7 | performance.mozNow || 8 | performance.oNow || 9 | performance.msNow; 10 | 11 | if (nowFun) { 12 | return nowFun.bind(performance); 13 | } else { 14 | return Date.now; 15 | } 16 | } else { 17 | return Date.now; 18 | } 19 | } 20 | 21 | export const monotonicTime = makeMonotonicTime(); 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | **Is your feature request related to a problem? Please describe.** 7 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 8 | 9 | **Describe the solution you'd like** 10 | A clear and concise description of what you want to happen. 11 | For UI requests, don't hesitate to post some draws. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /src/keygen/hpmini.spec.ts: -------------------------------------------------------------------------------- 1 | import { hpMiniSolver } from "./hpmini"; 2 | 3 | describe("Test HP Mini BIOS", () => { 4 | it("HPMini key for CNU1234ABC is e9l37fvcpe", () => { 5 | expect(hpMiniSolver("CNU1234ABC")).toEqual(["e9l37fvcpe"]); 6 | }); 7 | it("HPMini key for CNU1234567 is e9l37fvqgx", () => { 8 | expect(hpMiniSolver("CNU1234567")).toEqual(["e9l37fvqgx"]); 9 | }); 10 | 11 | it("HPMini key for CNU1234ABX is e9l37fvcp4 or e9l37fvcpr", () => { 12 | expect(hpMiniSolver("CNU1234ABX").sort()).toEqual(["e9l37fvcp4", "e9l37fvcpr"].sort()); 13 | }); 14 | 15 | it("test invalid keys", () => { 16 | expect(hpMiniSolver("CNU12345678")).toEqual([]); 17 | expect(hpMiniSolver("CNU1234")).toEqual([]); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /src/keygen/sony.ts: -------------------------------------------------------------------------------- 1 | import { makeSolver } from "./utils"; 2 | /* Return password for old sony laptops 3 | * password 7 digit number like 1234567 4 | */ 5 | function sonyKeygen(serial: string): string { 6 | const table = "0987654321876543210976543210982109876543109876543221098765436543210987"; 7 | let code: string = ""; 8 | for (let i = 0; i < serial.length; i++) { 9 | code += table.charAt(parseInt(serial.charAt(i), 10) + 10 * i); 10 | } 11 | return code; 12 | } 13 | 14 | export let sonySolver = makeSolver({ 15 | name: "sony", 16 | description: "Old Sony", 17 | examples: ["1234567"], 18 | inputValidator: (s) => /^\d{7}$/i.test(s), 19 | fun: (code: string) => { 20 | let res = sonyKeygen(code); 21 | return res ? [res] : []; 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report 4 | --- 5 | 6 | **NOTE**: *This is template for a bug report, not a request for a new unlock algorithm. If you want 7 | to request support for new unlock algorithm use another template. 8 | 9 | ### Please specify your environment 10 | 11 | * **OS**: Specify your OS 12 | * **Browser**: specify your browser here (including version, e.g. Firefox 77, Chrome 83) 13 | * **website domain**: does bug happens on main website ([bios-pw.org](https:///bios-pw.org/)) or 14 | beta version ([beta.bios-pw.org](https://beta.bios-pw.org/)) 15 | * **website version**: specify output for `https://website-domain/version-info.txt`. For example: 16 | https://bios-pw.org/version-info.txt 17 | 18 | ### Expected behavior 19 | 20 | ### Actual behavior 21 | 22 | ### Steps to reproduce the issue 23 | 24 | - Please be as specific as possible 25 | 26 | ### Additional information 27 | 28 | Attach additional information that could help to reproduce the bug (screenshot, browser console 29 | logs, etc). 30 | -------------------------------------------------------------------------------- /src/googleAnalytics.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-empty */ 2 | /* eslint-disable @typescript-eslint/no-empty-function */ 3 | /* eslint-disable no-empty-function */ 4 | /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ 5 | /* eslint-disable prefer-rest-params */ 6 | /** @type {function(...*):void} */ 7 | export let gtag: (...args: any[]) => void = () => {}; 8 | 9 | if (GOOGLE_ANALYTICS_TAG) { 10 | let gaElem = document.createElement("script"); 11 | gaElem.async = true; 12 | let tag = GOOGLE_ANALYTICS_TAG; 13 | gaElem.src = `https://www.googletagmanager.com/gtag/js?id=${tag}`; 14 | let firstScript = document.getElementsByTagName("script")[0] as HTMLScriptElement; 15 | (firstScript.parentNode as HTMLElement).insertBefore(gaElem, firstScript); 16 | 17 | window.dataLayer = window.dataLayer || []; 18 | gtag = function() { window.dataLayer.push(arguments); }; 19 | gtag("js", new Date()); 20 | gtag("config", GOOGLE_ANALYTICS_TAG, { 21 | "custom_map": {"dimension1": "siteVersion"}, 22 | "transport_type": "beacon" 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | paths-ignore: 7 | - '**.md' 8 | pull_request: 9 | paths-ignore: 10 | - '**.md' 11 | 12 | 13 | jobs: 14 | build: 15 | name: Build and test 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Setup node 18 20 | uses: actions/setup-node@v2 21 | with: 22 | node-version: '18' 23 | cache: npm 24 | - name: Node checks 25 | run: | 26 | npm ci 27 | npm test 28 | npm run lint 29 | 30 | - name: Install browsers 31 | env: 32 | DEBIAN_FRONTEND: noninteractive 33 | TZ: Etc/UTC 34 | run: | 35 | sudo apt-get update -q -y 36 | sudo apt-get install -q -y chromium-chromedriver 37 | 38 | - name: Run browser tests 39 | run: npm run browser-test 40 | - name: Coveralls 41 | uses: coverallsapp/github-action@master 42 | with: 43 | github-token: ${{ secrets.GITHUB_TOKEN }} 44 | -------------------------------------------------------------------------------- /src/keygen/asus.spec.ts: -------------------------------------------------------------------------------- 1 | import { asusKeygen, asusSolver } from "./asus"; 2 | 3 | // https://pastebin.com/L3c3rySj 4 | 5 | describe("Test Asus keygen", () => { 6 | it("Asus password for 2007-02-01 is AA19BALA", () => { 7 | expect(asusKeygen(2007, 2, 1)).toEqual("AA19BALA"); 8 | }); 9 | 10 | it("Asus password for 2017-10-12 is AABABLAL", () => { 11 | expect(asusKeygen(2017, 10, 12)).toEqual("AABABLAL"); 12 | }); 13 | 14 | it("Asus password for 2020-09-15 is LBD9DBA1", () => { 15 | expect(asusKeygen(2020, 9, 15)).toEqual("LBD9DBA1"); 16 | }); 17 | 18 | it("Asus password for 2012-03-29 is AOBOBL2B", () => { 19 | expect(asusKeygen(2012, 3, 29)).toEqual("AOBOBL2B"); 20 | }); 21 | 22 | it("Asus password for 2002-01-02 is ALAA4ABA", () => { 23 | expect(asusKeygen(2002, 1, 2)).toEqual("ALAA4ABA"); 24 | }); 25 | }); 26 | 27 | describe("Test Asus solver", () => { 28 | it("Asus password for 2007-02-01 is AA19BALA", () => { 29 | expect(asusSolver("2007-02-01")).toEqual(["AA19BALA"]); 30 | }); 31 | 32 | it("Asus password for 01-02-2007 is AA19BALA (dmy format)", () => { 33 | expect(asusSolver("01-02-2007")).toEqual(["AA19BALA"]); 34 | }); 35 | 36 | it("Asus password for 01022007 is AA19BALA (dmy format)", () => { 37 | expect(asusSolver("01022007")).toEqual(["AA19BALA"]); 38 | }); 39 | 40 | it("41022007 is bad date", () => { 41 | expect(asusSolver("41022007")).toEqual([]); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /src/keygen/sony_4x4.spec.ts: -------------------------------------------------------------------------------- 1 | import JSBI from "jsbi"; 2 | import { modularPow, sony4x4Keygen, sony4x4Solver } from "./sony_4x4"; 3 | 4 | describe("Sony 4x4 BIOS Keygen", () => { 5 | it("Sony 4x4 key for 73KR3FP9PVKHK29R is 32799624", () => { 6 | expect(sony4x4Keygen("73KR3FP9PVKHK29R")).toEqual("32799624"); 7 | }); 8 | it("Sony 4x4 key for 73KR-3FP9-PVKH-K299 is 69423778", () => { 9 | expect(sony4x4Keygen("73KR3FP9PVKHK299")).toEqual("69423778"); 10 | }); 11 | it("Sony 4x4 key for 9DPK-73KR-8JHX-F3RT is 54746568", () => { 12 | expect(sony4x4Keygen("9DPK73KR8JHXF3RT")).toEqual("54746568"); 13 | }); 14 | it("Sony 4x4 key for 3RT6-8JV2-6HX8-K7FX is 32969527", () => { 15 | expect(sony4x4Keygen("3RT68JV26HX8K7FX")).toEqual("32969527"); 16 | }); 17 | it("Sony 4x4 key for K29R-PVKH-3FP9-73KR is 65395983", () => { 18 | expect(sony4x4Keygen("K29RPVKH3FP973KR")).toEqual("65395983"); 19 | }); 20 | }); 21 | 22 | describe("Sony 4x4 BIOS Solver", () => { 23 | it("Sony 4x4 key for 73KR-3FP9-PVKH-K29R is 32799624", () => { 24 | expect(sony4x4Solver("73KR-3FP9-PVKH-K29R")).toEqual(["32799624"]); 25 | }); 26 | it("Sony 4x4 invalid key 73KR-3FP9-PVKH-K29C", () => { 27 | expect(sony4x4Solver("73KR-3FP9-PVKH-K29C")).toEqual([]); 28 | }); 29 | }); 30 | 31 | describe("test modularPow", () => { 32 | it("4 ^ 13 mod 497 == 445", () => { 33 | expect(modularPow(JSBI.BigInt(4), 13, 497)).toEqual(445); 34 | }); 35 | it("100500 ^ 100500 mod 14 == 8", () => { 36 | expect(modularPow(JSBI.BigInt(100500), 100500, 14)).toEqual(8); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /src/keygen/hpami.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | import { Crc32 } from "./cryptoUtils"; 3 | import { makeSolver } from "./utils"; 4 | 5 | function hpAmiKeygen(input: string): string | undefined { 6 | if (input.length !== 8) { 7 | return undefined; 8 | } 9 | 10 | const salt = Uint8Array.from([ 11 | 0xb9, 0xed, 0xf5, 0x69, 0x9d, 0x16, 0x49, 0xf9, 12 | 0x8c, 0x5f, 0x7c, 0xb3, 0x68, 0x3c, 0xd4, 0xa7 13 | ]); 14 | 15 | const backdoor = parseInt(input, 16); 16 | let temp = new Uint8Array(20); 17 | let crc = new Crc32(); 18 | for (let i = 0; i < 0x10; i++) { 19 | temp[i] = salt[i] ^ 0x36; 20 | } 21 | // pack value in little-endian format 22 | temp[0x10] = backdoor & 0xFF; 23 | temp[0x11] = (backdoor >>> 8) & 0xFF; 24 | temp[0x12] = (backdoor >>> 16) & 0xFF; 25 | temp[0x13] = (backdoor >>> 24) & 0xFF; 26 | crc.update(temp); 27 | const next = crc.digest(); 28 | 29 | for (let i = 0; i < 0x10; i++) { 30 | temp[i] = salt[i] ^ 0x5C; 31 | } 32 | // pack value in little-endian format 33 | temp[0x10] = next & 0xFF; 34 | temp[0x11] = (next >>> 8) & 0xFF; 35 | temp[0x12] = (next >>> 16) & 0xFF; 36 | temp[0x13] = (next >>> 24) & 0xFF; 37 | crc.reset(); 38 | crc.update(temp); 39 | return crc.hexdigest(); 40 | } 41 | 42 | export let hpAMISolver = makeSolver({ 43 | name: "hpAMI", 44 | description: "HP AMI", 45 | examples: ["A7AF422F"], 46 | inputValidator: (s) => /^[0-9ABCDEF]{8}$/i.test(s), 47 | fun: (input: string) => { 48 | const output = hpAmiKeygen(input); 49 | return (output) ? [output] : []; 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /src/keygen/phoenix.spec.ts: -------------------------------------------------------------------------------- 1 | import * as bios from "./phoenix"; 2 | 3 | describe("Test Phoenix BIOS", () => { 4 | it("check correct passwords", () => { 5 | expect(bios.phoenixSolver.calculateHash("abstoou")).toEqual(12345); 6 | expect(bios.phoenixHPCompaqSolver.calculateHash("vnflm")).toEqual(12345); 7 | expect(bios.phoenixFsiSolver.calculateHash("411113")).toEqual(12345); 8 | expect(bios.phoenixFsiLSolver.calculateHash("362153")).toEqual(12345); 9 | expect(bios.phoenixFsiPSolver.calculateHash("4465237")).toEqual(12345); 10 | expect(bios.phoenixFsiSSolver.calculateHash("71669")).toEqual(12345); 11 | expect(bios.phoenixFsiXSolver.calculateHash("739979")).toEqual(12345); 12 | }); 13 | 14 | it("find password for hash 12345", () => { 15 | function phoenixValidate(solver: bios.PhoenixSolver, hash: string): number { 16 | let newPassword = solver(hash)[0]; 17 | expect(newPassword).not.toBeUndefined(); 18 | return solver.calculateHash(newPassword); 19 | } 20 | 21 | expect(phoenixValidate(bios.phoenixSolver, "12345")).toEqual(12345); 22 | expect(phoenixValidate(bios.phoenixHPCompaqSolver, "12345")).toEqual(12345); 23 | expect(phoenixValidate(bios.phoenixFsiSolver, "12345")).toEqual(12345); 24 | expect(phoenixValidate(bios.phoenixFsiLSolver, "12345")).toEqual(12345); 25 | expect(phoenixValidate(bios.phoenixFsiPSolver, "12345")).toEqual(12345); 26 | expect(phoenixValidate(bios.phoenixFsiSSolver, "12345")).toEqual(12345); 27 | expect(phoenixValidate(bios.phoenixFsiXSolver, "12345")).toEqual(12345); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: 4 | workflow_dispatch: 5 | workflow_run: 6 | workflows: ["Tests"] 7 | branches: [main] 8 | types: [completed] 9 | 10 | 11 | jobs: 12 | staging-deploy: 13 | name: Deploy to beta.bios-pw.org 14 | if: ${{ github.event.workflow_run.conclusion == 'success' }} || ${{ github.event.workflow_dispatch.sender.site_admin == true }} 15 | runs-on: ubuntu-latest 16 | concurrency: beta 17 | environment: 18 | name: beta 19 | url: https://beta.bios-pw.org/ 20 | 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v2 24 | 25 | - name: Install python 26 | uses: actions/setup-python@v2 27 | with: 28 | python-version: '3.9' 29 | cache: 'pip' 30 | cache-dependency-path: ./ci/requirements.txt 31 | 32 | - name: Install boto3 33 | run: pip install -r ./ci/requirements.txt 34 | 35 | - name: Setup node 18 36 | uses: actions/setup-node@v2 37 | with: 38 | node-version: '18' 39 | cache: npm 40 | 41 | - name: Build scripts and assets 42 | run: | 43 | npm ci 44 | npm run build-stage 45 | 46 | - name: Configure AWS Credentials 47 | uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3 48 | with: 49 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 50 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 51 | aws-region: ${{ secrets.AWS_DEFAULT_REGION }} 52 | 53 | - name: Upload assets to S3 54 | run: ./ci/deploy.py ./dist/ beta.bios-pw.org 55 | -------------------------------------------------------------------------------- /src/keygen/hpmini.ts: -------------------------------------------------------------------------------- 1 | /* For HP/Compaq Netbooks. 10 chars */ 2 | import { makeSolver } from "./utils"; 3 | 4 | const table1: {[key: string]: string} = { 5 | "1": "3", "0": "1", "3": "F", "2": "7", "5": "Q", "4": "V", 6 | "7": "X", "6": "G", "9": "O", "8": "U", "a": "C", "c": "E", 7 | "b": "P", "e": "M", "d": "T", "g": "H", "f": "8", "i": "Y", 8 | "h": "Z", "k": "S", "j": "W", "m": "4", "l": "K", "o": "J", 9 | "n": "9", "q": "5", "p": "2", "s": "N", "r": "B", "u": "L", 10 | "t": "A", "w": "D", "v": "6", "y": "I", "x": "4", "z": "0" 11 | }; 12 | 13 | const table2: {[key: string]: string} = { 14 | "1": "3", "0": "1", "3": "F", "2": "7", "5": "Q", "4": "V", 15 | "7": "X", "6": "G", "9": "O", "8": "U", "a": "C", "c": "E", 16 | "b": "P", "e": "M", "d": "T", "g": "H", "f": "8", "i": "Y", 17 | "h": "Z", "k": "S", "j": "W", "m": "4", "l": "K", "o": "J", 18 | "n": "9", "q": "5", "p": "2", "s": "N", "r": "B", "u": "L", 19 | "t": "A", "w": "D", "v": "6", "y": "I", "x": "R", "z": "0" 20 | }; 21 | 22 | function hpMiniKeygen(serial: string): string[] { 23 | 24 | let password1 = ""; 25 | let password2 = ""; 26 | serial = serial.toLowerCase(); 27 | for (let i = 0; i < serial.length; i++) { 28 | password1 += table1[serial.charAt(i)]; 29 | password2 += table2[serial.charAt(i)]; 30 | } 31 | if (password1 === password2) { 32 | return [password1.toLowerCase()]; 33 | } else { 34 | return [password1.toLowerCase(), password2.toLowerCase()]; 35 | } 36 | } 37 | 38 | export let hpMiniSolver = makeSolver({ 39 | name: "hpMini", 40 | description: "HP/Compaq Mini Netbooks", 41 | examples: ["CNU1234ABC"], 42 | inputValidator: (s) => /^[0-9A-Z]{10}$/i.test(s), 43 | fun: hpMiniKeygen 44 | }); 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new_laptop.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Request new codes 3 | about: Generated codes didn't worked or there was no codes at all 4 | title: "[VENDOR]: [MODEL] [algorithm info (e.g. vendor suffix, code size)]" 5 | labels: code 6 | --- 7 | 8 | **NOTE**: *You should select this option if you are going to request support for new unlock 9 | algorithm or existing one didn't worked for you*. 10 | 11 | **IMPORTANT**: before creating a new issue first check if there is any existing one with same model 12 | or algorithm request, in that case you'd better add information to that particular issue (your 13 | laptop model, BIOS version, screen photo, etc). 14 | 15 | Please replace `[VENDOR]` in a title with your laptop vendor (e.g. dell, hp, acer) and `[MODEL]` 16 | with model, also you can specify extra information in `[algorithm info]` if you can, otherwise just 17 | remove it from a title. 18 | 19 | Please specify following information: 20 | 21 | ### General information 22 | 23 | * **Vendor**: specify here your laptop manufacturer (e.g. dell, hp, acer, etc.) 24 | * **Model**: your laptop model (please be as specific as possible) 25 | * **Firmware version**: version of your BIOS firmware, it also good if you can specify firmware 26 | release date. 27 | 28 | ### Photo 29 | 30 | It also would be helpful if you post a photo of your locked screen (with generated code, `system 31 | disabled` message) for example like [here][photo-sample]. You can skip this if there are multiple 32 | images with exact same message. 33 | 34 | 35 | **Don't expect on immediate response**, your issue might help someone other who would face such 36 | issue in a feature but not necessarily you. I'd suggest you to contact your vendor support, cause 37 | this should be much faster channel. 38 | 39 | [photo-sample]: https://github.com/bacher09/pwgen-for-bios/issues/108#issue-638364581 40 | -------------------------------------------------------------------------------- /src/keygen/index.ts: -------------------------------------------------------------------------------- 1 | import { monotonicTime } from "../polyfills/performancePolyfill"; 2 | import { asusSolver } from "./asus"; 3 | import { dellHddSolver, dellLatitude3540Solver, dellSolver, hddOldSolver } from "./dell"; 4 | import { fsi20DecNewSolver, fsi20DecOldSolver, fsi24DecSolver, fsiHexSolver, fsi24Hex203cSolver } from "./fsi"; 5 | import { hpAMISolver } from "./hpami"; 6 | import { hpMiniSolver } from "./hpmini"; 7 | import { acerInsyde10Solver, hpInsydeSolver, insydeSolver } from "./insyde"; 8 | import { 9 | phoenixFsiLSolver, phoenixFsiPSolver, phoenixFsiSolver, 10 | phoenixFsiSSolver, phoenixFsiXSolver, phoenixHPCompaqSolver, phoenixSolver 11 | } from "./phoenix"; 12 | import { samsung44HexSolver, samsungSolver } from "./samsung"; 13 | import { sonySolver } from "./sony"; 14 | import { sony4x4Solver } from "./sony_4x4"; 15 | import { Solver } from "./utils"; 16 | 17 | export type KeygenResult = [Solver, string[], number]; 18 | 19 | export const solvers: Solver[] = [ 20 | asusSolver, 21 | acerInsyde10Solver, 22 | sonySolver, 23 | sony4x4Solver, 24 | samsung44HexSolver, 25 | samsungSolver, 26 | hddOldSolver, 27 | dellSolver, 28 | dellHddSolver, 29 | dellLatitude3540Solver, 30 | fsiHexSolver, 31 | fsi20DecNewSolver, 32 | fsi20DecOldSolver, 33 | fsi24DecSolver, 34 | fsi24Hex203cSolver, 35 | hpMiniSolver, 36 | hpInsydeSolver, 37 | hpAMISolver, 38 | insydeSolver, 39 | phoenixSolver, 40 | phoenixHPCompaqSolver, 41 | phoenixFsiSolver, 42 | phoenixFsiLSolver, 43 | phoenixFsiPSolver, 44 | phoenixFsiSSolver, 45 | phoenixFsiXSolver 46 | ]; 47 | 48 | // NOTE: In future this function can change or even be removed 49 | export function keygen(serial: string): KeygenResult[] { 50 | return solvers 51 | .map((solver): KeygenResult => { 52 | let startTime = monotonicTime(); 53 | let passwords = solver(serial); 54 | let calcTime = monotonicTime() - startTime; 55 | return [solver, passwords, calcTime]; 56 | }).filter(([_, passwords]) => passwords !== undefined && passwords.length >= 1); 57 | } 58 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pwgen-for-bios", 3 | "version": "2.0.0", 4 | "description": "Password generator for BIOS", 5 | "main": "src/ui.ts", 6 | "browserslist": "> 0.25%, not dead", 7 | "dependencies": { 8 | "jsbi": "^4.3.0" 9 | }, 10 | "devDependencies": { 11 | "@babel/core": "^7.23.3", 12 | "@babel/preset-env": "^7.23.3", 13 | "@jsdevtools/coverage-istanbul-loader": "^3.0.5", 14 | "@types/jasmine": "^3.10.3", 15 | "@typescript-eslint/eslint-plugin": "^5.11.0", 16 | "@typescript-eslint/parser": "^5.11.0", 17 | "ajv": "^8.10.0", 18 | "babel-loader": "^9.1.3", 19 | "clean-webpack-plugin": "^4.0.0", 20 | "copy-webpack-plugin": "^10.2.4", 21 | "coveralls": "^3.1.1", 22 | "eslint": "^8.54.0", 23 | "eslint-plugin-jsdoc": "^46.9.0", 24 | "eslint-plugin-no-null": "^1.0.2", 25 | "eslint-plugin-prefer-arrow": "^1.2.3", 26 | "esm": "^3.2.25", 27 | "html-webpack-plugin": "^5.5.3", 28 | "jasmine": "^3.99.0", 29 | "jasmine-spec-reporter": "^7.0", 30 | "karma": "^6.4.2", 31 | "karma-chrome-launcher": "^3.2.0", 32 | "karma-coverage-istanbul-reporter": "^3.0.3", 33 | "karma-firefox-launcher": "^2.1.2", 34 | "karma-jasmine": "^5.1.0", 35 | "karma-sourcemap-loader": "^0.4.0", 36 | "karma-webpack": "^5.0.0", 37 | "terser-webpack-plugin": "^5.3.9", 38 | "ts-loader": "^9.5.1", 39 | "ts-node": "^10.9.1", 40 | "typescript": "^4.5.5", 41 | "webpack": "^5.89.0", 42 | "webpack-cli": "^5.1.4", 43 | "webpack-dev-server": "^4.15.1" 44 | }, 45 | "scripts": { 46 | "test": "node -r esm -r ts-node/register node_modules/.bin/jasmine --config=jasmine.json", 47 | "browser-test": "karma start", 48 | "lint": "eslint -c .eslintrc.js --ext .ts src/", 49 | "all": "npm test && npm run lint && npm run browser-test", 50 | "build-prod": "PRODUCTION=1 GOOGLE_ANALYTICS_TAG=UA-112154345-1 webpack", 51 | "build-stage": "PRODUCTION=1 GOOGLE_ANALYTICS_TAG=UA-112154345-2 webpack", 52 | "webpack": "webpack", 53 | "dev-server": "webpack-dev-server" 54 | }, 55 | "repository": { 56 | "type": "git", 57 | "url": "git+https://github.com/bacher09/pwgen-for-bios.git" 58 | }, 59 | "keywords": [ 60 | "bios", 61 | "keygen", 62 | "password" 63 | ], 64 | "author": "Slava Bacherikov", 65 | "license": "GPL-3.0", 66 | "bugs": { 67 | "url": "https://github.com/bacher09/pwgen-for-bios/issues" 68 | }, 69 | "homepage": "https://github.com/bacher09/pwgen-for-bios#readme" 70 | } 71 | -------------------------------------------------------------------------------- /assets/images/bios-pw-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 18 | image/svg+xml 19 | 21 | 22 | 23 | 24 | 25 | 27 | 36 | 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Password generator for BIOS 2 | ================================ 3 | [![github actions status][build-status]][tests] 4 | [![coverage here][coverage-status]][coverage] 5 | 6 | [![tested-browsers][sauce-matrix]][sauce-link] 7 | 8 | This project contains master password generators for various BIOS/UEFI firmware. 9 | For more info [read this][dogbert-post]. 10 | 11 | Latest released version available [here][bios-pw] and latest testing version (*synchronized with master branch*) [here][beta-bios-pw]. 12 | 13 | ## Supported BIOS types: 14 | 15 | * Asus — current BIOS date. For example: ``01-02-2013`` 16 | * Compaq — 5 decimal digits (*e.g*. ``12345``) 17 | * Dell — supports such series: ``595B``, ``D35B``, ``2A7B``, ``A95B``, ``1D3B``, ``6FF1``, ``1F66``, ``1F5A`` and ``BF97``, ``E7A8``. *e.g*: ``1234567-2A7B`` or ``1234567890A-D35B`` for HDD. 18 | * Dell Insyde BIOS (Latitude 3540) — *e.g.* ``5F3988D5E0ACE4BF-7QH8602`` (``7QH8602`` — service tag). 19 | * Fujitsu-Siemens — 5 decimal digits, 8 hexadecimal digits, 5x4 and 6x4 hexadecimal digits, 5x4 decimal digits 20 | * Hewlett-Packard — 5 decimal digits, 10 characters 21 | * Insyde H20 (Acer, HP) — 8 decimal digits, 10 decimal digits or HP `i ` (lowercase and uppercase) prefixed 8 digits. 22 | * Phoenix (generic) — 5 decimal digits 23 | * Sony — 7 digit serial number 24 | * HP (AMI BIOS) — 8 hexadecimal digits (A code) 25 | * Samsung — 12, 18 or 44 hexadecimal digits 26 | 27 | ## More info 28 | 29 | * http://dogber1.blogspot.com/2009/05/table-of-reverse-engineered-bios.html 30 | * https://web.archive.org/web/20180913211958/https://sites.google.com/site/hpglserv/Home/article 31 | 32 | ## Thanks 33 | 34 | * [asyncritius](https://github.com/A-syncritus) — for major contribution to dell generator 35 | * [dogbert](https://github.com/dogbert) — researched many generators present here 36 | * hpgl — for initial dell generator 37 | * [let-def](https://github.com/let-def) — for Acer Insyde 10 digit 38 | * [polloloco](https://github.com/polloloco) — for FSI 6x4 hex (`203c-d001`) 39 | 40 | [build-status]: https://github.com/bacher09/pwgen-for-bios/actions/workflows/build-test.yml/badge.svg 41 | [tests]: https://github.com/bacher09/pwgen-for-bios/actions/workflows/build-test.yml 42 | [coverage-status]: https://coveralls.io/repos/github/bacher09/pwgen-for-bios/badge.svg?branch=master 43 | [coverage]: https://coveralls.io/github/bacher09/pwgen-for-bios?branch=master 44 | [sauce-matrix]: https://saucelabs.com/browser-matrix/bacher09.svg 45 | [sauce-link]: https://saucelabs.com/u/bacher09 46 | [dogbert-post]: http://dogber1.blogspot.com/2009/05/table-of-reverse-engineered-bios.html 47 | [bios-pw]: https://bios-pw.org/ 48 | [beta-bios-pw]: https://beta.bios-pw.org/ 49 | -------------------------------------------------------------------------------- /src/ui.ts: -------------------------------------------------------------------------------- 1 | import { gtag } from "./googleAnalytics"; 2 | import { keygen, KeygenResult, solvers } from "./keygen"; 3 | 4 | let form = document.getElementById("form_id") as HTMLFormElement; 5 | let serialInput = document.getElementById("serial_id") as HTMLInputElement; 6 | let tryThis = document.getElementById("try_this") as HTMLElement; 7 | let dellNote = document.getElementById("dell_note") as HTMLElement; 8 | let answerElement = document.getElementById("answer") as HTMLDivElement; 9 | 10 | function renderResult(results: KeygenResult[]): void { 11 | let table = document.createElement("table"); 12 | table.classList.add("answer_table"); 13 | results.forEach(([solver, passwords, _]) => { 14 | let trElem = document.createElement("tr"); 15 | let tdNameElem = document.createElement("td"); 16 | tdNameElem.appendChild(document.createTextNode(solver.description)); 17 | trElem.appendChild(tdNameElem); 18 | let tdElem = document.createElement("td"); 19 | passwords.forEach((pwd, index) => { 20 | if (index > 0) { 21 | tdElem.appendChild(document.createElement("br")); 22 | } 23 | tdElem.appendChild(document.createTextNode(pwd)); 24 | }); 25 | trElem.appendChild(tdElem); 26 | table.appendChild(trElem); 27 | }); 28 | answerElement.appendChild(table); 29 | } 30 | 31 | function trackResult(serial: string): KeygenResult[] { 32 | let result = keygen(serial); 33 | if (GOOGLE_ANALYTICS_TAG) { 34 | let eventParams: {[key: string]: boolean} = {}; 35 | solvers.forEach((solver) => { 36 | eventParams[solver.biosName] = false; 37 | }); 38 | 39 | result.forEach(([solver, _, time]) => { 40 | eventParams[solver.biosName] = true; 41 | 42 | // send calculation timing report 43 | gtag("event", "timing_complete", { 44 | "name": "bios_keygen", 45 | "value": Math.round(time), 46 | "event_category": solver.biosName 47 | }); 48 | }); 49 | 50 | // send event about calculation 51 | gtag("event", "bios_keygen", eventParams); 52 | } 53 | return result; 54 | } 55 | 56 | form.addEventListener("submit", (event) => { 57 | if (event.preventDefault) { 58 | event.preventDefault(); 59 | } else { 60 | event.returnValue = false; 61 | } 62 | answerElement.innerHTML = ""; // remove old table 63 | let results = trackResult(serialInput.value); 64 | if (results.length > 0) { 65 | tryThis.style.display = ""; 66 | dellNote.style.display = ""; 67 | renderResult(results); 68 | } else { 69 | tryThis.style.display = "none"; 70 | dellNote.style.display = "none"; 71 | } 72 | }, true); 73 | -------------------------------------------------------------------------------- /src/keygen/cryptoUtils.spec.ts: -------------------------------------------------------------------------------- 1 | import { AES128, Crc32, Crc64, Sha256 } from "./cryptoUtils"; 2 | 3 | describe("Crypto utils", () => { 4 | it("sha256", () => { 5 | expect(new Sha256(Uint8Array.from([])).hexdigest()) 6 | .toEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); 7 | 8 | expect(new Sha256(Uint8Array.from([1])).hexdigest()) 9 | .toEqual("4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a"); 10 | 11 | expect(new Sha256(Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])).hexdigest()) 12 | .toEqual("c848e1013f9f04a9d63fa43ce7fd4af035152c7c669a4a404b67107cee5f2e4e"); 13 | 14 | expect(new Sha256(Uint8Array.from("test".split("").map((v) => v.charCodeAt(0)))).hexdigest()) 15 | .toEqual("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"); 16 | 17 | expect(new Sha256(Uint8Array.from("0".repeat(256).split("").map((v) => v.charCodeAt(0)))).hexdigest()) 18 | .toEqual("67f022195ee405142968ca1b53ae2513a8bab0404d70577785316fa95218e8ba"); 19 | 20 | expect(new Sha256(Uint8Array.from("0".repeat(56).split("").map((v) => v.charCodeAt(0)))).hexdigest()) 21 | .toEqual("bd03ac1428f0ea86f4b83a731ffc7967bb82866d8545322f888d2f6e857ffc18"); 22 | }); 23 | it("AES128", () => { 24 | const numbers = Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); 25 | const myaes = new AES128(numbers); 26 | expect(myaes.encryptBlock(numbers)) 27 | .toEqual(Uint8Array.from([52, 195, 59, 127, 20, 253, 83, 220, 234, 37, 224, 26, 2, 225, 103, 39])); 28 | 29 | expect(myaes.encryptBlock(Uint8Array.from("123456789abcdefg".split("").map((v) => v.charCodeAt(0))))) 30 | .toEqual(Uint8Array.from([111, 52, 225, 193, 98, 40, 19, 168, 122, 34, 93, 3, 146, 166, 202, 100])); 31 | }); 32 | it("Check crc32", () => { 33 | let crc = new Crc32(); 34 | crc.update("test".split("").map((v) => v.charCodeAt(0))); 35 | expect(crc.digest()).toEqual(3632233996); 36 | crc.update("123".split("").map((v) => v.charCodeAt(0))); 37 | expect(crc.digest()).toEqual(4032078523); // crc32 for "test123" 38 | expect(crc.hexdigest()).toEqual("f054a2bb"); 39 | crc.reset(); 40 | expect(crc.hexdigest()).toEqual("00000000"); 41 | }); 42 | it("crc64", () => { 43 | let mycrc = new Crc64(Crc64.ECMA_POLYNOMIAL); 44 | mycrc.update([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); 45 | expect(mycrc.hexdigest()).toEqual("335a089168033fbe"); 46 | mycrc.reset(); 47 | mycrc.update([0x80]); 48 | expect(mycrc.hexdigest()).toEqual("c96c5795d7870f42"); 49 | mycrc.reset(); 50 | mycrc.update(Uint8Array.from([0xde, 0xad, 0xbe, 0xef])); 51 | expect(mycrc.hexdigest()).toEqual("fc232c18806871af"); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = function(config) { 4 | 5 | var customLaunchers = { 6 | ChromeHeadlessTravis: { 7 | base: "ChromeHeadless", 8 | flags: ['--no-sandbox'] 9 | } 10 | }; 11 | 12 | var configuration = { 13 | frameworks: ["jasmine"], 14 | files: [ 15 | {pattern: './ci/spec-bundle.js', watched: false} 16 | ], 17 | preprocessors: { 18 | './ci/spec-bundle.js': ['webpack'], 19 | }, 20 | webpackMiddleware: { 21 | scripts: 'errors-only' 22 | }, 23 | webpack: { 24 | devtool: "inline-source-map", 25 | mode: "development", 26 | resolve: { 27 | extensions: ['.ts', '.js', '.mjs'], 28 | }, 29 | module: { 30 | rules: [ 31 | { 32 | test: /\.ts$/, 33 | exclude: /node_modules/, 34 | use: [ 35 | "@jsdevtools/coverage-istanbul-loader", 36 | {loader: 'ts-loader', options: {transpileOnly: true}} 37 | ] 38 | }, 39 | { 40 | test: /\.m?js$/, 41 | exclude: /node_modules/, 42 | use: [{loader: 'babel-loader', options: {presets: ['@babel/preset-env']}}] 43 | } 44 | ] 45 | }, 46 | }, 47 | mime: { 48 | 'text/x-typescript': ['ts', 'tsx'] 49 | }, 50 | reporters: ["progress", "coverage-istanbul"], 51 | coverageIstanbulReporter: { 52 | reports: ['text', 'text-summary', "lcovonly"], 53 | dir: path.join(__dirname, "coverage"), 54 | combineBrowserReports: true, 55 | fixWebpackSourcePaths: true, 56 | }, 57 | browsers: ["ChromeHeadless", "FirefoxHeadless"], 58 | customLaunchers: customLaunchers, 59 | singleRun: true, 60 | concurrency: 2, 61 | plugins: [ 62 | 'karma-jasmine', 63 | 'karma-chrome-launcher', 64 | 'karma-firefox-launcher', 65 | 'karma-webpack', 66 | 'karma-coverage-istanbul-reporter' 67 | ] 68 | }; 69 | 70 | if (process.env.TRAVIS) { 71 | configuration.browsers = ['ChromeHeadlessTravis', 'FirefoxHeadless']; 72 | } 73 | 74 | if (process.env.SAUCE && process.env.SAUCE_USERNAME) { 75 | var currentBrowsers = configuration.browsers; 76 | var sauceBrowsers = Object.keys(customLaunchers).filter((s) => s.startsWith('sl_')); 77 | configuration.browsers = currentBrowsers.concat(sauceBrowsers); 78 | 79 | if (process.env.TRAVIS) { 80 | var buildNumber = process.env.TRAVIS_BUILD_NUMBER; 81 | var travisBuildId = process.env.TRAVIS_BUILD_ID; 82 | var buildId = `TRAVIS ${buildNumber} (${travisBuildId})`; 83 | configuration.sauceLabs.build = buildId; 84 | configuration.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; 85 | } 86 | } 87 | 88 | config.set(configuration); 89 | } 90 | -------------------------------------------------------------------------------- /ci/deploy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import re 3 | import os 4 | import boto3 5 | import mimetypes 6 | import argparse 7 | import time 8 | 9 | 10 | UPLOAD_ORDER = [ 11 | (re.compile(r'.*\.html$'), -1) 12 | ] 13 | 14 | CACHE_RULES = [ 15 | (re.compile(r'.*\.html$'), "public, max-age=120"), 16 | (re.compile(r'^version-info\.txt$'), "public, max-age=60"), 17 | (re.compile(r'.*\.(css|js)$'), "public, s-maxage=31536000, max-age=86400") 18 | ] 19 | 20 | DEFAULT_PRIORITY = 0 21 | REMOVE_TIMEOUT = 60 * 2 22 | 23 | 24 | def deployment_files(deploy_dir): 25 | for root, dirs, files in os.walk(deploy_dir): 26 | for filename in files: 27 | file_path = os.path.join(root, filename) 28 | yield os.path.relpath(file_path, start=deploy_dir) 29 | 30 | 31 | def sorted_files(deploy_dir): 32 | "Returns files in right order" 33 | files = list(deployment_files(deploy_dir)) 34 | match_rules = [] 35 | 36 | def sort_key(filename): 37 | for pattern, priority in UPLOAD_ORDER: 38 | if pattern.match(filename): 39 | return (priority, filename) 40 | 41 | return (DEFAULT_PRIORITY, filename) 42 | 43 | files.sort(key=sort_key, reverse=True) 44 | return files 45 | 46 | 47 | def file_options(file_name): 48 | mimetype, _ = mimetypes.guess_type(file_name) 49 | if mimetype is None: 50 | mimetype = 'application/octet-stream' 51 | 52 | extra_config = { 53 | 'ContentType': mimetype 54 | } 55 | 56 | for pattern, value in CACHE_RULES: 57 | if pattern.match(file_name): 58 | extra_config['CacheControl'] = value 59 | break 60 | 61 | return extra_config 62 | 63 | 64 | def remove_old(bucket, new_files): 65 | new_files_set = frozenset(new_files) 66 | removed_files = [] 67 | 68 | for s3_object in bucket.objects.all(): 69 | if s3_object.key not in new_files_set: 70 | removed_files.append(s3_object.key) 71 | print("Marked for remove: {}".format(s3_object.key)) 72 | 73 | # TODO: check errors 74 | bucket.delete_objects(Delete={ 75 | 'Objects': [{'Key': key} for key in removed_files], 76 | 'Quiet': True 77 | }) 78 | print("Objects removed") 79 | 80 | 81 | def update_site(deploy_dir, bucket_name, delete=False): 82 | s3 = boto3.resource('s3') 83 | bucket = s3.Bucket(bucket_name) 84 | updated_files = sorted_files(deploy_dir) 85 | 86 | for file_name in updated_files: 87 | file_path = os.path.join(deploy_dir, file_name) 88 | extra = file_options(file_name) 89 | print("Uploading: {}".format(file_name)) 90 | bucket.upload_file(file_path, file_name, extra) 91 | 92 | if delete: 93 | print("Wait for cache invalidation") # till cache become old 94 | time.sleep(REMOVE_TIMEOUT) 95 | remove_old(bucket, updated_files) 96 | 97 | 98 | if __name__ == '__main__': 99 | parser = argparse.ArgumentParser(description='Deploy site to s3') 100 | parser.add_argument('--delete', action='store_true', help="Remove old files") 101 | parser.add_argument("deploy_dir") 102 | parser.add_argument("s3_bucket") 103 | args = parser.parse_args() 104 | update_site(args.deploy_dir, args.s3_bucket, delete=args.delete) 105 | print("Done") 106 | -------------------------------------------------------------------------------- /src/keygen/utils.ts: -------------------------------------------------------------------------------- 1 | export type Predicate = (val: T) => boolean; 2 | export type SolverFunction = (val: string) => string[]; 3 | 4 | export interface SolverDescription { 5 | readonly name: string; 6 | readonly description?: string; 7 | readonly examples?: string[]; 8 | fun: SolverFunction; 9 | inputValidator: Predicate; 10 | cleaner?: (val: string) => string; 11 | } 12 | 13 | export interface Solver { 14 | (code: string): string[]; 15 | readonly biosName: string; 16 | readonly examples?: string[]; 17 | readonly description: string; 18 | validator(code: string): boolean; 19 | cleaner(code: string): string; 20 | keygen(code: string): string[]; 21 | } 22 | 23 | export const keyboardDict: {[key: number]: string} = { 24 | 2: "1", 3: "2", 4: "3", 5: "4", 6: "5", 7: "6", 8: "7", 9: "8", 25 | 10: "9", 11: "0", 16: "q", 17: "w", 18: "e", 19: "r", 20: "t", 21: "y", 26 | 22: "u", 23: "i", 24: "o", 25: "p", 30: "a", 31: "s", 32: "d", 33: "f", 27 | 34: "g", 35: "h", 36: "j", 37: "k", 38: "l", 44: "z", 45: "x", 46: "c", 28 | 47: "v", 48: "b", 49: "n", 50: "m" 29 | }; 30 | 31 | // reverse scan code table 32 | function generateReverseKeyDict(): {[key: string]: number} { 33 | let result: {[key: string]: number} = {}; 34 | for (let key in keyboardDict) { 35 | if (keyboardDict.hasOwnProperty(key)) { 36 | result[keyboardDict[key]] = parseInt(key, 10); 37 | } 38 | } 39 | return result; 40 | } 41 | 42 | export const reversedScanCodes = generateReverseKeyDict(); 43 | 44 | /* Decode Keyboard code to Ascii symbol */ 45 | export function keyboardEncToAscii(inKey: number[]): string { 46 | let out = ""; 47 | for (let key of inKey) { 48 | if (key === 0) { 49 | return out; 50 | } 51 | 52 | if (key in keyboardDict) { 53 | out += keyboardDict[key]; 54 | } else { 55 | return ""; 56 | } 57 | } 58 | return out; 59 | } 60 | 61 | export function asciiToKeyboardEnc(password: string): number[] { 62 | return password.split("").map((c) => { 63 | let code = reversedScanCodes[c]; 64 | if (code === void 0) { 65 | throw new Error("Undefined scan code"); 66 | } else { 67 | return code; 68 | } 69 | }); 70 | } 71 | 72 | function cleanSerial(serial: string): string { 73 | return serial.trim().replace(/-/gi, ""); 74 | } 75 | 76 | export function makeSolver(description: SolverDescription): Solver { 77 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ 78 | 79 | let solver: any = (code: string) => { 80 | let cleanCode = (solver as Solver).cleaner(code); 81 | if (description.inputValidator(cleanCode)) { 82 | return description.fun(cleanCode); 83 | } else { 84 | return []; 85 | } 86 | }; 87 | 88 | solver.biosName = description.name; 89 | solver.validator = description.inputValidator; 90 | 91 | if (description.cleaner) { 92 | solver.cleaner = description.cleaner; 93 | } else { 94 | solver.cleaner = cleanSerial; 95 | } 96 | 97 | solver.keygen = description.fun; 98 | 99 | if (description.examples) { 100 | solver.examples = description.examples; 101 | } 102 | 103 | if (description.description) { 104 | solver.description = description.description; 105 | } 106 | 107 | return solver as Solver; 108 | } 109 | -------------------------------------------------------------------------------- /src/keygen/samsung.spec.ts: -------------------------------------------------------------------------------- 1 | import { samsung44HexSolver, samsungSolver } from "./samsung"; 2 | 3 | describe("Test Samsung BIOS", () => { 4 | it("Samsung key for 07088120410C0000 is 12345", () => { 5 | expect(samsungSolver("07088120410C0000")).toEqual(["12345"]); 6 | }); 7 | it("Samsung key for 07088120410C is 12345", () => { 8 | expect(samsungSolver("07088120410C")).toEqual(["12345"]); 9 | }); 10 | 11 | it("Samsung key for 1AA9CD4638C0186000 is 5728000", () => { 12 | expect(samsungSolver("1AA9CD4638C0186000")).toEqual(["5728000"]); 13 | }); 14 | 15 | it("Samsung key for 1AA9CD4638C0186001 is 5728000@", () => { 16 | expect(samsungSolver("1AA9CD4638C0186001")).toEqual(["5728000@"]); 17 | }); 18 | it("test invalid keys", () => { 19 | expect(samsungSolver("1AA9CD4638C01860Z0")).toEqual([]); 20 | expect(samsungSolver("1AA9CD4638C01860000")).toEqual([]); 21 | }); 22 | }); 23 | 24 | describe("Test Samsung 44 hex digit", () => { 25 | it("Samsung 44 keys", () => { 26 | expect(samsung44HexSolver("59F72F85239CC9DB6239DEDDC5C4CDB43A37D5533003")).toEqual(["justin"]); 27 | expect(samsung44HexSolver("351EF13822577610E4ED863695BD6CB7B356A5227185")).toEqual(["Diegocoelho"]); 28 | expect(samsung44HexSolver("D78EF5B5CA236F4869662339D9912C39B727D50BB285")).toEqual(["auroradvr23"]); 29 | expect(samsung44HexSolver("DF6E02658349EC455407A5CD60666AC01B26C0465004")).toEqual(["20160530"]); 30 | expect(samsung44HexSolver("7856AC492A91B6A343B267680D4CDC016C8906194004")).toEqual(["2016 714"]); 31 | expect(samsung44HexSolver("0C2D3C17293624ABAC569559CACA5E8C97E5BCE5D206")).toEqual(["////#/eeeeee"]); 32 | expect(samsung44HexSolver("F0AC97598FCB9BEB0E8C69478055833466C9E61BD102")).toEqual(["6793"]); 33 | expect(samsung44HexSolver("22D8DBEF1B9A2D24AAC8663A58B1AC5AB6AD2D5AF105")).toEqual(["Kimmiecat3"]); 34 | expect(samsung44HexSolver("0E45ED5D2EF8949498AF1A9C2763726091E4850D1105")).toEqual(["Car2096994"]); 35 | expect(samsung44HexSolver("8DD4D28455C8CDD06C4372190E9B264D1927E6C9F107")).toEqual(["97925178294647"]); 36 | expect(samsung44HexSolver("54574AAD6A8B1B9353F6FA66DCD2DA91B06DBD8E3204")).toEqual(["tokadmin"]); 37 | expect(samsung44HexSolver("BF5EC2647227EDC493BDBBB8C4BD0DB53DE6BD533083")).toEqual(["jonzkho"]); 38 | expect(samsung44HexSolver("DED9EA70EA68EB1D3CDDB32C05CCE6391807D59B8083")).toEqual(["sup0r73"]); 39 | expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B382")).toEqual(["12345"]); 40 | expect(samsung44HexSolver("525052DF4524459125E750FA97B7DCBDB98DA5EE7303")).toEqual(["wilson"]); 41 | expect(samsung44HexSolver("8DD5CFD4ADBC740A9EEF381383EADE621C23CCA10302")).toEqual(["4328"]); 42 | expect(samsung44HexSolver("AEF53EE53CD1B453CACE163989950D3A3696A1835306")).toEqual(["philthebrave"]); 43 | expect(samsung44HexSolver("2D2FB35C18B2B4846F1F989846036E6CA968E4C87005")).toEqual(["2945670211"]); 44 | // lowercase 45 | expect(samsung44HexSolver("2d2fb35c18b2b4846f1f989846036e6ca968e4c87005")).toEqual(["2945670211"]); 46 | }); 47 | it("Samsung 44 invalid keys", () => { 48 | expect(samsung44HexSolver("2D2FB35C18B2B4846F1F989846036E6DA968E4C87005")).toEqual([]); 49 | expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B38")).toEqual([]); 50 | expect(samsung44HexSolver("B6C5525D15BCA963277178ED150EA3A968994698B3833")).toEqual([]); 51 | expect(samsung44HexSolver("DF6E02658349EC455407A5CD60666AC01B26C046508A")).toEqual([]); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /src/keygen/fsi.spec.ts: -------------------------------------------------------------------------------- 1 | import { fsi20DecNewSolver, fsi20DecOldSolver, fsi24DecSolver, fsi24Hex203cSolver, fsiHexSolver } from "./fsi"; 2 | 3 | describe("Test Fujitsu-Siemens 5x4 hexadecimal BIOS", () => { 4 | it("FSI key for 1234-4321-1234-4321-1234 is 35682708", () => { 5 | expect(fsiHexSolver("1234-4321-1234-4321-1234")).toEqual(["35683789"]); 6 | }); 7 | it("FSI key for AAAA-BBBB-CCCC-DEAD-BEEF is 64830592", () => { 8 | expect(fsiHexSolver("AAAA-BBBB-CCCC-DEAD-BEEF")).toEqual(["64830592"]); 9 | expect(fsiHexSolver("AAAABBBBCCCCDEADBEEF")).toEqual(["64830592"]); 10 | }); 11 | it("FSI key for DEADBEEF is 64830592", () => { 12 | expect(fsiHexSolver("DEADBEEF")).toEqual(["64830592"]); 13 | }); 14 | it("test invalid keys", () => { 15 | expect(fsiHexSolver("AAAA-BBBB-CCCC-DEAD-CODE")).toEqual([]); 16 | expect(fsiHexSolver("AAAA-BBBB-CCCC-DEAD-BEEF-12")).toEqual([]); 17 | }); 18 | }); 19 | 20 | describe("Test Fujitsu-Siemens 5x4 decimal new", () => { 21 | it("FSI key for 1234-4321-1234-4321-1234 is 7122790", () => { 22 | expect(fsi20DecNewSolver("1234-4321-1234-4321-1234")).toEqual(["7122790"]); 23 | }); 24 | 25 | it("FSI key for 7234-4321-1234-4321-1234 is 3122790", () => { 26 | expect(fsi20DecNewSolver("7234-4321-1234-4321-1234")).toEqual(["3122790"]); 27 | }); 28 | 29 | it("test invalid keys", () => { 30 | expect(fsi20DecNewSolver("1234-4321-1234-4321-1234-1")).toEqual([]); 31 | expect(fsi20DecNewSolver("1234-4321-1234-4321-BEEF")).toEqual([]); 32 | }); 33 | }); 34 | 35 | describe("Test Fujitsu-Siemens 5x4 decimal old", () => { 36 | it("FSI key for 1234-4321-1234-4321-1234 is 10cphf0b", () => { 37 | expect(fsi20DecOldSolver("1234-4321-1234-4321-1234")).toEqual(["10cphf0b"]); 38 | }); 39 | 40 | it("FSI key for 7234-4321-1234-4321-1234 is 10cphf0b", () => { 41 | expect(fsi20DecOldSolver("7234-4321-1234-4321-1234")).toEqual(["90ldhf0b"]); 42 | }); 43 | 44 | it("test invalid keys", () => { 45 | expect(fsi20DecOldSolver("1234-4321-1234-4321-1234-1")).toEqual([]); 46 | expect(fsi20DecOldSolver("1234-4321-1234-4321-BEEF")).toEqual([]); 47 | }); 48 | }); 49 | 50 | describe("Test Fujitsu-Siemens 6x4 decimal", () => { 51 | it("FSI key for 8F16-1234-4321-1234-4321-1234 is sjqtka8l", () => { 52 | expect(fsi24DecSolver("8F16-1234-4321-1234-4321-1234")).toEqual(["sjqtka8l"]); 53 | }); 54 | 55 | it("FSI key for 1234-7234-4321-1234-4321-1234 is smqtkaa5", () => { 56 | expect(fsi24DecSolver("1234-7234-4321-1234-4321-1234")).toEqual(["smqtkaa5"]); 57 | }); 58 | 59 | it("test invalid keys", () => { 60 | expect(fsi24DecSolver("1234-4321-1234-4321-1234-1")).toEqual([]); 61 | expect(fsi24DecSolver("1234-1234-4321-1234-4321-BEEF")).toEqual([]); 62 | expect(fsi24DecSolver("F234-4321-1234-4321-1234-1234-1")).toEqual([]); 63 | expect(fsi24DecSolver("1234-1234-4321-1234-4321-BEEF")).toEqual([]); 64 | }); 65 | }); 66 | 67 | describe("Test Fujitsu-Siemens 6x4 hex 203c-d001", () => { 68 | it("FSI key for 203c-d001-0000-001d-e960-227d is 494eab7c", () => { 69 | expect(fsi24Hex203cSolver("203c-d001-0000-001d-e960-227d")).toEqual(["494eab7c"]); 70 | }); 71 | it("FSI key for 203c-d001-4f30-609d-5125-646a is 66b14918", () => { 72 | expect(fsi24Hex203cSolver("203c-d001-4f30-609d-5125-646a")).toEqual(["66b14918"]); 73 | }); 74 | 75 | it("FSI key for 203C-D001-4F30-609D-5125-646a is 66b14918", () => { 76 | expect(fsi24Hex203cSolver("203C-D001-4F30-609D-5125-646a")).toEqual(["66b14918"]); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /src/keygen/insyde.spec.ts: -------------------------------------------------------------------------------- 1 | import { acerInsyde10Solver, hpInsydeSolver, insydeSolver } from "./insyde"; 2 | 3 | describe("Insyde BIOS", () => { 4 | it("Insyde key for 03133610 is 12891236", () => { 5 | expect(insydeSolver("03133610")[0]).toEqual("12891236"); 6 | }); 7 | it("Insyde key for 12345678 is 03023278", () => { 8 | expect(insydeSolver("12345678")[0]).toEqual("03023278"); 9 | }); 10 | 11 | it("Insyde key for 87654321 is 38732907", () => { 12 | expect(insydeSolver("87654321")[0]).toEqual("38732907"); 13 | }); 14 | 15 | it("Insyde key for 12345678 (all variants)", () => { 16 | expect(insydeSolver("12345678")).toEqual(["03023278", "16503512"]); 17 | expect(insydeSolver("03133610")).toEqual(["12891236", "24094120", "99534862"]); 18 | }); 19 | 20 | it("test invalid keys", () => { 21 | expect(insydeSolver("123456789")).toEqual([]); 22 | expect(insydeSolver("1234567")).toEqual([]); 23 | }); 24 | }); 25 | 26 | describe("Acer Insyde 10 BIOS", () => { 27 | it("Check Acer solver", () => { 28 | expect(acerInsyde10Solver("0173549286")).toEqual(["e0eac38fdfcfd74a"]); 29 | expect(acerInsyde10Solver("1014206418")).toEqual(["3c0a50907bc2c604"]); 30 | expect(acerInsyde10Solver("1765418418")).toEqual(["5f54e355b83e969c"]); 31 | expect(acerInsyde10Solver("1858408509")).toEqual(["c4791532114cfbab"]); 32 | expect(acerInsyde10Solver("1925715998")).toEqual(["f21cce78c0987233"]); 33 | expect(acerInsyde10Solver("2051611322")).toEqual(["1c648cb56e8a64bb"]); 34 | expect(acerInsyde10Solver("2036529205")).toEqual(["f2e874332b6f50b1"]); 35 | expect(acerInsyde10Solver("1768688657")).toEqual(["80774329818c3312"]); 36 | expect(acerInsyde10Solver("1746144265")).toEqual(["c3d46da5f6f3c75b"]); 37 | expect(acerInsyde10Solver("1611926546")).toEqual(["f61c86479a8a6b20"]); 38 | expect(acerInsyde10Solver("1355047683")).toEqual(["7fe913d78ffc5ed1"]); 39 | expect(acerInsyde10Solver("1373072054")).toEqual(["aebeae5c425684cd"]); 40 | expect(acerInsyde10Solver("1373899792")).toEqual(["a26970a4ffb62d49"]); 41 | expect(acerInsyde10Solver("1395185025")).toEqual(["a763280d9f7396ec"]); 42 | expect(acerInsyde10Solver("1205532638")).toEqual(["0f29abe2243b5a5e"]); 43 | expect(acerInsyde10Solver("1378359327")).toEqual(["0cb381199969833e"]); 44 | expect(acerInsyde10Solver("1880388286")).toEqual(["021df1cd9695387d"]); 45 | expect(acerInsyde10Solver("2025088185")).toEqual(["018261c3cbe60945"]); 46 | }); 47 | }); 48 | 49 | describe("HP Insyde [i \d{8}] codes", () => { 50 | it("Check HP Insyde solver", () => { 51 | expect(hpInsydeSolver("i 70412809")[0]).toEqual("47283646"); 52 | expect(hpInsydeSolver("i 76205377")[0]).toEqual("41898738"); 53 | expect(hpInsydeSolver("i 52669168")[0]).toEqual("65436527"); 54 | expect(hpInsydeSolver("i 58828448")[0]).toEqual("65477807"); 55 | // user can type more spaces or use wrong case for `I` 56 | expect(hpInsydeSolver("I 62996480")[0]).toEqual("55507825"); 57 | expect(hpInsydeSolver("i 51120876")[0]).toEqual("66775639"); 58 | expect(hpInsydeSolver("I 69779941")[0]).toEqual("54526704"); 59 | expect(hpInsydeSolver("i 75582785")[0]).toEqual("42313120"); 60 | expect(hpInsydeSolver("I 52214872")[0]).toEqual("65889633"); 61 | expect(hpInsydeSolver("i 77319488")[0]).toEqual("40986827"); 62 | expect(hpInsydeSolver("i 68852353")[0]).toEqual("55443712"); 63 | expect(hpInsydeSolver("i 59170869")[0]).toEqual("64725626"); 64 | expect(hpInsydeSolver("i 63121056")[0]).toEqual("54774419"); 65 | expect(hpInsydeSolver("i 68105474")[0]).toEqual("55798831"); 66 | expect(hpInsydeSolver("i 87267970")[0]).toEqual("10836735"); 67 | expect(hpInsydeSolver("i 93641394 ")[0]).toEqual("04454731"); 68 | // uppercase I codes 69 | expect(hpInsydeSolver("i 51974384")[1]).toEqual("44652900"); 70 | expect(hpInsydeSolver("I 51085312")[1]).toEqual("44983934"); 71 | expect(hpInsydeSolver("I 86013615")[1]).toEqual("39971231"); 72 | expect(hpInsydeSolver("I 59170869")[1]).toEqual("46858269"); 73 | // invalid input 74 | expect(hpInsydeSolver("51120876")).toEqual([]); 75 | expect(hpInsydeSolver("i 511")).toEqual([]); 76 | }); 77 | }); 78 | -------------------------------------------------------------------------------- /webpack.base.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { CleanWebpackPlugin } = require('clean-webpack-plugin'); 3 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 4 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 5 | const { DefinePlugin } = require('webpack'); 6 | const { exec } = require('child_process'); 7 | const Terser = require('terser-webpack-plugin'); 8 | const fs = require('fs'); 9 | 10 | 11 | class VersionInfoPlugin { 12 | constructor(options = {}) { 13 | if (options.filename == void 0) { 14 | throw new Error('[VersionInfoPlugin] filename should be set'); 15 | } 16 | this.options = options; 17 | } 18 | 19 | apply(compiler) { 20 | const plugin = { name: 'VersionInfoPlugin' } 21 | compiler.hooks.afterEmit.tapAsync(plugin, (compilation, callback) => { 22 | exec('git describe --tags --always', (error, stdout, stderr) => { 23 | if (error) { 24 | compilation.errors.push(error); 25 | callback(); 26 | return; 27 | } 28 | 29 | var version_info = `version: ${stdout.trim()}\ntime: ${new Date().toISOString()}\n`; 30 | if (process.env.TRAVIS) { 31 | version_info += `build id: TRAVIS ${process.env.TRAVIS_JOB_NUMBER} (${process.env.TRAVIS_BUILD_ID})\n`; 32 | } 33 | 34 | const filename = path.join(compiler.options.output.path, this.options.filename); 35 | 36 | fs.writeFile(filename, version_info, (err) => { 37 | if (err) { 38 | compilation.errors.push(err); 39 | } 40 | callback(); 41 | }) 42 | }); 43 | }); 44 | } 45 | } 46 | 47 | function getWebpackConfig(production, gtag) { 48 | var webpackMode; 49 | 50 | production = (typeof(production) === 'undefined') ? false : production; 51 | gtag = (typeof(gtag) === 'undefined') ? "" : gtag; 52 | 53 | var plugins = [ 54 | new CleanWebpackPlugin(), 55 | new CopyWebpackPlugin({ 56 | patterns: [ 57 | {from: 'assets/bootstrap.min.css', to: 'assets/'}, 58 | {from: 'assets/images/favicon.ico', to: 'favicon.ico'}, 59 | {from: 'assets/images/', to: 'assets/images/'}, 60 | ] 61 | }), 62 | new DefinePlugin({ 63 | GOOGLE_ANALYTICS_TAG: JSON.stringify(gtag) 64 | }), 65 | new HtmlWebpackPlugin({ 66 | minify: { 67 | collapseWhitespace: true, 68 | conservativeCollapse: true, 69 | removeComments: true, 70 | }, 71 | template: 'html/index.html', 72 | }), 73 | new VersionInfoPlugin({filename: 'version-info.txt'}) 74 | ]; 75 | 76 | if (production) { 77 | webpackMode = "production"; 78 | } else { 79 | webpackMode = "development"; 80 | } 81 | 82 | return { 83 | entry: "./src/ui.ts", 84 | output: { 85 | filename: "assets/bundle.[hash].js", 86 | path: path.join(__dirname, "dist") 87 | }, 88 | plugins: plugins, 89 | optimization: { 90 | concatenateModules: false, 91 | minimizer: [ 92 | new Terser({}) 93 | ] 94 | }, 95 | devtool: "source-map", 96 | devServer: { 97 | contentBase: path.join(__dirname, "dist"), 98 | port: 9000 99 | }, 100 | resolve: { 101 | extensions: ['.ts', '.tsx', '.js'] 102 | }, 103 | mode: webpackMode, 104 | module: { 105 | rules: [ 106 | { 107 | test: /\.ts$/, 108 | exclude: /node_modules/, 109 | use: [{loader: 'ts-loader', options: {transpileOnly: false}}] 110 | }, 111 | { 112 | test: /\.m?js$/, 113 | exclude: /node_modules/, 114 | use: [{loader: 'babel-loader', options: {presets: ['@babel/preset-env']}}] 115 | } 116 | ] 117 | } 118 | } 119 | } 120 | 121 | exports.getWebpackConfig = getWebpackConfig 122 | -------------------------------------------------------------------------------- /src/keygen/asus.ts: -------------------------------------------------------------------------------- 1 | // based on dogbert's pwgen-asus.py 2 | /* eslint-disable no-bitwise */ 3 | import { makeSolver } from "./utils"; 4 | 5 | /** @type {function(number=,number=,number=):Array} */ 6 | function initTable(a1: number = 11, a2: number = 19, a3: number = 6): number[] { 7 | let table: number[] = []; 8 | const zeroCode = "0".charCodeAt(0); 9 | table[0] = a1 + zeroCode; 10 | table[1] = a2 + zeroCode; 11 | table[2] = a3 + zeroCode; 12 | table[3] = "6".charCodeAt(0); 13 | table[4] = "7".charCodeAt(0); 14 | table[5] = "8".charCodeAt(0); 15 | table[6] = "9".charCodeAt(0); 16 | 17 | let chksum: number = table.reduce((acc, val) => acc + val, 0); 18 | for (let i = 7; i < 32; i++) { 19 | chksum = (33676 * chksum + 12345) >>> 0; 20 | table[i] = ((chksum >> 16) & 0x7FFF) % 43 + zeroCode; 21 | } 22 | 23 | let v3 = a1 * a2; 24 | let v4 = shuffle1((a1 - 1) * (a2 - 1), a3); 25 | 26 | return table.map((value) => shuffle2(value - zeroCode, v4, v3)); 27 | } 28 | 29 | function shuffle1(a1: number, a2: number): number { 30 | let v3 = 2; 31 | for (let i = 0; i < a2; i++) { 32 | let v4 = v3; 33 | let v5 = a1; 34 | while (v5 > 0) { 35 | if (v5 < v4) { 36 | [v5, v4] = [v4, v5]; 37 | } 38 | v5 %= v4; 39 | } 40 | if (v4 !== 1) { 41 | v3++; 42 | } 43 | } 44 | return v3; 45 | } 46 | 47 | function shuffle2(a1: number, a2: number, a3: number): number { 48 | if (a1 >= a3) { 49 | a1 %= a3; 50 | } 51 | let result = a1; 52 | if (a2 !== 1) { 53 | for (let i = 0; i < a2 - 1; i++) { 54 | result = a1 * result % a3; 55 | } 56 | } 57 | return result; 58 | } 59 | 60 | function leftPad(base: string, len: number, fill: string = " ") { 61 | const padding = len - base.length; 62 | for (let i = 0; i < padding; i++) { 63 | base = fill + base; 64 | } 65 | return base; 66 | } 67 | 68 | function makeDateRegexp(): [RegExp, RegExp] { 69 | let years: string[] = []; 70 | let months: string[] = []; 71 | let days: string[] = []; 72 | 73 | for (let year = 1990; year <= 2100; year++) { 74 | years.push(leftPad(year.toString(), 4, "0")); 75 | } 76 | 77 | for (let month = 1; month <= 12; month++) { 78 | months.push(leftPad(month.toString(), 2, "0")); 79 | } 80 | 81 | for (let day = 1; day <= 31; day++) { 82 | days.push(leftPad(day.toString(), 2, "0")); 83 | } 84 | let ymdre = new RegExp(`(${years.join("|")})(${months.join("|")})(${days.join("|")})`); 85 | let dmyre = new RegExp(`(${days.join("|")})(${months.join("|")})(${years.join("|")})`); 86 | return [ymdre, dmyre]; 87 | } 88 | 89 | const asusTable = initTable(); 90 | const [ymdRegex, dmyRegex] = makeDateRegexp(); 91 | 92 | export function asusKeygen(year: number, month: number, day: number): string { 93 | const date = leftPad(year.toString(), 4, "0") + 94 | leftPad(month.toString(), 2, "0") + 95 | leftPad(day.toString(), 2, "0"); 96 | 97 | let chksum = parseInt(date, 16); 98 | let password: string = ""; 99 | 100 | for (let i = 0; i < 8; i++) { 101 | chksum = (33676 * chksum + 12345) >>> 0; 102 | let index = (chksum >> 16) & 31; 103 | let pwdChar = asusTable[index] % 36; 104 | if (pwdChar > 9) { 105 | password += String.fromCharCode(pwdChar + "7".charCodeAt(0)); 106 | } else { 107 | password += String.fromCharCode(pwdChar + "0".charCodeAt(0)); 108 | } 109 | } 110 | 111 | return password; 112 | } 113 | 114 | export let asusSolver = makeSolver({ 115 | name: "asusDate", 116 | description: "ASUS (Using date)", 117 | examples: ["2010-02-03"], 118 | inputValidator: (s) => s.length === 8, 119 | fun: (code) => { 120 | let result: string[] = []; 121 | 122 | if (ymdRegex.test(code)) { 123 | let year = parseInt(code.slice(0, 4), 10); 124 | let month = parseInt(code.slice(4, 6), 10); 125 | let day = parseInt(code.slice(6, 8), 10); 126 | result.push(asusKeygen(year, month, day)); 127 | } 128 | 129 | if (dmyRegex.test(code)) { 130 | let day = parseInt(code.slice(0, 2), 10); 131 | let month = parseInt(code.slice(2, 4), 10); 132 | let year = parseInt(code.slice(4, 8), 10); 133 | result.push(asusKeygen(year, month, day)); 134 | } 135 | 136 | return result; 137 | } 138 | }); 139 | -------------------------------------------------------------------------------- /src/keygen/samsung.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | /* Return password for samsung laptops 3 | * 12 or 18 hexhecimal digits like 07088120410C0000 4 | */ 5 | 6 | import { makeSolver } from "./utils"; 7 | import { keyboardEncToAscii } from "./utils"; 8 | 9 | const rotationMatrix1 = [ 10 | 7, 1, 5, 3, 0, 6, 2, 5, 2, 3, 0, 6, 1, 7, 6, 1, 5, 2, 7, 1, 0, 3, 7, 11 | 6, 1, 0, 5, 2, 1, 5, 7, 3, 2, 0, 6 12 | ]; 13 | const rotationMatrix2 = [ 14 | 1, 6, 2, 5, 7, 3, 0, 7, 1, 6, 2, 5, 0, 3, 0, 6, 5, 1, 1, 7, 2, 5, 2, 15 | 3, 7, 6, 2, 1, 3, 7, 6, 5, 0, 1, 7 16 | ]; 17 | 18 | const rotationMatrix3: Uint8Array = Uint8Array.from([ 19 | 3, 6, 3, 1, 6, 7, 7, 7, 2, 6, 4, 3, 4, 6, 1, 7, 2, 1, 7, 7, 20 | 5, 3, 3, 1, 2, 3, 1, 2, 1, 7, 4, 7, 6, 2, 4, 4, 1, 6, 1, 5, 21 | 6, 6, 7, 5, 7, 7, 4, 3, 1, 1, 1, 6, 3, 2, 7, 3, 7, 3, 7, 3, 22 | 5, 6, 4, 1, 1, 3, 6, 6, 1, 4, 3, 7, 6, 7, 5, 3, 6, 7, 6, 3, 23 | 1, 3, 5, 7, 5, 6, 2, 2, 7, 5, 7, 1, 2, 3, 2, 1, 6, 4, 5, 3 24 | ]); 25 | 26 | function keyToAscii(intKeys: number[]): string | undefined { 27 | let out = ""; 28 | 29 | for (let intKey of intKeys) { 30 | if (intKey === 0) { 31 | return out; 32 | } 33 | if (intKey < 32 || intKey > 127) { 34 | return undefined; 35 | } 36 | out += String.fromCharCode(intKey); 37 | } 38 | 39 | return out; 40 | } 41 | 42 | function decryptHash(hash: number[], key: number, rotationMatrix: number[]): number[] { 43 | let outhash: number[] = []; 44 | 45 | for (let i = 0; i < hash.length; i++) { 46 | const val = ((hash[i] << (rotationMatrix[7 * key + i])) & 0xFF) | 47 | (hash[i] >> (8 - rotationMatrix[7 * key + i])); 48 | outhash.push(val); 49 | } 50 | 51 | return outhash; 52 | } 53 | 54 | function samsungKeygen(serial: string): string[] { 55 | let hash: number[] = []; 56 | 57 | for (let i = 1; i < Math.floor(serial.length / 2); i++) { 58 | let val = parseInt(serial.charAt(2 * i) + serial.charAt(2 * i + 1), 16); 59 | hash.push(val); 60 | } 61 | let key = parseInt(serial.substring(0, 2), 16) % 5; 62 | 63 | let calcScanCodePwd = (matrix: number[]) => 64 | keyboardEncToAscii(decryptHash(hash, key, matrix)); 65 | 66 | let scanCodePassword = calcScanCodePwd(rotationMatrix1); 67 | if (scanCodePassword === "") { 68 | scanCodePassword = calcScanCodePwd(rotationMatrix2); 69 | } 70 | 71 | const asciiPassword1 = keyToAscii(decryptHash(hash, key, rotationMatrix1)); 72 | const asciiPassword2 = keyToAscii(decryptHash(hash, key, rotationMatrix2)); 73 | 74 | return [scanCodePassword, asciiPassword1, asciiPassword2]. 75 | filter((code) => code ? true : false) as string[]; 76 | } 77 | 78 | function byteRol(val: number, shift: number): number { 79 | return ((val << shift) & 0xff) | (val >> (8 - shift)); 80 | } 81 | 82 | function nonprintable(sym: number): boolean { 83 | return sym >= 127 || sym < 32; 84 | } 85 | 86 | /* Samsung 44 HEX keys */ 87 | export function samsung44HexKeygen(serial: string): string | undefined { 88 | if (serial.length !== 44) { 89 | return undefined; 90 | } 91 | 92 | let hash = new Uint8Array(22); 93 | let password = ""; 94 | for (let i = 21; i >= 0; i--) { 95 | const low = parseInt(serial[i * 2], 16); 96 | const high = parseInt(serial[i * 2 + 1], 16); 97 | hash[21 - i] = (high << 4) | low; 98 | } 99 | const pwdLength = hash[0] >> 3; 100 | if (pwdLength > 20) { 101 | // length to big, probably other algorithm 102 | return undefined; 103 | } 104 | const key = (hash[1] % 5) * 20; 105 | for (let i = 0; i < pwdLength; i++) { 106 | const shift = rotationMatrix3[key + i]; 107 | const sym = byteRol(byteRol(hash[i + 2], shift), 4); 108 | if (nonprintable(sym)) { 109 | return undefined; 110 | } 111 | password += String.fromCharCode(sym); 112 | } 113 | return password; 114 | } 115 | 116 | export let samsungSolver = makeSolver({ 117 | name: "samsung", 118 | description: "Samsung", 119 | examples: ["07088120410C0000"], 120 | inputValidator: (s) => /^[0-9ABCDEF]+$/i.test(s) && ( 121 | s.length === 12 || s.length === 14 || s.length === 16 || s.length === 18 122 | ), 123 | fun: samsungKeygen 124 | }); 125 | 126 | export let samsung44HexSolver = makeSolver({ 127 | name: "samsung44Hex", 128 | description: "Samsung 44 Hexdecimal", 129 | examples: ["54574AAD6A8B1B9353F6FA66DCD2DA91B06DBD8E3204"], 130 | inputValidator: (s) => /^[0-9ABCDEF]{44}$/i.test(s), 131 | fun: (hash: string) => { 132 | const pwd = samsung44HexKeygen(hash); 133 | return (pwd) ? [pwd] : []; 134 | } 135 | }); 136 | -------------------------------------------------------------------------------- /src/keygen/sony_4x4.ts: -------------------------------------------------------------------------------- 1 | // based on dogbert's pwgen-sony-4x4.py 2 | /* eslint-disable no-bitwise */ 3 | import JSBI from "jsbi"; 4 | import { makeSolver } from "./utils"; 5 | 6 | const otpChars: string = "9DPK7V2F3RT6HX8J"; 7 | const pwdChars: string = "47592836"; 8 | const inputRe: RegExp = new RegExp(`^[${otpChars}]{16}\$`); 9 | 10 | function arrayToNumber(arr: number[]): number { 11 | // same as python struct.unpack(">> 0; 13 | } 14 | 15 | function numberToArray(num: number): number[] { 16 | return [num & 0xFF, (num >> 8) & 0xFF, (num >> 16) & 0xFF, (num >> 24) & 0xFF]; 17 | } 18 | 19 | function decodeHash(hash: string): number[] { 20 | let temp: number[] = []; 21 | for (let i = 0; i < hash.length; i += 2) { 22 | // TODO: check values 23 | temp.unshift(otpChars.indexOf(hash[i]) * 16 + otpChars.indexOf(hash[i + 1])); 24 | } 25 | return temp; 26 | } 27 | 28 | function encodePassword(pwd: number[]): string { 29 | let n: number = arrayToNumber(pwd); 30 | let result: string = ""; 31 | for (let i = 0; i < 8; i++) { 32 | result += pwdChars.charAt((n >> (21 - i * 3)) & 0x7); 33 | } 34 | return result; 35 | } 36 | 37 | // http://numericalrecipes.blogspot.com/2009/03/modular-multiplicative-inverse.html 38 | function extEuclideanAlg(a: JSBI, b: JSBI): [JSBI, JSBI, JSBI] { 39 | if (JSBI.EQ(b, 0)) { 40 | return [JSBI.BigInt(1), JSBI.BigInt(0), a]; 41 | } else { 42 | let [x, y, gcd] = extEuclideanAlg(b, JSBI.remainder(a, b)); 43 | return [y, JSBI.subtract(x, JSBI.multiply(y, JSBI.divide(a, b))), gcd]; 44 | } 45 | } 46 | 47 | function modInvEuclid(a: JSBI, m: JSBI): JSBI | undefined { 48 | let [x, , gcd] = extEuclideanAlg(a, m); 49 | if (JSBI.EQ(gcd, 1)) { 50 | // hack for javascript modulo operation 51 | // https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers 52 | const temp = JSBI.remainder(x, m); 53 | return JSBI.GE(temp, 0) ? temp : JSBI.ADD(temp, m) as JSBI; 54 | } else { 55 | return undefined; 56 | } 57 | } 58 | 59 | // https://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method 60 | export function modularPow(base: JSBI, exponent: number, modulus: number | JSBI): number { 61 | let result: JSBI = JSBI.BigInt(1); 62 | 63 | if (!(modulus instanceof JSBI)) { 64 | modulus = JSBI.BigInt(modulus); 65 | } 66 | 67 | if (JSBI.EQ(modulus, 1)) { 68 | return 0; 69 | } 70 | 71 | base = JSBI.remainder(base, modulus); 72 | 73 | while (exponent > 0) { 74 | if ((exponent & 1) === 1) { 75 | result = JSBI.remainder(JSBI.multiply(result, base), modulus); 76 | } 77 | exponent = exponent >> 1; 78 | base = JSBI.remainder(JSBI.multiply(base, base), modulus); 79 | } 80 | return JSBI.toNumber(result); 81 | } 82 | 83 | function rsaDecrypt(code: number[]): number[] { 84 | const low: JSBI = JSBI.BigInt(arrayToNumber(code.slice(0, 4))); 85 | const high: JSBI = JSBI.BigInt(arrayToNumber(code.slice(4, 8))); 86 | const c: JSBI = JSBI.bitwiseOr(JSBI.leftShift(high, JSBI.BigInt(32)), low); 87 | 88 | const p: number = 2795287379; 89 | const q: number = 3544934711; 90 | const e = 41; 91 | const phi: JSBI = JSBI.multiply(JSBI.BigInt(p - 1), JSBI.BigInt(q - 1)); 92 | const d: JSBI = modInvEuclid(JSBI.BigInt(e), phi) as JSBI; 93 | 94 | const dp: JSBI = JSBI.remainder(d, JSBI.BigInt(p - 1)); 95 | const dq: JSBI = JSBI.remainder(d, JSBI.BigInt(q - 1)); 96 | const qinv: JSBI = modInvEuclid(JSBI.BigInt(q), JSBI.BigInt(p)) as JSBI; 97 | 98 | const m1 = modularPow(c, JSBI.toNumber(dp), p); 99 | const m2 = modularPow(c, JSBI.toNumber(dq), q); 100 | let h: JSBI; 101 | 102 | if (m1 < m2) { 103 | h = JSBI.remainder(JSBI.multiply(JSBI.add(JSBI.BigInt(m1 - m2), JSBI.BigInt(p)), qinv), JSBI.BigInt(p)); 104 | } else { 105 | h = JSBI.remainder(JSBI.multiply(JSBI.BigInt(m1 - m2), qinv), JSBI.BigInt(p)); 106 | } 107 | const m: JSBI = JSBI.add(JSBI.multiply(h, JSBI.BigInt(q)), JSBI.BigInt(m2)); 108 | return numberToArray(JSBI.toNumber(JSBI.asUintN(32, m))).concat( 109 | numberToArray(JSBI.toNumber(JSBI.signedRightShift(m, JSBI.BigInt(32)))) 110 | ); 111 | } 112 | 113 | export function sony4x4Keygen(hash: string): string { 114 | const numHash = decodeHash(hash); 115 | const pwd = rsaDecrypt(numHash); 116 | return encodePassword(pwd); 117 | } 118 | 119 | export let sony4x4Solver = makeSolver({ 120 | name: "sony4x4", 121 | description: "Sony 4x4", 122 | examples: ["73KR-3FP9-PVKH-K29R"], 123 | cleaner: (input: string) => input.trim().replace(/[-\s]/gi, "").toUpperCase(), 124 | inputValidator: (s) => inputRe.test(s), 125 | fun: (code: string) => { 126 | let res = sony4x4Keygen(code); 127 | return res ? [res] : []; 128 | } 129 | }); 130 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | BIOS Master Password Generator for Laptops 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 |
18 |
19 |
20 | Clear unknown BIOS passwords 21 | 25 |
26 |
27 |
28 |
29 |
30 |

31 |

BIOS Password Recovery for Laptops

32 | Quick and easy way to recover BIOS passwords on laptops. Based on research by Dogbert and Asyncritus. 33 |
34 |
35 |
36 |

Enter your code


37 |
38 | 39 |

40 | 41 |
42 |
43 |
44 | 45 |
46 |

47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
VendorTypeHash Code/Serial example
Compaq5 decimal digits12345
Dellserial number1234567-595B
1234567-D35B
1234567-2A7B
1234567-1D3B
1234567-1F66
1234567-6FF1
1234567-1F5A
1234567-BF97
Fujitsu-Siemens5 decimal digits12345
Fujitsu-Siemens8 hexadecimal digitsDEADBEEF
Fujitsu-Siemens5x4 hexadecimal digitsAAAA-BBBB-CCCC-DEAD-BEEF
Fujitsu-Siemens5x4 decimal digits1234-4321-1234-4321-1234
Hewlett-Packard5 decimal digits12345
Hewlett-Packard/Compaq Netbooks10 charactersCNU1234ABC
Insyde H20 (generic)8 decimal digits03133610
Phoenix (generic)5 decimal digits12345
Sony7 digit serial number1234567
Samsung12 hexadecimal digits07088120410C0000
64 | 65 |
66 |
67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true 4 | }, 5 | "extends": [ 6 | "plugin:@typescript-eslint/recommended", 7 | "plugin:@typescript-eslint/recommended-requiring-type-checking" 8 | ], 9 | "parser": "@typescript-eslint/parser", 10 | "parserOptions": { 11 | "project": "tsconfig.json", 12 | "sourceType": "module" 13 | }, 14 | "plugins": [ 15 | "eslint-plugin-no-null", 16 | "eslint-plugin-jsdoc", 17 | "eslint-plugin-prefer-arrow", 18 | "@typescript-eslint", 19 | ], 20 | "rules": { 21 | "no-unused-vars": "off", 22 | "semi": "off", 23 | "@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}], 24 | "@typescript-eslint/semi": ["error"], 25 | "@typescript-eslint/adjacent-overload-signatures": "error", 26 | "@typescript-eslint/array-type": [ 27 | "error", 28 | { 29 | "default": "array" 30 | } 31 | ], 32 | "@typescript-eslint/ban-types": [ 33 | "error", 34 | { 35 | "types": { 36 | "Object": { 37 | "message": "Avoid using the `Object` type. Did you mean `object`?" 38 | }, 39 | "Function": { 40 | "message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`." 41 | }, 42 | "Boolean": { 43 | "message": "Avoid using the `Boolean` type. Did you mean `boolean`?" 44 | }, 45 | "Number": { 46 | "message": "Avoid using the `Number` type. Did you mean `number`?" 47 | }, 48 | "String": { 49 | "message": "Avoid using the `String` type. Did you mean `string`?" 50 | }, 51 | "Symbol": { 52 | "message": "Avoid using the `Symbol` type. Did you mean `symbol`?" 53 | } 54 | } 55 | } 56 | ], 57 | "@typescript-eslint/consistent-type-assertions": "error", 58 | "@typescript-eslint/dot-notation": "error", 59 | "@typescript-eslint/indent": "error", 60 | "@typescript-eslint/member-ordering": "error", 61 | "@typescript-eslint/naming-convention": ["error", 62 | {"selector": "function","format": ["PascalCase", "camelCase"]}, 63 | {"selector": "classProperty","format": ["camelCase", "UPPER_CASE"]} 64 | ], 65 | "@typescript-eslint/no-empty-function": "error", 66 | "@typescript-eslint/no-empty-interface": "error", 67 | "@typescript-eslint/no-explicit-any": "off", 68 | "@typescript-eslint/no-misused-new": "error", 69 | "@typescript-eslint/no-namespace": "error", 70 | "@typescript-eslint/no-parameter-properties": "off", 71 | "@typescript-eslint/no-shadow": [ 72 | "error", 73 | { 74 | "hoist": "all" 75 | } 76 | ], 77 | "@typescript-eslint/no-unused-expressions": "error", 78 | "@typescript-eslint/no-use-before-define": "off", 79 | "@typescript-eslint/no-var-requires": "error", 80 | "@typescript-eslint/prefer-for-of": "off", // TODO: maybe enable it ? 81 | "@typescript-eslint/prefer-function-type": "error", 82 | "@typescript-eslint/no-inferrable-types": "off", 83 | "@typescript-eslint/prefer-namespace-keyword": "error", 84 | "@typescript-eslint/triple-slash-reference": [ 85 | "error", 86 | { 87 | "path": "always", 88 | "types": "prefer-import", 89 | "lib": "always" 90 | } 91 | ], 92 | "@typescript-eslint/unified-signatures": "error", 93 | "comma-dangle": "off", 94 | "complexity": "off", 95 | "constructor-super": "error", 96 | "dot-notation": "error", 97 | "eol-last": "error", 98 | "eqeqeq": [ 99 | "error", 100 | "smart" 101 | ], 102 | "guard-for-in": "error", 103 | "id-denylist": [ 104 | "error", 105 | "any", 106 | "Number", 107 | "number", 108 | "String", 109 | "string", 110 | "Boolean", 111 | "boolean", 112 | "Undefined", 113 | "undefined" 114 | ], 115 | "id-match": "error", 116 | "indent": "off", 117 | "@typescript-eslint/indent": [ 118 | "error", 119 | 4, 120 | { 121 | "FunctionDeclaration": { 122 | "parameters": "first" 123 | }, 124 | "FunctionExpression": { 125 | "parameters": "first" 126 | }, 127 | "SwitchCase": 1, 128 | } 129 | ], 130 | "jsdoc/check-alignment": "error", 131 | "jsdoc/check-indentation": "error", 132 | "max-classes-per-file": "off", 133 | "new-parens": "error", 134 | "no-bitwise": "error", 135 | "no-caller": "error", 136 | "no-cond-assign": "error", 137 | "no-console": "error", 138 | "no-debugger": "error", 139 | "no-empty": "error", 140 | "no-empty-function": "error", 141 | "no-eval": "error", 142 | "no-fallthrough": "off", 143 | "no-invalid-this": "off", 144 | "no-new-wrappers": "error", 145 | "no-null/no-null": "error", 146 | "no-shadow": "off", 147 | "no-throw-literal": "error", 148 | "no-trailing-spaces": "error", 149 | "no-undef-init": "error", 150 | "no-underscore-dangle": "error", 151 | "no-unsafe-finally": "error", 152 | "no-unused-expressions": "error", 153 | "no-unused-labels": "error", 154 | "no-use-before-define": "off", 155 | "no-var": "error", 156 | "object-shorthand": "error", 157 | "one-var": [ 158 | "error", 159 | "never" 160 | ], 161 | "prefer-arrow/prefer-arrow-functions": "off", 162 | "prefer-const": "off", 163 | "quote-props": "off", 164 | "radix": "error", 165 | "spaced-comment": [ 166 | "error", 167 | "always", 168 | { 169 | "markers": [ 170 | "/" 171 | ] 172 | } 173 | ], 174 | "use-isnan": "error", 175 | "valid-typeof": "off", 176 | } 177 | }; 178 | -------------------------------------------------------------------------------- /src/keygen/insyde.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | /* eslint-disable @typescript-eslint/no-shadow */ 3 | /* eslint-disable no-shadow */ 4 | /* Maybe need fixing for browsers where numbers is 32-bits */ 5 | /* Some Acer, HP laptops. 8 digit */ 6 | import { makeSolver } from "./utils"; 7 | import { Crc64, Sha256, AES128 } from "./cryptoUtils"; 8 | 9 | const INSYDE_SALT = "Insyde Software Corp."; 10 | 11 | export function insydeAcerSwitch(arr: Uint8Array): Uint8Array { 12 | if (arr.length !== 32) { 13 | throw new Error("Input array should have 32 length"); 14 | } 15 | 16 | function fun0(arr: Uint8Array): Uint8Array { 17 | let output = new Uint8Array(16); 18 | let k = 0; 19 | for (let i = 3; i >= 0; i--) { 20 | for (let j = 0; j < 16; j += 4 ) { 21 | output[k++] = arr[i + j]; 22 | } 23 | } 24 | return output; 25 | } 26 | function fun1(arr: Uint8Array): Uint8Array { 27 | let output = new Uint8Array(16); 28 | let k = 0; 29 | for (let i = 0; i < 4; i++) { 30 | for (let j = 12; j >= 0; j -= 4) { 31 | output[k++] = arr[i + j]; 32 | } 33 | } 34 | return output; 35 | } 36 | function fun2(arr: Uint8Array): Uint8Array { 37 | let output = new Uint8Array(16); 38 | let k = 0; 39 | for (let i = 0; i < 4; i++) { 40 | for (let j = 0; j < 4; j++) { 41 | output[k++] = (arr[((j + i) & 3) + i * 4] + i) & 0xFF; 42 | } 43 | } 44 | return output; 45 | } 46 | function fun3(arr: Uint8Array): Uint8Array { 47 | let output = new Uint8Array(16); 48 | let k = 0; 49 | let acc1 = 0; 50 | let acc2 = 0; 51 | for (let i = 0; i < 4; i++) { 52 | acc1 ^= arr[i * 5]; 53 | acc2 ^= arr[i * 3 + 3]; 54 | } 55 | for (let i = 0; i < 16; i++) { 56 | const pivot = ((i & 1) === 0) ? acc1 : acc2; 57 | output[k++] = arr[i] ^ pivot; 58 | } 59 | return output; 60 | } 61 | function fun4(arr: Uint8Array): Uint8Array { 62 | let output = new Uint8Array(16); 63 | let k = 0; 64 | for (let i = 0; i < 16; i++) { 65 | const temp1 = arr[i]; 66 | const temp2 = arr[(i + 1) & 0xF]; // arr[(i + 1) % 15]; 67 | const pivot = (temp2 < temp1) ? temp2 : 0xFF; 68 | output[k++] = temp1 ^ pivot; 69 | } 70 | return output; 71 | } 72 | function fun5(arr: Uint8Array): Uint8Array { 73 | let output = new Uint8Array(16); 74 | for (let i = 0; i < 4; i++) { 75 | let acc: number = 0; 76 | for (let j = 0; j < 16; j += 4) { 77 | acc ^= arr[j + i]; 78 | } 79 | for (let j = 0; j < 16; j += 4) { 80 | const temp = i + j; 81 | output[temp] = (arr[temp] * acc) & 0xFF; 82 | } 83 | } 84 | return output; 85 | } 86 | function keyProcess(arr: Uint8Array): Uint8Array { 87 | let output = new Uint8Array(16); 88 | for (let i = 0; i < 16; i++) { 89 | let acc: number = 0; 90 | for (let j = 0; j < 8; j++) { 91 | acc += arr[((i >> 2) << 3) + j] * arr[j * 4 + (i & 3)]; 92 | } 93 | output[i] = acc & 0xFF; 94 | } 95 | return output; 96 | } 97 | 98 | const temp = keyProcess(arr); 99 | switch (arr[8] % 6) { 100 | case 0: 101 | return fun0(temp); 102 | case 1: 103 | return fun1(temp); 104 | case 2: 105 | return fun2(temp); 106 | case 3: 107 | return fun3(temp); 108 | case 4: 109 | return fun4(temp); 110 | default: 111 | return fun5(temp); 112 | } 113 | } 114 | 115 | // 10 digits acer key 116 | function acerInsydeKeygen(serial: string): string[] { 117 | function rotatefun(arr: Uint8Array): Uint8Array { 118 | const idx = arr[9] & 0xF; 119 | let output = new Uint8Array(16); 120 | for (let i = 0; i < output.length; i++) { 121 | output[i] = arr[((idx * 2 + 1) * i) % arr.length]; 122 | } 123 | return output; 124 | } 125 | 126 | const inputBytes = Uint8Array.from(serial.split("").map((c) => c.charCodeAt(0) & 0xFF)); 127 | const digest = (new Sha256(inputBytes)).digest(); 128 | const key = insydeAcerSwitch(digest); 129 | const blockData = rotatefun(digest); 130 | const data = (new AES128(key)).encryptBlock(blockData); 131 | let crc = new Crc64(Crc64.ECMA_POLYNOMIAL); 132 | crc.update(data); 133 | return [crc.hexdigest()]; 134 | } 135 | 136 | function insydeKeygen(serial: string): string[] { 137 | const salt1 = INSYDE_SALT; 138 | const salt2 = ":\x16@>\x1496H\x07.\x0f\x0e\nG-MDGHBT"; 139 | // some firmware has a bug in number convesion to string 140 | // they use simple snprintf(dst, 0x16, "%d", serial) so leading zeros are lost 141 | // and at the end buffer is filled with \x00 142 | const serial2 = (parseInt(serial, 10).toString() + "\x00".repeat(8)).slice(0, 8); 143 | let password1 = ""; 144 | let password2 = ""; 145 | let password3 = ""; 146 | for (let i = 0; i < 8; i++) { 147 | // salt.charCodeAt(i % salt.length) + (i % salt.length) 148 | let b: number = (salt1.charCodeAt(i) + i) ^ serial.charCodeAt(i); 149 | password1 += (b % 10).toString(); 150 | 151 | b = (salt1.charCodeAt(i) + i) ^ serial2.charCodeAt(i); 152 | password2 += (b % 10).toString(); 153 | 154 | b = salt2.charCodeAt(i) ^ serial2.charCodeAt(i); 155 | password3 += (b % 10).toString(); 156 | } 157 | if (password1 === password2) { 158 | return [password1, password3]; 159 | } else { 160 | return [password1, password2, password3]; 161 | } 162 | } 163 | 164 | function hpInsydeKeygen(serial: string): string[] { 165 | const inputRe = /^i\s*(\d{8})$/i; 166 | const salt1 = "c6B|wS^8"; 167 | const salt2 = INSYDE_SALT; 168 | const match = inputRe.exec(serial); 169 | 170 | if (!match || match.length !== 2) { 171 | return []; 172 | } else { 173 | serial = match[1]; 174 | } 175 | let password1 = ""; 176 | let password2 = ""; 177 | for (let i = 0; i < 8; i++) { 178 | let b: number = (salt1.charCodeAt(i) + i) ^ serial.charCodeAt(i); 179 | password1 += (b % 10).toString(); 180 | 181 | b = (salt2.charCodeAt(i) + i) ^ serial.charCodeAt(i); 182 | password2 += (b % 10).toString(); 183 | } 184 | return [password1, password2]; 185 | } 186 | 187 | export let insydeSolver = makeSolver({ 188 | name: "insydeH2O", 189 | description: "Insyde H2O BIOS (Acer, HP)", 190 | examples: ["03133610"], 191 | inputValidator: (s) => /^\d{8}$/i.test(s), 192 | fun: insydeKeygen 193 | }); 194 | 195 | export let acerInsyde10Solver = makeSolver({ 196 | name: "acerInsyde10", 197 | description: "Acer Insyde 10 digits", 198 | examples: ["0173549286"], 199 | inputValidator: (s) => /^\d{10}$/i.test(s), 200 | fun: acerInsydeKeygen 201 | }); 202 | 203 | export let hpInsydeSolver = makeSolver({ 204 | name: "hpInsyde", 205 | description: "HP Insyde H2O", 206 | examples: ["i 70412809", "I 59170869"], 207 | inputValidator: (s) => /^i\s*\d{8}$/i.test(s), 208 | fun: hpInsydeKeygen 209 | }); 210 | -------------------------------------------------------------------------------- /src/keygen/phoenix.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | import { 3 | asciiToKeyboardEnc, keyboardEncToAscii, reversedScanCodes, Solver 4 | } from "./utils"; 5 | 6 | export const enum PhoenixErrors { 7 | BadHash, 8 | NotFound 9 | } 10 | 11 | export interface PhoenixInfo { 12 | shift: number; 13 | salt: number; 14 | dictionary: string[]; 15 | minLen: number; 16 | maxLen: number; 17 | } 18 | 19 | export interface PhoenixBios extends Partial { 20 | name: string; 21 | description?: string; 22 | } 23 | 24 | export interface PhoenixSolver extends Solver { 25 | readonly info: PhoenixInfo; 26 | calculateHash(password: string): number; 27 | } 28 | 29 | // Without zero 30 | const digitsOnly: string[] = "123456789".split(""); 31 | 32 | const lettersOnly: string[] = "abcdefghijklmnopqrstuvwxyz".split(""); 33 | 34 | // const alphaNumeric: string[] = lettersOnly.concat(digitsOnly); 35 | 36 | const defaultPhoenix: PhoenixInfo = { 37 | shift: 0, 38 | salt: 0, 39 | dictionary: lettersOnly, 40 | minLen: 3, 41 | maxLen: 7 42 | }; 43 | 44 | /* The phoenix implementation of the CRC-16 contains a rather severe bug 45 | * quartering the image space of the function: both the first and second MSB 46 | * are always zero regardless of the input. 47 | * For a working implementation, you'd have to change the polynom from 0x2001 48 | * to e.g. 0xA001. 49 | */ 50 | 51 | function badCRC16(pwd: number[], salt: number = 0): number { 52 | 53 | let hash = salt; 54 | for (let c = 0; c < pwd.length; c++) { 55 | hash ^= pwd[c]; 56 | for (let i = 8; i--;) { 57 | if (hash & 1) { 58 | hash = (hash >> 1) ^ 0x2001; 59 | } else { 60 | hash = (hash >> 1); 61 | } 62 | } 63 | } 64 | return hash; 65 | } 66 | 67 | /* 68 | * Modified version of badCRC16 to speedup bruteForce. 69 | * Returns pasword length if it matches required hash 70 | * or -1 if it isn't matches requiredHash. 71 | */ 72 | function searchBadCRC16(pwd: number[], salt: number, requiredHash: number, minLen: number): number { 73 | 74 | minLen--; 75 | let hash = salt; 76 | for (let c = 0; c < pwd.length; c++) { 77 | hash ^= pwd[c]; 78 | for (let i = 8; i--;) { 79 | if (hash & 1) { 80 | hash = (hash >> 1) ^ 0x2001; 81 | } else { 82 | hash = (hash >> 1); 83 | } 84 | } 85 | 86 | if (c >= minLen && hash === requiredHash) { 87 | return c + 1; 88 | } 89 | } 90 | return -1; // not found 91 | } 92 | 93 | function generatePhoenixPassword(encodedPwd: number[], characters: string[] = lettersOnly): void { 94 | let rnd = Math.random() * characters.length; 95 | for (let i = 0; i < encodedPwd.length; i++) { 96 | let index = Math.floor(rnd % characters.length); 97 | encodedPwd[i] = reversedScanCodes[characters[index]]; 98 | rnd *= encodedPwd.length; 99 | } 100 | } 101 | 102 | function bruteForce(hash: number, salt: number = 0, characters: string[] = lettersOnly, 103 | minLen: number = 3, maxLen: number = 7): string | PhoenixErrors { 104 | 105 | let encodedPwd: number[] = []; 106 | for (let i = 0; i < maxLen; i++) { 107 | encodedPwd.push(0); 108 | } 109 | 110 | if (hash > 0x3FFF) { 111 | return PhoenixErrors.BadHash; 112 | } 113 | 114 | let kk = 0; 115 | while (true) { 116 | kk++; 117 | if (kk > 7000000) { 118 | return PhoenixErrors.NotFound; 119 | } 120 | 121 | generatePhoenixPassword(encodedPwd, characters); 122 | 123 | let found = searchBadCRC16(encodedPwd, salt, hash, minLen); 124 | if (found !== -1) { 125 | return keyboardEncToAscii(encodedPwd.slice(0, found)); 126 | } 127 | } 128 | } 129 | 130 | function makePhoenixSolver(description?: PhoenixBios): PhoenixSolver { 131 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ 132 | 133 | if (description === void 0) { 134 | description = {} as PhoenixBios; 135 | } 136 | 137 | let key: keyof PhoenixInfo; 138 | for (key in defaultPhoenix) { 139 | if (description[key] === void 0) { 140 | (description[key] as (PhoenixInfo[keyof PhoenixInfo])) = defaultPhoenix[key]; 141 | } 142 | } 143 | 144 | const info: PhoenixInfo = { 145 | shift: description.shift as number, 146 | salt: description.salt as number, 147 | dictionary: description.dictionary as string[], 148 | minLen: description.minLen as number, 149 | maxLen: description.maxLen as number 150 | }; 151 | 152 | let keygen = (code: string) => { 153 | let password = bruteForce(parseInt(code, 10) + info.shift, info.salt, 154 | info.dictionary, info.minLen, info.maxLen); 155 | 156 | if (typeof password === "string") { 157 | return [password]; 158 | } else { 159 | return []; 160 | } 161 | }; 162 | 163 | let cleaner = (code: string): string => code.trim().replace(/[-\s]/gi, ""); 164 | let validator = (s: string): boolean => /^[0-9]{5}$/i.test(s); 165 | let calculateHash = (password: string): number => { 166 | let pwd = asciiToKeyboardEnc(password); 167 | return badCRC16(pwd, info.salt) - info.shift; 168 | }; 169 | let solver: any = (code: string): string[] => { 170 | let cleanCode = cleaner(code); 171 | if (validator(cleanCode)) { 172 | return keygen(cleanCode); 173 | } else { 174 | return []; 175 | } 176 | }; 177 | 178 | solver.biosName = description.name; 179 | solver.validator = validator; 180 | solver.cleaner = cleaner; 181 | solver.keygen = keygen; 182 | solver.examples = ["12345"]; 183 | solver.info = info; 184 | solver.calculateHash = calculateHash; 185 | 186 | if (description.description) { 187 | solver.description = description.description; 188 | } 189 | return solver as PhoenixSolver; 190 | } 191 | 192 | export let phoenixSolver = makePhoenixSolver({ 193 | name: "phoenix", 194 | description: "Generic Phoenix" 195 | }); 196 | 197 | export let phoenixHPCompaqSolver = makePhoenixSolver({ 198 | name: "phoenixHP", 199 | description: "HP/Compaq Phoenix BIOS", 200 | salt: 17232 201 | }); 202 | 203 | export let phoenixFsiSolver = makePhoenixSolver({ 204 | name: "phoenixFSI", 205 | description: "Fujitsu-Siemens Phoenix", 206 | salt: 65, 207 | dictionary: digitsOnly 208 | }); 209 | 210 | export let phoenixFsiLSolver = makePhoenixSolver({ 211 | name: "phoenixFSIModelL", 212 | description: "Fujitsu-Siemens (model L) Phoenix", 213 | shift: 1, 214 | salt: "L".charCodeAt(0), 215 | dictionary: digitsOnly 216 | }); 217 | 218 | export let phoenixFsiPSolver = makePhoenixSolver({ 219 | name: "phoenixFSIModelP", 220 | description: "Fujitsu-Siemens (model P) Phoenix", 221 | shift: 1, 222 | salt: "P".charCodeAt(0), 223 | dictionary: digitsOnly 224 | }); 225 | 226 | export let phoenixFsiSSolver = makePhoenixSolver({ 227 | name: "phoenixFSIModelS", 228 | description: "Fujitsu-Siemens (model S) Phoenix", 229 | shift: 1, 230 | salt: "S".charCodeAt(0), 231 | dictionary: digitsOnly 232 | }); 233 | 234 | export let phoenixFsiXSolver = makePhoenixSolver({ 235 | name: "phoenixFSIModelX", 236 | description: "Fujitsu-Siemens (model X) Phoenix", 237 | shift: 1, 238 | salt: "X".charCodeAt(0), 239 | dictionary: digitsOnly 240 | }); 241 | -------------------------------------------------------------------------------- /src/keygen/fsi.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | import { makeSolver } from "./utils"; 3 | import { Crc32 } from "./cryptoUtils"; 4 | 5 | function generateCRC16Table(): number[] { 6 | let table: number[] = []; 7 | for (let i = 0, crc = 0; i < 256; i++) { 8 | crc = (i << 8); 9 | for (let j = 0; j < 8; j++) { 10 | crc = (crc << 1); 11 | if (crc & 0x10000) { 12 | crc = crc ^ 0x1021; 13 | } 14 | } 15 | table.push(crc & 0xFFFF); 16 | } 17 | return table; 18 | } 19 | 20 | const crc16Table = generateCRC16Table(); 21 | 22 | /* For Fujitsu-Siemens. 8 or 5x4 hexadecimal digits. */ 23 | function fsiHexKeygen(serial: string): string { 24 | 25 | function hashToString(hash: number) { 26 | const zero = "0".charCodeAt(0); 27 | return [12, 8, 4, 0].reduce((acc, num) => { 28 | let temp = String.fromCharCode(zero + ((hash >> num) % 16) % 10); 29 | return acc + temp; 30 | }, ""); 31 | } 32 | 33 | function calculateHash(word: string, table: number[]) { 34 | let hash = 0; 35 | for (let i = 0, d = 0; i < word.length; i++) { 36 | d = table[(word.charCodeAt(i) ^ (hash >> 8)) % 256]; 37 | hash = ((hash << 8) ^ d) & 0xFFFF ; 38 | } 39 | return hash; 40 | } 41 | 42 | if (serial.length === 20) { 43 | serial = serial.slice(12, 20); 44 | } 45 | 46 | return hashToString(calculateHash(serial.slice(0, 4), crc16Table)) + 47 | hashToString(calculateHash(serial.slice(4, 8), crc16Table)); 48 | } 49 | 50 | function codeToBytes(code: string): number[] { 51 | const numbers = [ 52 | parseInt(code.slice(0, 5), 10), 53 | parseInt(code.slice(5, 10), 10), 54 | parseInt(code.slice(10, 15), 10), 55 | parseInt(code.slice(15, 20), 10) 56 | ]; 57 | let acc = []; 58 | for (let val of numbers) { 59 | acc.push(val % 256); 60 | acc.push(Math.floor(val / 256)); 61 | } 62 | return acc; 63 | } 64 | 65 | /* For Fujitsu-Siemens. 5x4 dicimal digits */ 66 | function fsi20DecOldKeygen(serial: string): string { 67 | 68 | // opArr - array with that operations do, ar1,ar2 - numbers */ 69 | function interleave(opArr: number[], ar1: number[], ar2: number[]) { 70 | let arr = opArr.slice(0); // copy array 71 | arr[ar1[0]] = ((opArr[ar2[0]] >> 4) | (opArr[ar2[3]] << 4)) & 0xFF; 72 | arr[ar1[1]] = ((opArr[ar2[0]] & 0x0F) | (opArr[ar2[3]] & 0xF0)); 73 | arr[ar1[2]] = ((opArr[ar2[1]] >> 4) | (opArr[ar2[2]] << 4) & 0xFF); 74 | arr[ar1[3]] = (opArr[ar2[1]] & 0x0F) | (opArr[ar2[2]] & 0xF0); 75 | return arr; 76 | } 77 | 78 | function decryptCodeOld(bytes: number[]) { 79 | const xorKey = ":3-v@e4i"; 80 | // apply XOR key 81 | bytes.forEach((val, i, arr) => { 82 | arr[i] = val ^ xorKey.charCodeAt(i); 83 | }); 84 | // swap two bytes 85 | [bytes[2], bytes[6]] = [bytes[6], bytes[2]]; 86 | [bytes[3], bytes[7]] = [bytes[7], bytes[3]]; 87 | bytes = interleave(bytes, [0, 1, 2, 3], [0, 1, 2, 3]); 88 | bytes = interleave(bytes, [4, 5, 6, 7], [6, 7, 4, 5]); 89 | // final rotations 90 | bytes[0] = ((bytes[0] << 3) & 0xFF) | (bytes[0] >> 5); 91 | bytes[1] = ((bytes[1] << 5) & 0xFF) | (bytes[1] >> 3); 92 | bytes[2] = ((bytes[2] << 7) & 0xFF) | (bytes[2] >> 1); 93 | bytes[3] = ((bytes[3] << 4) & 0xFF) | (bytes[3] >> 4); 94 | bytes[5] = ((bytes[5] << 6) & 0xFF) | (bytes[5] >> 2); 95 | bytes[6] = ((bytes[6] << 1) & 0xFF) | (bytes[6] >> 7); 96 | bytes[7] = ((bytes[7] << 2) & 0xFF) | (bytes[7] >> 6); 97 | return bytes.map((b) => (b % 36).toString(36)).join(""); 98 | } 99 | 100 | return decryptCodeOld(codeToBytes(serial)); 101 | } 102 | 103 | /* For Fujitsu-Simens. 6x4 decimal digits */ 104 | function fsi24DecKeygen(serial: string): string { 105 | const xorKey = "<7#&9?>s"; 106 | const tmp = codeToBytes(serial.slice(4)); 107 | const bytes = [ 108 | (tmp[3] & 0xF0) | (tmp[0] & 0x0F), 109 | (tmp[2] & 0xF0) | (tmp[1] & 0x0F), 110 | (tmp[5] & 0xF0) | (tmp[6] & 0x0F), 111 | (tmp[4] & 0xF0) | (tmp[7] & 0x0F), 112 | (tmp[7] & 0xF0) | (tmp[4] & 0x0F), 113 | (tmp[6] & 0xF0) | (tmp[5] & 0x0F), 114 | (tmp[1] & 0xF0) | (tmp[2] & 0x0F), 115 | (tmp[0] & 0xF0) | (tmp[3] & 0x0F) 116 | ]; 117 | 118 | bytes.forEach((val, i, arr) => { 119 | arr[i] = val ^ xorKey.charCodeAt(i); 120 | }); 121 | 122 | bytes[0] = ((bytes[0] << 1) & 0xFF) | (bytes[0] >> 7); 123 | bytes[1] = ((bytes[1] << 7) & 0xFF) | (bytes[1] >> 1); 124 | bytes[2] = ((bytes[2] << 2) & 0xFF) | (bytes[2] >> 6); 125 | bytes[3] = ((bytes[3] << 8) & 0xFF) | (bytes[3] >> 0); 126 | bytes[4] = ((bytes[4] << 3) & 0xFF) | (bytes[4] >> 5); 127 | bytes[5] = ((bytes[5] << 6) & 0xFF) | (bytes[5] >> 2); 128 | bytes[6] = ((bytes[6] << 4) & 0xFF) | (bytes[6] >> 4); 129 | bytes[7] = ((bytes[7] << 5) & 0xFF) | (bytes[7] >> 3); 130 | return bytes.map((val) => (val % 36).toString(36)).join(""); 131 | } 132 | 133 | /* For Fujitsu-Siemens. 5x4 dicimal digits. new */ 134 | function fsi20DecNewKeygen(serial: string): string { 135 | const fKeys = [ 136 | "4798156302", "7201593846", "5412367098", "6587249310", 137 | "9137605284", "3974018625", "8052974163" 138 | ]; 139 | 140 | return [0, 2, 5, 11, 13, 15, 16].map((val, i) => { 141 | let temp = parseInt(serial.charAt(val), 10); 142 | return fKeys[i].charAt(temp); 143 | }).join(""); 144 | } 145 | 146 | /* For Fujitsu-Siemens. 6x4 203c-d001-xxxx-xxxx-xxxx-xxxx 147 | * Based on: https://gitlab.com/polloloco/fujitsu-bios-unlocker/ 148 | */ 149 | function fsiHex203Cd001Keygen(serial: string): string[] { 150 | if (serial.length !== 24) { 151 | return []; 152 | } 153 | serial = serial.toLowerCase(); 154 | if (serial.slice(0, 8) !== "203cd001") { 155 | return []; 156 | } 157 | let crc = new Crc32(); 158 | crc.update(serial.slice(8).split("").map(c => c.charCodeAt(0))); 159 | // JAMCRC 160 | const output = ("0".repeat(8) + ((~crc.digest()) >>> 0).toString(16)).slice(-8); 161 | return [output]; 162 | } 163 | 164 | export let fsiHexSolver = makeSolver({ 165 | name: "fsiHex", 166 | description: "Fujitsu-Siemens hexdigits", 167 | examples: ["DEADBEEF", "AAAA-BBBB-CCCC-DEAD-BEEF"], 168 | inputValidator: (s) => /^([0-9ABCDEF]{20}|[0-9ABCDEF]{8})$/i.test(s), 169 | fun: (code: string) => [fsiHexKeygen(code)] 170 | }); 171 | 172 | export let fsi20DecNewSolver = makeSolver({ 173 | name: "fsiDecNew", 174 | description: "Fujitsu-Siemens decimal new (5x4)", 175 | examples: ["1234-4321-1234-4321-1234"], 176 | inputValidator: (s) => /^\d{20}$/i.test(s), 177 | fun: (code: string) => [fsi20DecNewKeygen(code)] 178 | }); 179 | 180 | export let fsi20DecOldSolver = makeSolver({ 181 | name: "fsiDecOld", 182 | description: "Fujitsu-Siemens decimal old (5x4)", 183 | examples: ["1234-4321-1234-4321-1234"], 184 | inputValidator: (s) => /^\d{20}$/i.test(s), 185 | fun: (code: string) => [fsi20DecOldKeygen(code)] 186 | }); 187 | 188 | export let fsi24DecSolver = makeSolver({ 189 | name: "fsi24Dec", 190 | description: "Fujitsu-Siemens decimal old (6x4)", 191 | examples: ["8F16-1234-4321-1234-4321-1234"], 192 | inputValidator: (s) => /^[0-9ABCDEF]{4}\d{20}$/i.test(s), 193 | fun: (code: string) => [fsi24DecKeygen(code)] 194 | }); 195 | 196 | export let fsi24Hex203cSolver = makeSolver({ 197 | name: "fsi24Hex203c", 198 | description: "Fujitsu-Siemens Hex (6x4) 203c-d001-xxxx-xxxx-xxxx-xxxx", 199 | examples: ["203c-d001-0000-001d-e960-227d"], 200 | inputValidator: (s) => /^[0-9ABCDEF]{24}$/i.test(s), 201 | fun: (code: string) => fsiHex203Cd001Keygen(code) 202 | }); 203 | -------------------------------------------------------------------------------- /src/keygen/dell/index.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | import { makeSolver } from "../utils"; 3 | import { blockEncode, TagE7A8Encoder, TagE7A8EncoderSecond } from "./encode"; 4 | import { DES, latitude3540Keygen } from "./latitude"; 5 | import { DellTag, SuffixType } from "./types"; 6 | export { DellTag, SuffixType, DES, latitude3540Keygen }; 7 | import { Sha256 } from "../cryptoUtils"; 8 | 9 | const scanCodes: string = 10 | "\0\x1B1234567890-=\x08\x09qwertyuiop[]\x0D\xFFasdfghjkl;'`\xFF\\zxcvbnm,./"; 11 | 12 | const encscans: number[] = [ 13 | 0x05, 0x10, 0x13, 0x09, 0x32, 0x03, 0x25, 0x11, 0x1F, 0x17, 0x06, 0x15, 14 | 0x30, 0x19, 0x26, 0x22, 0x0A, 0x02, 0x2C, 0x2F, 0x16, 0x14, 0x07, 0x18, 15 | 0x24, 0x23, 0x31, 0x20, 0x1E, 0x08, 0x2D, 0x21, 0x04, 0x0B, 0x12, 0x2E 16 | ]; 17 | 18 | const asciiPrintable = "012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0"; 19 | 20 | const extraCharacters: {readonly [P in DellTag]?: string} = { 21 | "2A7B": asciiPrintable, 22 | "1F5A": asciiPrintable, 23 | "1D3B": "0BfIUG1kuPvc8A9Nl5DLZYSno7Ka6HMgqsJWm65yCQR94b21OTp7VFX2z0jihE33d4xtrew0", 24 | "1F66": "0ewr3d4xtUG1ku0BfIp7VFb21OTSno7KDLZYqsJWa6HMgCQR94m65y9Nl5Pvc8AjihE3X2z0", 25 | "6FF1": "08rptBxfbGVMz38IiSoeb360MKcLf4QtBCbWVzmH5wmZUcRR5DZG2xNCEv1nFtzsZB2bw1X0", 26 | "BF97": "0Q2drGk99rkQFMxN[Z5y3DGr16h638myIL2rzz2pzcU7JWLJ1EGnqRN4seZPRM2aBXIjbkGZ" 27 | }; 28 | 29 | /* 30 | * Does this really work somewhere ? 31 | * Depends only in first two chars 32 | * Input: 11 symbols 33 | */ 34 | function keygenHddOld(serial: string): string { 35 | let serialArr: number[] = serial.split("").map((c) => c.charCodeAt(0)); 36 | // encscans[26], encscans[0xAA % encscans.length] 37 | let ret: number[] = [49, 49, 49, 49, 49]; 38 | ret.push(serialArr[1] >> 1); 39 | ret.push((serialArr[1] >> 6) | (serialArr[0] << 2)); 40 | ret.push(serialArr[0] >> 3); 41 | // lower bits then 5 are never change 42 | for (let i = 0; i < 8; i++) { 43 | let r = 0xAA; 44 | if (ret[i] & 8) { 45 | r ^= serialArr[1]; 46 | } 47 | if (ret[i] & 16) { 48 | r ^= serialArr[0]; 49 | } 50 | ret[i] = encscans[r % encscans.length]; 51 | } 52 | return ret.map((c) => scanCodes.charAt(c)).join(""); 53 | } 54 | 55 | export function calculateSuffix(serial: number[], tag: DellTag, type: SuffixType): number[] { 56 | let suffix: number[] = []; 57 | let codesTable: number[]; 58 | let arr1: number[]; 59 | let arr2: number[]; 60 | 61 | if (type === SuffixType.ServiceTag) { 62 | arr1 = [1, 2, 3, 4]; 63 | arr2 = [4, 3, 2]; 64 | } else { 65 | // SuffixType.HDD 66 | arr1 = [1, 10, 9, 8]; 67 | arr2 = [8, 9, 10]; 68 | } 69 | 70 | suffix[0] = serial[arr1[3]]; 71 | suffix[1] = (serial[arr1[3]] >> 5) | 72 | (((serial[arr1[2]] >> 5) | (serial[arr1[2]] << 3)) & 0xF1); 73 | suffix[2] = serial[arr1[2]] >> 2; 74 | suffix[3] = (serial[arr1[2]] >> 7) | (serial[arr1[1]] << 1); 75 | suffix[4] = (serial[arr1[1]] >> 4) | (serial[arr1[0]] << 4); 76 | suffix[5] = serial[1] >> 1; 77 | suffix[6] = (serial[1] >> 6) | (serial[0] << 2); 78 | suffix[7] = serial[0] >> 3; 79 | 80 | // normalize bytes 81 | suffix.forEach((v, i) => { 82 | suffix[i] = v & 0xFF; 83 | }); 84 | 85 | let table = extraCharacters[tag]; 86 | if (table !== undefined) { 87 | codesTable = table.split("").map((s) => s.charCodeAt(0)); 88 | } else { 89 | codesTable = encscans; 90 | } 91 | 92 | for (let i = 0; i < 8; i++) { 93 | let r = 0xAA; 94 | if (suffix[i] & 1) { 95 | r ^= serial[arr2[0] ]; 96 | } 97 | if (suffix[i] & 2) { 98 | r ^= serial[arr2[1]]; 99 | } 100 | if (suffix[i] & 4) { 101 | r ^= serial[arr2[2]]; 102 | } 103 | if (suffix[i] & 8) { 104 | r ^= serial[1]; 105 | } 106 | if (suffix[i] & 16) { 107 | r ^= serial[0]; 108 | } 109 | 110 | suffix[i] = codesTable[r % codesTable.length]; 111 | } 112 | 113 | return suffix; 114 | } 115 | 116 | function resultToString(arr: number[] | Uint8Array, tag: DellTag): string { 117 | let r = arr[0] % 9; 118 | let result = ""; 119 | let table = extraCharacters[tag]; 120 | for (let i = 0; i < 16; i++) { 121 | if (table !== undefined) { 122 | result += table.charAt(arr[i] % table.length); 123 | } else if (r <= i && result.length < 8) { // 595B, D35B, A95B 124 | result += scanCodes.charAt(encscans[arr[i] % encscans.length]); 125 | } 126 | } 127 | return result; 128 | } 129 | /* 130 | * 7 symbols + 4 symbols ( 595B, D35B, 2A7B, A95B, 1D3B etc...) 131 | * serial -- serial number without tag, 7 symbols for ServiceTag, 11 symbols for HDD 132 | * tag -- tag string 133 | */ 134 | export function keygenDell(serial: string, tag: DellTag, type: SuffixType): string[] { 135 | let fullSerial: string; 136 | let encBlock: number[]; 137 | 138 | function byteArrayToInt(arr: number[]): number[] { 139 | // convert byte array to 32-bit little-endian int array 140 | // also will convert undefined values to 0 141 | let resultLength = arr.length >> 2; // divide length to 4 142 | let result: number[] = []; 143 | for (let i = 0; i <= resultLength; i++) { 144 | result[i] = arr[i * 4] | (arr[i * 4 + 1] << 8) | 145 | (arr[i * 4 + 2] << 16) | (arr[i * 4 + 3] << 24) | 0; 146 | } 147 | return result; 148 | } 149 | 150 | function intArrayToByte(arr: number[]): number[] { 151 | // convert 32-bit little-endian array to byte array 152 | let result: number[] = []; 153 | arr.forEach((num) => { 154 | result.push(num & 0xFF); 155 | result.push((num >> 8) & 0xFF); 156 | result.push((num >> 16) & 0xFF); 157 | result.push((num >> 24) & 0xFF); 158 | }); 159 | return result; 160 | } 161 | 162 | function calculateE7A8(block: number[], klass: {encode(data: number[]): number[]}): string { 163 | // TODO: refactor this 164 | const table = "Q92G0drk9y63r5DG1hLqJGW1EnRk[QxrFMNZ328I6myLr4MsPNeZR2z72czpzUJBGXbaIjkZ"; 165 | const res = intArrayToByte(klass.encode(block)); 166 | const digest = new Sha256(Uint8Array.from(res)); 167 | const out = digest.digest(); 168 | let out_str = ""; 169 | for (let i = 0; i < 16; i++) { 170 | out_str += table[(out[i + 16] + out[i]) % table.length]; 171 | } 172 | return out_str; 173 | } 174 | 175 | if (tag === DellTag.TagA95B) { 176 | 177 | if (type === SuffixType.ServiceTag) { 178 | fullSerial = serial + DellTag.Tag595B; 179 | } else { // HDD 180 | fullSerial = serial.slice(3) + "\0\0\0" + DellTag.Tag595B; 181 | } 182 | 183 | } else { 184 | fullSerial = serial + tag; 185 | } 186 | 187 | let fullSerialArray: number[] = []; 188 | // convert string to byte array 189 | for (let i = 0; i < fullSerial.length; i++) { 190 | // Maybe protect against unicode symbols with: charCode & 0xFF ? 191 | fullSerialArray.push(fullSerial.charCodeAt(i)); 192 | } 193 | if (tag === DellTag.TagE7A8) { 194 | // TODO: refactor all this 195 | encBlock = byteArrayToInt(fullSerialArray); 196 | for (let i = 0; i < 16; i++) { 197 | if (encBlock[i] === undefined) { 198 | encBlock[i] = 0; 199 | } 200 | } 201 | const out_str1 = calculateE7A8(encBlock, TagE7A8Encoder); 202 | const out_str2 = calculateE7A8(encBlock, TagE7A8EncoderSecond); 203 | let output = []; 204 | if (out_str1) { 205 | output.push(out_str1); 206 | } 207 | if (out_str2) { 208 | output.push(out_str2); 209 | } 210 | return output; 211 | } 212 | 213 | fullSerialArray = fullSerialArray.concat(calculateSuffix(fullSerialArray, tag, type)); 214 | const cnt = 23; 215 | // NOTE: after this array might contain undefined values 216 | fullSerialArray[cnt] = 0x80; 217 | encBlock = byteArrayToInt(fullSerialArray); 218 | // fill empty values with zeros 219 | for (let i = 0; i < 16; i++) { 220 | if (encBlock[i] === undefined) { 221 | encBlock[i] = 0; 222 | } 223 | } 224 | encBlock[14] = cnt << 3; 225 | let decodedBytes = intArrayToByte(blockEncode(encBlock, tag)); 226 | const outputResult = resultToString(decodedBytes, tag); 227 | return (outputResult) ? [outputResult] : []; 228 | } 229 | 230 | function checkDellTag(tag: string): boolean { 231 | tag = tag.toUpperCase(); 232 | for (let tagItem in DellTag) { 233 | if (tag === (DellTag[tagItem as keyof typeof DellTag])) { 234 | return true; 235 | } 236 | } 237 | return false; 238 | } 239 | 240 | export let hddOldSolver = makeSolver({ 241 | name: "dellHDDOld", 242 | description: "Dell HDD Serial Number (old)", 243 | examples: ["12345678901"], 244 | inputValidator: (s) => s.length === 11, 245 | fun: (s) => [keygenHddOld(s)] 246 | }); 247 | 248 | export let dellSolver = makeSolver({ 249 | name: "dellTag", 250 | description: "Dell from serial number", 251 | examples: ["1234567-595B", "1234567-1D3B"], 252 | inputValidator: (password: string) => { 253 | if (password.length !== 11) { 254 | return false; 255 | } else { 256 | return checkDellTag(password.slice(7, 11)); 257 | } 258 | }, 259 | fun: (password: string) => { 260 | const suffix = password.slice(7, 11).toUpperCase(); 261 | return keygenDell(password.slice(0, 7).toUpperCase(), suffix as DellTag, SuffixType.ServiceTag); 262 | } 263 | }); 264 | 265 | export let dellHddSolver = makeSolver({ 266 | name: "dellHddNew", 267 | description: "Dell from hdd serial number", 268 | examples: ["1234567890A-595B"], 269 | inputValidator: (password: string) => { 270 | if (password.length !== 15) { 271 | return false; 272 | } else { 273 | return checkDellTag(password.slice(11, 15)); 274 | } 275 | }, 276 | fun: (password: string) => { 277 | const suffix = password.slice(11, 15).toUpperCase(); 278 | return keygenDell(password.slice(0, 11).toUpperCase(), suffix as DellTag, SuffixType.HDD); 279 | } 280 | }); 281 | 282 | const latitude3540RE = /^([0-9A-F]{16})([0-9A-Z]{7})$/i; 283 | 284 | // TODO: implement solver with 2 inputs 285 | export let dellLatitude3540Solver = makeSolver({ 286 | name: "dellLatitude3540", 287 | description: "Dell Latitude 3540", 288 | examples: ["5F3988D5E0ACE4BF-7QH8602"], 289 | inputValidator: (pwd) => latitude3540RE.test(pwd), 290 | fun: (input: string) => { 291 | const match = latitude3540RE.exec(input); 292 | if (match && match.length === 3) { 293 | const output = latitude3540Keygen(match[1], match[2]); 294 | if (output) { 295 | return [output]; 296 | } 297 | } 298 | return []; 299 | } 300 | }); 301 | -------------------------------------------------------------------------------- /src/keygen/dell/latitude.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | 3 | export class DES { 4 | // DES ECB mode 5 | // Initial permutation table 6 | private static readonly IP: Uint8Array = Uint8Array.from([ 7 | 58, 50, 42, 34, 26, 18, 10, 2, 8 | 60, 52, 44, 36, 28, 20, 12, 4, 9 | 62, 54, 46, 38, 30, 22, 14, 6, 10 | 64, 56, 48, 40, 32, 24, 16, 8, 11 | 57, 49, 41, 33, 25, 17, 9, 1, 12 | 59, 51, 43, 35, 27, 19, 11, 3, 13 | 61, 53, 45, 37, 29, 21, 13, 5, 14 | 63, 55, 47, 39, 31, 23, 15, 7, 15 | ]); 16 | 17 | // final permutation table 18 | private static readonly FP: Uint8Array = Uint8Array.from([ 19 | 40, 8, 48, 16, 56, 24, 64, 32, 20 | 39, 7, 47, 15, 55, 23, 63, 31, 21 | 38, 6, 46, 14, 54, 22, 62, 30, 22 | 37, 5, 45, 13, 53, 21, 61, 29, 23 | 36, 4, 44, 12, 52, 20, 60, 28, 24 | 35, 3, 43, 11, 51, 19, 59, 27, 25 | 34, 2, 42, 10, 50, 18, 58, 26, 26 | 33, 1, 41, 9, 49, 17, 57, 25, 27 | ]); 28 | 29 | // permutation choice 1 30 | private static readonly PC1: Uint8Array = Uint8Array.from([ 31 | 57, 49, 41, 33, 25, 17, 9, 32 | 1, 58, 50, 42, 34, 26, 18, 33 | 10, 2, 59, 51, 43, 35, 27, 34 | 19, 11, 3, 60, 52, 44, 36, 35 | 63, 55, 47, 39, 31, 23, 15, 36 | 7, 62, 54, 46, 38, 30, 22, 37 | 14, 6, 61, 53, 45, 37, 29, 38 | 21, 13, 5, 28, 20, 12, 4, 39 | ]); 40 | 41 | // permutation choice 2 42 | private static readonly PC2: Uint8Array = Uint8Array.from([ 43 | 14, 17, 11, 24, 1, 5, 3, 28, 44 | 15, 6, 21, 10, 23, 19, 12, 4, 45 | 26, 8, 16, 7, 27, 20, 13, 2, 46 | 41, 52, 31, 37, 47, 55, 30, 40, 47 | 51, 45, 33, 48, 44, 49, 39, 56, 48 | 34, 53, 46, 42, 50, 36, 29, 32, 49 | ]); 50 | 51 | // expansion table (E table) 52 | private static readonly EXPANSION: Uint8Array = Uint8Array.from([ 53 | 32, 1, 2, 3, 4, 5, 54 | 4, 5, 6, 7, 8, 9, 55 | 8, 9, 10, 11, 12, 13, 56 | 12, 13, 14, 15, 16, 17, 57 | 16, 17, 18, 19, 20, 21, 58 | 20, 21, 22, 23, 24, 25, 59 | 24, 25, 26, 27, 28, 29, 60 | 28, 29, 30, 31, 32, 1, 61 | ]); 62 | 63 | // Post S-Box permutation (P table) 64 | private static readonly POST_SBOX: Uint8Array = Uint8Array.from([ 65 | 16, 7, 20, 21, 66 | 29, 12, 28, 17, 67 | 1, 15, 23, 26, 68 | 5, 18, 31, 10, 69 | 2, 8, 24, 14, 70 | 32, 27, 3, 9, 71 | 19, 13, 30, 6, 72 | 22, 11, 4, 25, 73 | ]); 74 | 75 | private static readonly ITERATION_SHIFT: Uint8Array = Uint8Array.from([ 76 | 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 77 | ]); 78 | 79 | private static readonly SBOX: Uint8Array = Uint8Array.from([ 80 | // S1 81 | 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 82 | 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, 83 | 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, 84 | 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, 85 | // S2 86 | 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 87 | 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 88 | 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 89 | 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, 90 | // S3 91 | 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 92 | 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 93 | 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 94 | 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, 95 | // S4 96 | 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 97 | 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 98 | 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 99 | 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, 100 | // S5 101 | 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 102 | 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 103 | 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 104 | 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, 105 | // S6 106 | 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 107 | 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 108 | 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 109 | 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, 110 | // S7 111 | 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 112 | 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 113 | 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 114 | 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, 115 | // S8 116 | 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 117 | 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 118 | 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 119 | 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11, 120 | ]); 121 | 122 | private key: Uint8Array; 123 | private subKeys: Uint32Array; 124 | 125 | constructor(key: Uint8Array) { 126 | if (key.length !== 8) { 127 | throw new Error("DES key should be 8 bytes long"); 128 | } 129 | 130 | this.key = Uint8Array.from(key); 131 | this.subKeys = new Uint32Array(16 * 2); 132 | this.generateSubkeys(); 133 | } 134 | 135 | private static FUNC(data: number, subkey2: number, subkey1: number): number { 136 | let part1: number = 0; 137 | let part2: number = 0; 138 | let temp: number = 0; 139 | let output: number = 0; 140 | 141 | for (let i = 0; i < 48; i++) { 142 | const index = DES.EXPANSION[i] - 1; 143 | if (i < 32) { 144 | part1 |= ((data >>> index) & 1) << i; 145 | } else { 146 | part2 |= ((data >>> index) & 1) << (i - 32); 147 | } 148 | } 149 | part2 ^= subkey2; 150 | part1 ^= subkey1; 151 | 152 | function getEBit(index: number): number { 153 | if (index < 32) { 154 | return (part1 >>> index) & 1; 155 | } else { 156 | return (part2 >>> (index - 32)) & 1; 157 | } 158 | } 159 | 160 | for (let i = 0, level = 0; i < 48; i += 6, level++) { 161 | const row = getEBit(i) << 1 | getEBit(i + 5); 162 | const col = getEBit(i + 1) << 3 | getEBit(i + 2) << 2 | getEBit(i + 3) << 1 | getEBit(i + 4); 163 | const num = DES.SBOX[level << 6 | row << 4 | col]; 164 | // outputut in reverse order 165 | temp = (temp << 4) | num; 166 | } 167 | 168 | for (let i = 0; i < 32; i++) { 169 | const index = 32 - DES.POST_SBOX[i]; 170 | output |= ((temp >>> index) & 1) << i; 171 | } 172 | return output; 173 | } 174 | 175 | public encryptBlock(input: Uint8Array): Uint8Array { 176 | return this.cryptBlock(input, true); 177 | } 178 | 179 | public decryptBlock(input: Uint8Array): Uint8Array { 180 | return this.cryptBlock(input, false); 181 | } 182 | 183 | private generateSubkeys() { 184 | let leftpart: number = 0; 185 | let rightpart: number = 0; 186 | 187 | for (let i = 0; i < 56; i++) { 188 | const index = DES.PC1[i] - 1; 189 | const bit = (this.key[index >>> 3] >>> (7 - (index & 0b111))) & 1; 190 | if (i < 28) { 191 | leftpart |= (bit << i); 192 | } else { 193 | rightpart |= (bit << (i - 28)); 194 | } 195 | } 196 | function rightShift(part: number, val: number) { 197 | return (part >>> val | part << (28 - val)) & 0xfffffff; 198 | } 199 | 200 | for (let round = 0; round < 16; round++) { 201 | let subkeyPart1: number = 0; 202 | let subkeyPart2: number = 0; 203 | 204 | leftpart = rightShift(leftpart, DES.ITERATION_SHIFT[round]); 205 | rightpart = rightShift(rightpart, DES.ITERATION_SHIFT[round]); 206 | for (let i = 0; i < 48; i++) { 207 | const index = DES.PC2[i] - 1; 208 | const bit = ((index < 28) ? (leftpart >>> index) : (rightpart >>> (index - 28))) & 1; 209 | if (i < 32) { 210 | subkeyPart1 |= (bit << i); 211 | } else { 212 | subkeyPart2 |= (bit << (i - 32)); 213 | } 214 | } 215 | this.subKeys[round << 1] = subkeyPart2; 216 | this.subKeys[round << 1 | 1] = subkeyPart1; 217 | } 218 | } 219 | 220 | private cryptBlock(input: Uint8Array, encrypt: boolean = true): Uint8Array { 221 | if (input.length !== 8) { 222 | throw new Error("Input should be 8 bytes long"); 223 | } 224 | let leftpart: number = 0; 225 | let rightpart: number = 0; 226 | // initial permutation 227 | for (let i = 0; i < 64; i++) { 228 | const index = DES.IP[i] - 1; 229 | const bit = (input[index >>> 3] >>> (7 - (index & 0b111))) & 1; 230 | if (i < 32) { 231 | leftpart |= (bit << i); 232 | } else { 233 | rightpart |= (bit << (i - 32)); 234 | } 235 | } 236 | if (encrypt) { 237 | for (let round = 0; round < 16; round++) { 238 | const temp = rightpart; 239 | rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1], 240 | this.subKeys[round << 1 | 1]); 241 | leftpart = temp; 242 | } 243 | } else { 244 | // reverse order 245 | for (let round = 15; round >= 0; round--) { 246 | const temp = rightpart; 247 | rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1], 248 | this.subKeys[round << 1 | 1]); 249 | leftpart = temp; 250 | } 251 | } 252 | 253 | // final permutation 254 | let output: Uint8Array = new Uint8Array(8); 255 | for (let i = 0; i < 64; i++) { 256 | const index = DES.FP[i] - 1; 257 | let bit: number; 258 | if (index < 32) { 259 | bit = (rightpart >>> index) & 1; 260 | } else { 261 | bit = (leftpart >>> (index - 32)) & 1; 262 | } 263 | output[i >>> 3] |= (bit << (7 - (i & 0b111))); 264 | } 265 | return output; 266 | } 267 | } 268 | 269 | 270 | /* 271 | * Latitude 3540 keygen 272 | * hash -- 16 digit hexdeciman number 273 | * tag -- 7 chars length string 274 | */ 275 | export function latitude3540Keygen(hash: string, tag: string): string | undefined { 276 | const checkRe = /^[0-9A-Fa-f]$/; 277 | const masterKey = Uint8Array.from("23AAFFAD".split("").map(v => v.charCodeAt(0))); 278 | const enc1 = new DES(masterKey); 279 | let block1 = new Uint8Array(8); 280 | let block2 = new Uint8Array(8); 281 | let pwd: string = ""; 282 | // read hex encoded 8 byte block 283 | for (let i = 0; i < 8; i++) { 284 | block2[i] = parseInt(hash.slice(i * 2, i * 2 + 2), 16); 285 | } 286 | block1[0] = tag.charCodeAt(tag.length - 1); 287 | const key2 = enc1.encryptBlock(block1); 288 | const enc2 = new DES(key2); 289 | const encodedPwd = enc2.decryptBlock(block2); 290 | for (let i = 0; i < 8; i++) { 291 | const sym = String.fromCharCode(encodedPwd[i]); 292 | if (checkRe.test(sym)) { 293 | pwd += sym; 294 | } else { 295 | return undefined; 296 | } 297 | } 298 | return pwd; 299 | } 300 | -------------------------------------------------------------------------------- /src/keygen/dell.spec.ts: -------------------------------------------------------------------------------- 1 | // OPENSRC-1D3B = S3yJ91q0Gar3O72I 2 | // ABCDEFG-1D3B xvn0qEeftqyrkG52 3 | // NOSOUP4-3A5B zvd97y9h 4 | // 7G9C0G2-6FF1 35c0b0tVb32Z6ivD 5 | // 6 | // 7 | // HDD SN WXH109A14712 ? 8 | import { 9 | calculateSuffix, dellHddSolver, dellLatitude3540Solver, dellSolver, DellTag, DES, hddOldSolver, 10 | keygenDell, latitude3540Keygen, SuffixType 11 | } from "./dell"; 12 | 13 | // shortcut for simpler testing 14 | function checkSuffix(serial: string, tag: DellTag, type: SuffixType): number[] { 15 | serial = serial.concat(tag); 16 | let serialArr: number[] = serial.split("").map((c) => c.charCodeAt(0)); 17 | return calculateSuffix(serialArr, tag, type); 18 | } 19 | 20 | describe("Test calculateSuffix", () => { 21 | it("Check tag suffix for: 1234567-595B", () => { 22 | let suffix = checkSuffix("1234567", DellTag.Tag595B, SuffixType.ServiceTag); 23 | expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]); 24 | }); 25 | 26 | it("Check tag suffix for: 1234567-D35B", () => { 27 | let suffix = checkSuffix("1234567", DellTag.TagD35B, SuffixType.ServiceTag); 28 | expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]); 29 | }); 30 | 31 | it("Check tag suffix for: 1234567-2A7B", () => { 32 | let suffix = checkSuffix("1234567", DellTag.Tag2A7B, SuffixType.ServiceTag); 33 | expect(suffix).toEqual([101, 103, 102, 117, 115, 100, 97, 117]); 34 | }); 35 | 36 | it("Check tag suffix for: 1234567-A95B", () => { 37 | let suffix = checkSuffix("1234567", DellTag.TagA95B, SuffixType.ServiceTag); 38 | expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]); 39 | }); 40 | 41 | it("Check tag suffix for: 1234567-1D3B", () => { 42 | let suffix = checkSuffix("1234567", DellTag.Tag1D3B, SuffixType.ServiceTag); 43 | expect(suffix).toEqual([65, 78, 57, 72, 97, 56, 80, 72]); 44 | }); 45 | 46 | it("Check tag suffix for: 1234567-6FF1", () => { 47 | let suffix = checkSuffix("1234567", DellTag.Tag6FF1, SuffixType.ServiceTag); 48 | expect(suffix).toEqual([51, 73, 56, 52, 76, 122, 71, 52]); 49 | }); 50 | 51 | it("Check tag suffix for: 1234567-1F66", () => { 52 | let suffix = checkSuffix("1234567", DellTag.Tag1F66, SuffixType.ServiceTag); 53 | expect(suffix).toEqual([117, 66, 48, 111, 83, 107, 85, 111]); 54 | }); 55 | 56 | it("Check tag suffix for: 1234567-1F5A", () => { 57 | let suffix = checkSuffix("1234567", DellTag.Tag1F5A, SuffixType.ServiceTag); 58 | expect(suffix).toEqual([101, 103, 102, 117, 115, 100, 97, 117]); 59 | }); 60 | 61 | it("Check tag suffix for: ABCDEFG-1F5A", () => { 62 | let suffix = checkSuffix("ABCDEFG", DellTag.Tag1F5A, SuffixType.ServiceTag); 63 | expect(suffix).toEqual([0x74, 0x6e, 0x76, 0x75, 0x69, 0x6f, 0x74, 0x68]); 64 | }); 65 | 66 | it("Check tag suffix for: 1234567-BF97", () => { 67 | let suffix = checkSuffix("1234567", DellTag.TagBF97, SuffixType.ServiceTag); 68 | expect(suffix).toEqual([77, 78, 120, 56, 54, 70, 114, 56]); 69 | }); 70 | 71 | it("Check tag suffix for: ABCDEFG-BF97", () => { 72 | let suffix = checkSuffix("ABCDEFG", DellTag.TagBF97, SuffixType.ServiceTag); 73 | expect(suffix).toEqual([51, 71, 109, 56, 90, 114, 51, 91]); 74 | }); 75 | 76 | // HDD 77 | it("Check hdd suffix for: 12345678901-595B", () => { 78 | let suffix = checkSuffix("12345678901", DellTag.Tag595B, SuffixType.HDD); 79 | expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]); 80 | }); 81 | 82 | it("Check hdd suffix for: 12345678901-D35B", () => { 83 | let suffix = checkSuffix("12345678901", DellTag.TagD35B, SuffixType.HDD); 84 | expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]); 85 | }); 86 | 87 | it("Check hdd suffix for: 12345678901-2A7B", () => { 88 | let suffix = checkSuffix("12345678901", DellTag.Tag2A7B, SuffixType.HDD); 89 | expect(suffix).toEqual([48, 51, 113, 98, 107, 48, 99, 115]); 90 | }); 91 | 92 | it("Check hdd suffix for: 12345678901-A95B", () => { 93 | let suffix = checkSuffix("12345678901", DellTag.TagA95B, SuffixType.HDD); 94 | expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]); 95 | }); 96 | 97 | it("Check hdd suffix for: 12345678901-1D3B", () => { 98 | let suffix = checkSuffix("12345678901", DellTag.Tag1D3B, SuffixType.HDD); 99 | expect(suffix).toEqual([48, 73, 55, 118, 76, 48, 99, 97]); 100 | }); 101 | 102 | it("Check hdd suffix for: 12345678901-6FF1", () => { 103 | let suffix = checkSuffix("12345678901", DellTag.Tag6FF1, SuffixType.HDD); 104 | expect(suffix).toEqual([48, 112, 75, 86, 101, 48, 77, 76]); 105 | }); 106 | 107 | it("Check hdd suffix for: 12345678901-1F66", () => { 108 | let suffix = checkSuffix("12345678901", DellTag.Tag1F66, SuffixType.HDD); 109 | expect(suffix).toEqual([48, 114, 79, 71, 55, 48, 49, 83]); 110 | }); 111 | 112 | it("Check hdd suffix for: 12345678901-1F5A", () => { 113 | let suffix = checkSuffix("12345678901", DellTag.Tag1F5A, SuffixType.HDD); 114 | expect(suffix).toEqual([48, 51, 113, 98, 107, 48, 99, 115]); 115 | }); 116 | 117 | it("Check hdd suffix for: 12345678901-BF97", () => { 118 | let suffix = checkSuffix("12345678901", DellTag.TagBF97, SuffixType.HDD); 119 | expect(suffix).toEqual([48, 100, 54, 107, 121, 48, 81, 54]); 120 | }); 121 | }); 122 | 123 | describe("Test keygenDell", () => { 124 | it("Dell password for: 1234567-595B", () => { 125 | expect(keygenDell("1234567", DellTag.Tag595B, SuffixType.ServiceTag)) 126 | .toEqual(["46rg65ky"]); 127 | }); 128 | it("Dell password for: 1234567-D35B", () => { 129 | expect(keygenDell("1234567", DellTag.TagD35B, SuffixType.ServiceTag)) 130 | .toEqual(["5tc8q9re"]); 131 | }); 132 | it("Dell password for: 1234567-2A7B", () => { 133 | expect(keygenDell("1234567", DellTag.Tag2A7B, SuffixType.ServiceTag)) 134 | .toEqual(["J1KuwWpSUgnDarfi"]); 135 | }); 136 | it("Dell password for: 1234567-A95B", () => { 137 | expect(keygenDell("1234567", DellTag.TagA95B, SuffixType.ServiceTag)) 138 | .toEqual(["46rg65ky"]); 139 | }); 140 | it("Dell password for: 1234567-1D3B", () => { 141 | expect(keygenDell("1234567", DellTag.Tag1D3B, SuffixType.ServiceTag)) 142 | .toEqual(["Sn4fkF8bS57NymZl"]); 143 | }); 144 | it("Dell password for: 1234567-1F66", () => { 145 | expect(keygenDell("1234567", DellTag.Tag1F66, SuffixType.ServiceTag)) 146 | .toEqual(["kIpTBzx0m3s10JDR"]); 147 | }); 148 | it("Dell password for: 1234567-6FF1", () => { 149 | expect(keygenDell("1234567", DellTag.Tag6FF1, SuffixType.ServiceTag)) 150 | .toEqual(["Rzn1wGe555H5bM2r"]); 151 | }); 152 | it("Dell password for: OPENSRC-1D3B", () => { 153 | expect(keygenDell("OPENSRC", DellTag.Tag1D3B, SuffixType.ServiceTag)) 154 | .toEqual(["S3yJ91q0Gar3O72I"]); 155 | }); 156 | it("Dell password for: ABCDEFG-1D3B", () => { 157 | expect(keygenDell("ABCDEFG", DellTag.Tag1D3B, SuffixType.ServiceTag)) 158 | .toEqual(["xvn0qEeftqyrkG52"]); 159 | }); 160 | it("Dell password for: 7G9C0G2-6FF1", () => { 161 | expect(keygenDell("7G9C0G2", DellTag.Tag6FF1, SuffixType.ServiceTag)) 162 | .toEqual(["35c0b0tVb32Z6ivD"]); 163 | }); 164 | it("Dell password for: DELLSUX-1F66", () => { 165 | expect(keygenDell("DELLSUX", DellTag.Tag1F66, SuffixType.ServiceTag)) 166 | .toEqual(["qHXaL0ntli6Gu4c0"]); 167 | }); 168 | it("Dell password for: CRPP562-1F66", () => { 169 | expect(keygenDell("CRPP562", DellTag.Tag1F66, SuffixType.ServiceTag)) 170 | .toEqual(["8i5qLGa9woA919Ys"]); 171 | }); 172 | it("Dell password for: CDG8T32-1F66", () => { 173 | expect(keygenDell("CDG8T32", DellTag.Tag1F66, SuffixType.ServiceTag)) 174 | .toEqual(["4Ke3y2L3kTP2f6Vo"]); 175 | }); 176 | it("Dell password for: 8M5RQ32-1F66", () => { 177 | expect(keygenDell("8M5RQ32", DellTag.Tag1F66, SuffixType.ServiceTag)) 178 | .toEqual(["3rlrbaSj46Iw221g"]); 179 | }); 180 | 181 | it("Dell password for: 1234567-1F5A", () => { 182 | expect(keygenDell("1234567", DellTag.Tag1F5A, SuffixType.ServiceTag)) 183 | .toEqual(["2ls2b8GiP9H032kx"]); 184 | }); 185 | 186 | it("Dell password for: OPENSRC-1F5A", () => { 187 | expect(keygenDell("OPENSRC", DellTag.Tag1F5A, SuffixType.ServiceTag)) 188 | .toEqual(["ZC3j2t56eIe4Thgi"]); 189 | }); 190 | 191 | it("Dell password for: ABCDEFG-1F5A", () => { 192 | expect(keygenDell("ABCDEFG", DellTag.Tag1F5A, SuffixType.ServiceTag)) 193 | .toEqual(["x2zL5n7jj2Gl2TIh"]); 194 | }); 195 | 196 | it("Dell password for: 1234567-BF97", () => { 197 | expect(keygenDell("1234567", DellTag.TagBF97, SuffixType.ServiceTag)) 198 | .toEqual(["2r09GZhU[r0kW2zr"]); 199 | }); 200 | 201 | it("Dell password for: OPENSRC-BF97", () => { 202 | expect(keygenDell("OPENSRC", DellTag.TagBF97, SuffixType.ServiceTag)) 203 | .toEqual(["Dp29XkbyMrkBrp6Z"]); 204 | }); 205 | 206 | it("Dell password for: ABCDEFG-BF97", () => { 207 | expect(keygenDell("ABCDEFG", DellTag.TagBF97, SuffixType.ServiceTag)) 208 | .toEqual(["kr9Z1cmPpahGzsQ["]); 209 | }); 210 | 211 | it("Dell password for: DELLSUX-BF97", () => { 212 | expect(keygenDell("DELLSUX", DellTag.TagBF97, SuffixType.ServiceTag)) 213 | .toEqual(["rrNM2LrbD8nGsd2P"]); 214 | }); 215 | it("Dell password for: 1234567-E7A8", () => { 216 | expect(keygenDell("1234567", DellTag.TagE7A8, SuffixType.ServiceTag).sort()) 217 | .toEqual(["Qk3LkU22kPeyq2jd", "rLIqjUy59IG2JU2R"].sort()); 218 | }); 219 | it("Dell password for: D875TG2-E7A8", () => { 220 | expect(keygenDell("D875TG2", DellTag.TagE7A8, SuffixType.ServiceTag).sort()) 221 | .toEqual(["rLZc96rMZyGQ2GMG", "1Q6rxIWMGUznXZNy"].sort()); 222 | }); 223 | it("Dell password for: 2XSX273-E7A8", () => { 224 | expect(keygenDell("2XSX273", DellTag.TagE7A8, SuffixType.ServiceTag).sort()) 225 | .toEqual(["rPQ0DGLdqckG2kUZ", "0ZaP6RzW9qk73rmq"].sort()); 226 | }); 227 | it("Dell password for: CZXKYX2-E7A8", () => { 228 | expect(keygenDell("CZXKYX2", DellTag.TagE7A8, SuffixType.ServiceTag).sort()) 229 | .toEqual(["RGWD2BIR9UB9ZdIy", "38Gr7brmRGBPPIkz"].sort()); 230 | }); 231 | it("Dell password for: 6651WZ2-E7A8", () => { 232 | expect(keygenDell("6651WZ2", DellTag.TagE7A8, SuffixType.ServiceTag).sort()) 233 | .toEqual(["PBjMMMsZUQR2MhmR", "Q1N6k2sLRkGGGrEN"].sort()); 234 | }); 235 | it("Dell password for: 9M2JTG2-E7A8", () => { 236 | expect(keygenDell("9M2JTG2", DellTag.TagE7A8, SuffixType.ServiceTag)) 237 | .toContain("J2yR66N1kdn2N17m"); 238 | }); 239 | it("Dell password for: 1219P73-E7A8", () => { 240 | expect(keygenDell("1219P73", DellTag.TagE7A8, SuffixType.ServiceTag)) 241 | .toContain("ksM02GskJ341hnDx"); 242 | }); 243 | 244 | // HDD 245 | it("Dell HDD password for: 1234567890A-595B", () => { 246 | expect(keygenDell("1234567890A", DellTag.Tag595B, SuffixType.HDD)) 247 | .toEqual(["nyoap4lq"]); 248 | }); 249 | it("Dell HDD password for: 1234567890A-D35B", () => { 250 | expect(keygenDell("1234567890A", DellTag.TagD35B, SuffixType.HDD)) 251 | .toEqual(["dc14blrd"]); 252 | }); 253 | it("Dell HDD password for: 1234567890A-2A7B", () => { 254 | expect(keygenDell("1234567890A", DellTag.Tag2A7B, SuffixType.HDD)) 255 | .toEqual(["h6lwdi91qluUyt3u"]); 256 | }); 257 | it("Dell HDD password for: 1234567890A-A95B", () => { 258 | expect(keygenDell("1234567890A", DellTag.TagA95B, SuffixType.HDD)) 259 | .toEqual(["qr0s6x4n"]); 260 | }); 261 | it("Dell HDD password for: 1234567890A-1D3B", () => { 262 | expect(keygenDell("1234567890A", DellTag.Tag1D3B, SuffixType.HDD)) 263 | .toEqual(["6JQ1WacHNNR0Taia"]); 264 | }); 265 | it("Dell HDD password for: 1234567890A-1F66", () => { 266 | expect(keygenDell("1234567890A", DellTag.Tag1F66, SuffixType.HDD)) 267 | .toEqual(["vP0M31x066Z7Rq9p"]); 268 | }); 269 | it("Dell HDD password for: 1234567890A-6FF1", () => { 270 | expect(keygenDell("1234567890A", DellTag.Tag6FF1, SuffixType.HDD)) 271 | .toEqual(["5enLLpM3Immfb8CK"]); 272 | }); 273 | it("Dell HDD password for: 1234567890A-1F5A", () => { 274 | expect(keygenDell("1234567890A", DellTag.Tag1F5A, SuffixType.HDD)) 275 | .toEqual(["L9IJjYoUIXeY5wOy"]); 276 | }); 277 | it("Dell HDD password for: 12345678901-1F5A", () => { 278 | expect(keygenDell("12345678901", DellTag.Tag1F5A, SuffixType.HDD)) 279 | .toEqual(["QwO5Dki1zeR1n1t2"]); 280 | }); 281 | it("Dell HDD password for: 12345678901-BF97", () => { 282 | expect(keygenDell("12345678901", DellTag.TagBF97, SuffixType.HDD)) 283 | .toEqual(["nDrmUU6U5DI9ZLMI"]); 284 | }); 285 | it("Dell HDD password for: 1234567890A-BF97", () => { 286 | expect(keygenDell("1234567890A", DellTag.TagBF97, SuffixType.HDD)) 287 | .toEqual(["pRrky3r9ryEPNNJz"]); 288 | }); 289 | it("Dell HDD password for: 234567890AB-BF97", () => { 290 | expect(keygenDell("234567890AB", DellTag.TagBF97, SuffixType.HDD)) 291 | .toEqual(["h2RDrReN37I1NLmr"]); 292 | }); 293 | it("Dell HDD password for: 1234567890A-E7A8", () => { 294 | expect(keygenDell("1234567890A", DellTag.TagE7A8, SuffixType.HDD).sort()) 295 | .toEqual(["rN2rE2RBQh[X00yr", "G1bFzRGzjXIGzr22"].sort()); 296 | }); 297 | it("Dell HDD password for: 1234567890B-E7A8", () => { 298 | expect(keygenDell("1234567890B", DellTag.TagE7A8, SuffixType.HDD).sort()) 299 | .toEqual(["Ic18yqyXXZI5Qj22", "kzzMazZrz53sRZJm"].sort()); 300 | }); 301 | }); 302 | 303 | describe("Test Dell BIOS", () => { 304 | it("Dell for 12345678901 is yyyyyhnn", () => { 305 | expect(hddOldSolver("12345678901")).toEqual(["yyyyyhnn"]); 306 | }); 307 | it("Dell for 1234567-595B", () => { 308 | expect(dellSolver("1234567-595B")).toEqual(["46rg65ky"]); 309 | }); 310 | it("Dell for: 1234567-1F66", () => { 311 | expect(dellSolver("1234567-1f66")).toEqual(["kIpTBzx0m3s10JDR"]); 312 | }); 313 | it("Dell for: 123456a-1F66", () => { 314 | // AFAIK Dell service tags is always uppercase 315 | // so this supposed to calculate password for 123456A-1F66 316 | expect(dellSolver("123456a-1f66")).toEqual(["5sS11TUKBmBOQKRS"]); 317 | }); 318 | it("Dell HDD for: 1234567890A-595B", () => { 319 | expect(dellHddSolver("1234567890A-595b")).toEqual(["nyoap4lq"]); 320 | }); 321 | it("Check bad dell tag", () => { 322 | expect(dellSolver("1234567-BAD1")).toEqual([]); 323 | expect(dellSolver("1234567-TOLONG")).toEqual([]); 324 | expect(dellHddSolver("1234567-SHORT")).toEqual([]); 325 | }); 326 | }); 327 | 328 | describe("Latitude 3540", () => { 329 | it("DES", () => { 330 | const data = Uint8Array.from("12345678".split("").map((v) => v.charCodeAt(0))); 331 | let enc = new DES(data); 332 | const encoded = Uint8Array.from([150, 208, 2, 136, 120, 213, 140, 137]); 333 | expect(enc.encryptBlock(data)).toEqual(encoded); 334 | expect(enc.decryptBlock(encoded)).toEqual(data); 335 | }); 336 | it("Latitude 3540 Keygen", () => { 337 | expect(latitude3540Keygen("5F3988D5E0ACE4BF", "7QH8602")).toEqual("98072364"); 338 | expect(latitude3540Keygen("76A7D90FD9563C5F", "3FN2J22")).toEqual("60485207"); 339 | expect(latitude3540Keygen("1B6DD24D26E7B566", "BJVDG22")).toEqual("99937880"); 340 | expect(latitude3540Keygen("1B6DD24D26E7C566", "BJVDG22")).toEqual(undefined); 341 | }); 342 | it("Dell Latitude 3540 Solver", () => { 343 | expect(dellLatitude3540Solver("5F3988D5E0ACE4BF-7QH8602")).toEqual(["98072364"]); 344 | expect(dellLatitude3540Solver("5F3988D5E0ACE4bF-7QH8602")).toEqual(["98072364"]); 345 | }); 346 | }); 347 | -------------------------------------------------------------------------------- /src/keygen/cryptoUtils.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | /* eslint-disable @typescript-eslint/no-shadow */ 3 | /* eslint-disable no-shadow */ 4 | import JSBI from "jsbi"; 5 | 6 | export class Crc32 { 7 | 8 | public static readonly IEEE_POLYNOMIAL = 0xEDB88320; 9 | private static tableCache: {[key: string]: Uint32Array} = {}; 10 | 11 | private table: Uint32Array; 12 | private crc: number; 13 | 14 | constructor(poly?: number) { 15 | if (poly === undefined) { 16 | poly = Crc32.IEEE_POLYNOMIAL; 17 | } 18 | this.table = Crc32.getCRC32Table(poly); 19 | this.crc = 0; 20 | } 21 | 22 | private static makeTable(poly: number): Uint32Array { 23 | let crcTable = new Uint32Array(256); 24 | for (let i = 0; i < 256; i++) { 25 | let crc = i; 26 | for (let j = 0; j < 8; j++) { 27 | crc = (crc & 1) ? (poly ^ (crc >>> 1)) : (crc >>> 1); 28 | } 29 | crcTable[i] = crc; 30 | } 31 | return crcTable; 32 | } 33 | 34 | private static getCRC32Table(poly: number): Uint32Array { 35 | const key = poly.toString(10); 36 | const val = Crc32.tableCache[key]; 37 | if (val !== undefined && val instanceof Uint32Array) { 38 | return val; 39 | } else { 40 | const table = Crc32.makeTable(poly); 41 | // save only IEEE table 42 | if (poly === Crc32.IEEE_POLYNOMIAL) { 43 | Crc32.tableCache[key] = table; 44 | } 45 | return table; 46 | } 47 | } 48 | 49 | public reset() { 50 | this.crc = 0; 51 | } 52 | 53 | public update(input: Uint8Array | number[]) { 54 | this.crc ^= -1; 55 | 56 | for (let i = 0; i < input.length; i++) { 57 | const b = input[i] & 0xFF; 58 | const index = (this.crc ^ b) & 0xFF; 59 | this.crc = (this.crc >>> 8) ^ this.table[index]; 60 | } 61 | 62 | this.crc = ((this.crc ^ (-1)) >>> 0); 63 | } 64 | 65 | public digest(): number { 66 | return this.crc; 67 | } 68 | 69 | public hexdigest(): string { 70 | return ("0".repeat(8) + this.digest().toString(16)).slice(-8); 71 | } 72 | } 73 | 74 | export class Crc64 { 75 | // ECMA 182 0xC96C5795D7870F42 76 | public static readonly ECMA_POLYNOMIAL = JSBI.BigInt("14514072000185962306"); 77 | 78 | private static tableCache: {[key: string]: JSBI[]} = {}; 79 | 80 | public readonly polynom: JSBI; 81 | 82 | private table: JSBI[]; 83 | private crc: JSBI; 84 | 85 | constructor(poly: JSBI, table?: JSBI[]) { 86 | this.polynom = poly; 87 | if (table && Array.isArray(table)) { 88 | this.table = table; 89 | } else { 90 | this.table = Crc64.getCRC64Table(poly); 91 | } 92 | this.crc = JSBI.BigInt(0); 93 | } 94 | 95 | private static makeTable(poly: JSBI): JSBI[] { 96 | let table: JSBI[] = []; 97 | for (let i = 0; i < 256; i++) { 98 | let crc: JSBI = JSBI.BigInt(i); 99 | for (let j = 0; j < 8; j++) { 100 | if (JSBI.EQ(JSBI.bitwiseAnd(crc, JSBI.BigInt(1)), 1)) { 101 | crc = JSBI.bitwiseXor(JSBI.signedRightShift(crc, JSBI.BigInt(1)), poly); 102 | } else { 103 | crc = JSBI.signedRightShift(crc, JSBI.BigInt(1)); 104 | } 105 | } 106 | table.push(JSBI.asUintN(64, crc)); 107 | } 108 | return table; 109 | } 110 | private static getCRC64Table(poly: JSBI) { 111 | const key = poly.toString(10); 112 | const val = Crc64.tableCache[key]; 113 | if (val !== undefined && Array.isArray(val)) { 114 | return val; 115 | } else { 116 | const table = Crc64.makeTable(poly); 117 | // save only ECMA table 118 | if (JSBI.EQ(poly, Crc64.ECMA_POLYNOMIAL)) { 119 | Crc64.tableCache[key] = table; 120 | } 121 | return table; 122 | } 123 | } 124 | 125 | public reset() { 126 | this.crc = JSBI.BigInt(0); 127 | } 128 | 129 | public update(input: Uint8Array | number[]) { 130 | for (let i = 0; i < input.length; i++) { 131 | const b = input[i] & 0xFF; 132 | const index = JSBI.toNumber(JSBI.asUintN(8, JSBI.bitwiseXor(this.crc, JSBI.BigInt(b)))); 133 | const temp = JSBI.bitwiseXor(this.table[index], JSBI.signedRightShift(this.crc, JSBI.BigInt(8))); 134 | this.crc = JSBI.asUintN(64, temp); 135 | } 136 | } 137 | 138 | public digest(): JSBI { 139 | return this.crc; 140 | } 141 | 142 | public hexdigest(): string { 143 | return ("0".repeat(16) + this.digest().toString(16)).slice(-16); 144 | } 145 | } 146 | 147 | export class Sha256 { 148 | private static readonly SHA256_CONSTANTS: Uint32Array = Uint32Array.from([ 149 | 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 150 | 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 151 | 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 152 | 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 153 | 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 154 | 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 155 | 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 156 | 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, 157 | 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 158 | 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 159 | 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 160 | 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 161 | 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 162 | 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 163 | 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 164 | 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 165 | ]); 166 | 167 | private static readonly SHA256_IV: Uint32Array = Uint32Array.from([ 168 | 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 169 | 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 170 | ]); 171 | 172 | private state: Uint32Array; 173 | private data: Uint8Array; 174 | private bitlen: JSBI; 175 | private datalen: number; 176 | 177 | constructor(input?: Uint8Array) { 178 | this.bitlen = JSBI.BigInt(0); 179 | this.datalen = 0; 180 | this.data = new Uint8Array(64); 181 | this.state = Sha256.SHA256_IV.slice(); 182 | 183 | if (input && (input instanceof Uint8Array || Array.isArray(input))) { 184 | this.update(input); 185 | } 186 | } 187 | 188 | public update(input: Uint8Array) { 189 | for (let i = 0; i < input.length; i++) { 190 | const b = input[i]; 191 | this.data[this.datalen] = b; 192 | this.datalen++; 193 | 194 | if (this.datalen >= 64) { 195 | this.transform(); 196 | this.bitlen = JSBI.add(this.bitlen, JSBI.BigInt(512)); 197 | this.datalen = 0; 198 | } 199 | } 200 | } 201 | 202 | public digest(): Uint8Array { 203 | let item = this.copy(); 204 | return item.final(); 205 | } 206 | 207 | public hexdigest() { 208 | return Array.from(this.digest()).map((x) => { 209 | x = x & 0xFF; 210 | return (x < 0xf) ? "0" + x.toString(16) : x.toString(16); 211 | }).join(""); 212 | } 213 | 214 | private transform() { 215 | let m: Uint32Array = new Uint32Array(64); 216 | 217 | function ROTRIGHT(a: number, b: number): number { 218 | return (a >>> b) | (a << (32 - b)); 219 | } 220 | function CH(a: number, b: number, c: number): number { 221 | return (a & b) ^ (~a & c); 222 | } 223 | function MAJ(a: number, b: number, c: number): number { 224 | return (a & b) ^ (a & c) ^ (b & c); 225 | } 226 | function EP0(a: number) { 227 | return ROTRIGHT(a, 2) ^ ROTRIGHT(a, 13) ^ ROTRIGHT(a, 22); 228 | } 229 | function EP1(a: number) { 230 | return ROTRIGHT(a, 6) ^ ROTRIGHT(a, 11) ^ ROTRIGHT(a, 25); 231 | } 232 | function SIG0(a: number): number { 233 | return ROTRIGHT(a, 7) ^ ROTRIGHT(a, 18) ^ (a >>> 3); 234 | } 235 | function SIG1(a: number): number { 236 | return ROTRIGHT(a, 17) ^ ROTRIGHT(a, 19) ^ (a >>> 10); 237 | } 238 | for (let i = 0, j = 0; i < 16; i++, j += 4) { 239 | m[i] = (this.data[j] << 24) | (this.data[j + 1] << 16) | (this.data[j + 2] << 8) | 240 | (this.data[j + 3]); 241 | } 242 | for (let i = 16; i < 64; i++) { 243 | m[i] = (SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16]) >>> 0; 244 | } 245 | let [a, b, c, d, e, f, g, h] = this.state; 246 | for (let i = 0; i < 64; i++) { 247 | const t1 = h + EP1(e) + CH(e, f, g) + Sha256.SHA256_CONSTANTS[i] + m[i]; 248 | const t2 = EP0(a) + MAJ(a, b, c); 249 | h = g; 250 | g = f; 251 | f = e; 252 | e = (d + t1) >>> 0; 253 | d = c; 254 | c = b; 255 | b = a; 256 | a = (t1 + t2) >>> 0; 257 | } 258 | this.state[0] += a; 259 | this.state[1] += b; 260 | this.state[2] += c; 261 | this.state[3] += d; 262 | this.state[4] += e; 263 | this.state[5] += f; 264 | this.state[6] += g; 265 | this.state[7] += h; 266 | } 267 | 268 | private copy(): Sha256 { 269 | let item = new Sha256(); 270 | item.state = this.state.slice(); 271 | item.data = this.data.slice(); 272 | item.bitlen = this.bitlen; 273 | item.datalen = this.datalen; 274 | return item; 275 | } 276 | 277 | private final(): Uint8Array { 278 | let i = this.datalen & 63; 279 | if (this.datalen < 56) { 280 | this.data[i++] = 0x80; 281 | while (i < 56) { 282 | this.data[i++] = 0; 283 | } 284 | } else { 285 | this.data[i++] = 0x80; 286 | while (i < 64) { 287 | this.data[i++] = 0; 288 | } 289 | this.transform(); 290 | for (let i = 0; i < 56; i++) { 291 | this.data[i] = 0; 292 | } 293 | } 294 | this.bitlen = JSBI.add(this.bitlen, JSBI.BigInt(this.datalen * 8)); 295 | for (let i = 63, j = 0; i >= 56; i--, j += 8) { 296 | // val = (this.bitlen >> j) & 0xFF 297 | const val = JSBI.asUintN(8, JSBI.signedRightShift(this.bitlen, JSBI.BigInt(j))); 298 | this.data[i] = JSBI.toNumber(val); 299 | } 300 | this.transform(); 301 | let hash = new Uint8Array(32); 302 | for (let i = 0; i < 4; i++) { 303 | for (let j = 0; j < 8; j++) { 304 | hash[i + j * 4] = (this.state[j] >>> (24 - i * 8)) & 0xFF; 305 | } 306 | } 307 | return hash; 308 | } 309 | } 310 | 311 | export class AES128 { 312 | // AES128 ECB mode 313 | private static readonly NB = 4; 314 | private static readonly NK = 4; 315 | private static readonly NR = 10; 316 | 317 | private static readonly sbox: Uint8Array = Uint8Array.from([ 318 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 319 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 320 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 321 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 322 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 323 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 324 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 325 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 326 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 327 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 328 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 329 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 330 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 331 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 332 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 333 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 334 | ]); 335 | 336 | private static readonly rcon: Uint8Array = Uint8Array.from([ 337 | 0x8D, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A 338 | ]); 339 | 340 | private roundKey: Uint8Array; 341 | 342 | constructor(key: Uint8Array) { 343 | this.roundKey = AES128.keyExpansion(key); 344 | } 345 | 346 | private static keyExpansion(key: Uint8Array): Uint8Array { 347 | if (key.length !== 16) { 348 | throw new Error("Key should be 16 bytes"); 349 | } 350 | 351 | let roundKey = new Uint8Array(176); 352 | // first round key is the key itself 353 | for (let i = 0; i < AES128.NK * 4; i++) { 354 | roundKey[i] = key[i]; 355 | } 356 | let temp = new Uint8Array(4); 357 | // all other round keys generated from previous ones 358 | for (let i = AES128.NK; i < AES128.NB * (AES128.NR + 1); i++) { 359 | const k = (i - 1) * 4; 360 | temp[0] = roundKey[k + 0]; 361 | temp[1] = roundKey[k + 1]; 362 | temp[2] = roundKey[k + 2]; 363 | temp[3] = roundKey[k + 3]; 364 | 365 | if (i % AES128.NK === 0) { 366 | // AES RotWord() 367 | { 368 | const first = temp[0]; 369 | temp[0] = temp[1]; 370 | temp[1] = temp[2]; 371 | temp[2] = temp[3]; 372 | temp[3] = first; 373 | } 374 | // AES SubWord() 375 | { 376 | temp[0] = AES128.sbox[temp[0]]; 377 | temp[1] = AES128.sbox[temp[1]]; 378 | temp[2] = AES128.sbox[temp[2]]; 379 | temp[3] = AES128.sbox[temp[3]]; 380 | } 381 | 382 | temp[0] ^= AES128.rcon[i / AES128.NK]; 383 | } 384 | { 385 | const j = i * 4; 386 | const k = (i - AES128.NK) * 4; 387 | roundKey[j + 0] = roundKey[k + 0] ^ temp[0]; 388 | roundKey[j + 1] = roundKey[k + 1] ^ temp[1]; 389 | roundKey[j + 2] = roundKey[k + 2] ^ temp[2]; 390 | roundKey[j + 3] = roundKey[k + 3] ^ temp[3]; 391 | } 392 | } 393 | return roundKey; 394 | } 395 | 396 | private static addRoundKey(round: number, state: Uint8Array, roundKey: Uint8Array) { 397 | for (let i = 0; i < 4; i++) { 398 | for (let j = 0; j < 4; j++) { 399 | state[i * 4 + j] ^= roundKey[(round * AES128.NB * 4) + (i * AES128.NB) + j]; 400 | state[i * 4 + j] &= 0xFF; 401 | } 402 | } 403 | } 404 | 405 | private static subBytes(state: Uint8Array) { 406 | for (let i = 0; i < 4; i++) { 407 | for (let j = 0; j < 4; j++) { 408 | state[j * 4 + i] = AES128.sbox[state[j * 4 + i]]; 409 | } 410 | } 411 | } 412 | 413 | private static shiftRows(state: Uint8Array) { 414 | // rotate first row 1 columns to left 415 | let temp: number = state[0 * 4 + 1]; 416 | state[0 * 4 + 1] = state[1 * 4 + 1]; 417 | state[1 * 4 + 1] = state[2 * 4 + 1]; 418 | state[2 * 4 + 1] = state[3 * 4 + 1]; 419 | state[3 * 4 + 1] = temp; 420 | // rotate second row 2 columns to left 421 | temp = state[0 * 4 + 2]; 422 | state[0 * 4 + 2] = state[2 * 4 + 2]; 423 | state[2 * 4 + 2] = temp; 424 | temp = state[1 * 4 + 2]; 425 | state[1 * 4 + 2] = state[3 * 4 + 2]; 426 | state[3 * 4 + 2] = temp; 427 | // rotate thirdd row 3 columns to left 428 | temp = state[0 * 4 + 3]; 429 | state[0 * 4 + 3] = state[3 * 4 + 3]; 430 | state[3 * 4 + 3] = state[2 * 4 + 3]; 431 | state[2 * 4 + 3] = state[1 * 4 + 3]; 432 | state[1 * 4 + 3] = temp; 433 | } 434 | 435 | private static mixColumns(state: Uint8Array) { 436 | let tmp1: number; 437 | let tmp2: number; 438 | 439 | function xtime(x: number): number { 440 | return (x << 1) ^ (((x >>> 7) & 1) * 0x1B); 441 | } 442 | 443 | for (let i = 0; i < 4; i++) { 444 | const t = state[i * 4 + 0]; 445 | tmp1 = state[i * 4 + 0] ^ state[i * 4 + 1] ^ state[i * 4 + 2] ^ state[i * 4 + 3]; 446 | tmp2 = xtime(state[i * 4 + 0] ^ state[i * 4 + 1]); 447 | state[i * 4 + 0] ^= tmp2 ^ tmp1; 448 | tmp2 = xtime(state[i * 4 + 1] ^ state[i * 4 + 2]); 449 | state[i * 4 + 1] ^= tmp2 ^ tmp1; 450 | tmp2 = xtime(state[i * 4 + 2] ^ state[i * 4 + 3]); 451 | state[i * 4 + 2] ^= tmp2 ^ tmp1; 452 | tmp2 = xtime(state[i * 4 + 3] ^ t); 453 | state[i * 4 + 3] ^= tmp2 ^ tmp1; 454 | } 455 | } 456 | 457 | public encryptBlock(input: Uint8Array): Uint8Array { 458 | if (input.length !== 16) { 459 | throw new Error("Invalid block length"); 460 | } 461 | let state = input.slice(); 462 | AES128.addRoundKey(0, state, this.roundKey); 463 | for (let round = 1; ; round++) { 464 | AES128.subBytes(state); 465 | AES128.shiftRows(state); 466 | if (round === 10) { 467 | break; 468 | } 469 | AES128.mixColumns(state); 470 | AES128.addRoundKey(round, state, this.roundKey); 471 | } 472 | AES128.addRoundKey(AES128.NR, state, this.roundKey); 473 | return state; 474 | } 475 | } 476 | -------------------------------------------------------------------------------- /src/keygen/dell/encode.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-bitwise */ 2 | import { DellTag } from "./types"; 3 | 4 | const md5magic = Uint32Array.from([ 5 | 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 6 | 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, 7 | 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 8 | 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, 9 | 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 10 | 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, 11 | 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 12 | 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, 13 | 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 14 | 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, 15 | 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, 16 | 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, 17 | 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 18 | 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, 19 | 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 20 | 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 21 | ]); 22 | 23 | const md5magic2 = Uint32Array.from([ 24 | 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 25 | 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, 26 | 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 27 | 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, 28 | 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 29 | 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, 30 | 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 31 | 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, 32 | 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, 33 | 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 34 | 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, 35 | 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 36 | 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, 37 | 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 38 | 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, 39 | 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039 40 | ]); 41 | 42 | const rotationTable = [ 43 | [7, 12, 17, 22], 44 | [5, 9, 14, 20], 45 | [4, 11, 16, 23], 46 | [6, 10, 15, 21] 47 | ]; 48 | 49 | const initialData = [ 50 | 0x67452301 | 0, 51 | 0xEFCDAB89 | 0, 52 | 0x98BADCFE | 0, 53 | 0x10325476 | 0 54 | ]; 55 | 56 | type SumFunction = (a: number, b: number) => number; 57 | type EncFunction = (a: number, b: number, c: number) => number; 58 | interface Encoder { 59 | encode(data: number[]): number[]; 60 | } 61 | 62 | // Maybe optimize ? return (((param2 >>> (0x20 - param7))) | (param2 << param7)) + num1; 63 | function rol(x: number, bitsrot: number): number { 64 | // n >>> 0 used to convert signed number to unsigned 65 | // (unsigned(x) >> (32 - bitsrot)) | (unsigned(x) << bitsrot); 66 | return ((x >>> 0) / Math.pow(2, 32 - bitsrot)) | (((x >>> 0) << bitsrot) | 0 ); 67 | } 68 | 69 | function encF2(num1: number, num2: number, num3: number): number { 70 | return ((num3 ^ num2) & num1) ^ num3; 71 | } 72 | 73 | function encF3(num1: number, num2: number, num3: number): number { 74 | return ((num1 ^ num2) & num3) ^ num2; 75 | } 76 | 77 | function encF4(num1: number, num2: number, num3: number): number { 78 | return (num2 ^ num1) ^ num3; 79 | } 80 | 81 | function encF5(num1: number, num2: number, num3: number): number { 82 | return (num1 | ~num3) ^ num2; 83 | } 84 | 85 | function encF1(num1: number, num2: number): number { 86 | return (num1 + num2) | 0; 87 | } 88 | 89 | // Negative functions 90 | function encF1N(num1: number, num2: number): number { 91 | return (num1 - num2) | 0; 92 | } 93 | 94 | function encF2N(num1: number, num2: number, num3: number): number { 95 | return encF2(num1, num2, ~num3); 96 | } 97 | 98 | function encF4N(num1: number, num2: number, num3: number): number { 99 | return encF4(num1, ~num2, num3); 100 | } 101 | 102 | function encF5N(num1: number, num2: number, num3: number): number { 103 | return encF5(~num1, num2, num3); 104 | } 105 | 106 | class Tag595BEncoder { 107 | protected encBlock: number[]; 108 | protected encData: number[]; 109 | protected A: number; 110 | protected B: number; 111 | protected C: number; 112 | protected D: number; 113 | protected f1: SumFunction = encF1N; 114 | protected f2: EncFunction = encF2N; 115 | protected f3: EncFunction = encF3; 116 | protected f4: EncFunction = encF4N; 117 | protected f5: EncFunction = encF5N; 118 | protected readonly md5table: Uint32Array = md5magic; 119 | 120 | constructor(encBlock: number[]) { 121 | this.encBlock = encBlock; 122 | this.encData = this.initialData(); 123 | this.A = this.encData[0]; 124 | this.B = this.encData[1]; 125 | this.C = this.encData[2]; 126 | this.D = this.encData[3]; 127 | } 128 | 129 | public static encode(encBlock: number[]): number[] { 130 | let obj = new this(encBlock); 131 | obj.makeEncode(); 132 | return obj.result(); 133 | } 134 | 135 | public makeEncode(): void { 136 | let t: number = 0; 137 | for (let i = 0; i < 64; i++) { 138 | switch (i >> 4) { 139 | case 0: 140 | t = this.calculate(this.f2, i & 15, i); // Use half byte 141 | break; 142 | case 1: 143 | t = this.calculate(this.f3, (i * 5 + 1) & 15, i); 144 | break; 145 | case 2: 146 | t = this.calculate(this.f4, (i * 3 + 5) & 15, i); 147 | break; 148 | case 3: 149 | t = this.calculate(this.f5, (i * 7) & 15, i); 150 | break; 151 | } 152 | this.A = this.D; 153 | this.D = this.C; 154 | this.C = this.B; 155 | this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; 156 | } 157 | 158 | this.incrementData(); 159 | } 160 | 161 | public result(): number[] { 162 | return this.encData.map((v) => (v | 0) >>> 0); 163 | } 164 | 165 | protected initialData(): number[] { 166 | return initialData.slice(); 167 | } 168 | 169 | protected calculate(func: EncFunction, key1: number, key2: number): number { 170 | let temp = func(this.B, this.C, this.D); 171 | return this.A + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0; 172 | } 173 | 174 | protected incrementData() { 175 | this.encData[0] += this.A; 176 | this.encData[1] += this.B; 177 | this.encData[2] += this.C; 178 | this.encData[3] += this.D; 179 | 180 | this.encData.forEach((val, index) => { 181 | this.encData[index] = val | 0; 182 | }); 183 | } 184 | } 185 | 186 | class TagD35BEncoder extends Tag595BEncoder { 187 | protected f1 = encF1; 188 | protected f2 = encF2; 189 | protected f3 = encF3; 190 | protected f4 = encF4; 191 | protected f5 = encF5; 192 | } 193 | 194 | class Tag1D3BEncoder extends Tag595BEncoder { 195 | 196 | public makeEncode(): void { 197 | for (let j = 0; j < 21; j++) { 198 | this.A |= 0x97; 199 | this.B ^= 0x8; 200 | this.C |= 0x60606161 - j; 201 | this.D ^= 0x50501010 + j; 202 | super.makeEncode(); 203 | } 204 | } 205 | } 206 | 207 | class Tag1F66Encoder extends Tag595BEncoder { 208 | protected md5table = md5magic2; 209 | 210 | public makeEncode(): void { 211 | let t: number = 0; 212 | 213 | for (let j = 0; j < 17; j++) { 214 | this.A |= 0x100097; 215 | this.B ^= 0xA0008; 216 | this.C |= 0x60606161 - j; 217 | this.D ^= 0x50501010 + j; 218 | 219 | for (let i = 0; i < 64; i++) { 220 | switch (i >> 4) { 221 | case 0: 222 | t = this.calculate(this.f2, i & 15, i + 16 | 0); 223 | break; 224 | case 1: 225 | t = this.calculate(this.f3, (i * 5 + 1) & 15, i + 32 | 0); 226 | break; 227 | case 2: 228 | t = this.calculate(this.f4, (i * 3 + 5) & 15, i - 2 * (i & 12) + 12); 229 | break; 230 | case 3: 231 | t = this.calculate(this.f5, (i * 7) & 15, 2 * (i & 3) - (i & 15) + 12); 232 | break; 233 | } 234 | this.A = this.D; 235 | this.D = this.C; 236 | this.C = this.B; 237 | this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; 238 | } 239 | 240 | this.incrementData(); 241 | } 242 | 243 | for (let j = 0; j < 21; j++) { 244 | 245 | this.A |= 0x97; 246 | this.B ^= 0x8; 247 | this.C |= 0x50501010 - j; 248 | this.D ^= 0x60606161 + j; 249 | 250 | for (let i = 0; i < 64; i++) { 251 | switch (i >> 4) { 252 | case 0: 253 | t = this.calculate(this.f4, (i * 3 + 5) & 15, 2 * (i & 3) - i + 44); 254 | break; 255 | case 1: 256 | t = this.calculate(this.f5, (i * 7) & 15, 2 * (i & 3) - i + 76); 257 | break; 258 | case 2: 259 | t = this.calculate(this.f2, i & 15, (i & 15) | 0); 260 | break; 261 | case 3: 262 | t = this.calculate(this.f3, (i * 5 + 1) & 15, i - 32 | 0); 263 | break; 264 | } 265 | let g = (i >> 4) + 2; 266 | this.A = this.D; 267 | this.D = this.C; 268 | this.C = this.B; 269 | this.B = rol(t, rotationTable[g & 3][i & 3]) + this.B | 0; 270 | } 271 | 272 | this.incrementData(); 273 | } 274 | } 275 | } 276 | 277 | class Tag6FF1Encoder extends Tag595BEncoder { 278 | protected md5table = md5magic2; 279 | 280 | protected counter1: number = 23; 281 | 282 | public makeEncode(): void { 283 | let t: number = 0; 284 | 285 | for (let j = 0; j < this.counter1; j++) { 286 | this.A |= 0xA08097; 287 | this.B ^= 0xA010908; 288 | this.C |= 0x60606161 - j; 289 | this.D ^= 0x50501010 + j; 290 | 291 | for (let i = 0; i < 64; i++) { 292 | let k = (i & 15) - ((i & 12) << 1) + 12; 293 | switch (i >> 4) { 294 | case 0: 295 | t = this.calculate(this.f2, i & 15, i + 32 | 0); 296 | break; 297 | case 1: 298 | t = this.calculate(this.f3, (i * 5 + 1) & 15, (i & 15) | 0); 299 | break; 300 | case 2: 301 | t = this.calculate(this.f4, (i * 3 + 5) & 15, k + 16 | 0); 302 | break; 303 | case 3: 304 | t = this.calculate(this.f5, (i * 7) & 15, k + 48 | 0); 305 | break; 306 | } 307 | this.A = this.D; 308 | this.D = this.C; 309 | this.C = this.B; 310 | this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; 311 | } 312 | 313 | this.incrementData(); 314 | } 315 | 316 | for (let j = 0; j < 17; j++) { 317 | this.A |= 0x100097; 318 | this.B ^= 0xA0008; 319 | this.C |= 0x50501010 - j; 320 | this.D ^= 0x60606161 + j; 321 | 322 | for (let i = 0; i < 64; i++) { 323 | let k = (i & 15) - ((i & 12) << 1) + 12; 324 | switch (i >> 4) { 325 | case 0: 326 | t = this.calculate(this.f4, ((i & 15) * 3 + 5) & 15, k + 16); 327 | break; 328 | case 1: 329 | t = this.calculate(this.f5, ((i & 3) * 7 + (i & 12) + 4) & 15, (i & 15) + 32); 330 | break; 331 | case 2: 332 | t = this.calculate(this.f2, k & 15, k); 333 | break; 334 | case 3: 335 | t = this.calculate(this.f3, ((i & 15) * 5 + 1) & 15, (i & 15) + 48); 336 | break; 337 | } 338 | let g = (i >> 4) + 2; 339 | this.A = this.D; 340 | this.D = this.C; 341 | this.C = this.B; 342 | this.B = rol(t, rotationTable[g & 3][i & 3]) + this.B | 0; 343 | } 344 | 345 | this.incrementData(); 346 | } 347 | } 348 | } 349 | 350 | class Tag1F5AEncoder extends Tag595BEncoder { 351 | protected readonly md5table = md5magic2; 352 | 353 | public makeEncode(): void { 354 | let t: number = 0; 355 | for (let i = 0; i < 5; i++) { 356 | for (let j = 0; j < 64; j++) { 357 | let k = 12 + (j & 3) - (j & 12); 358 | switch (j >> 4) { 359 | case 0: 360 | t = this.calculate(this.f2, j & 15, j); 361 | break; 362 | case 1: 363 | t = this.calculate(this.f3, (j * 5 + 1) & 15, j); 364 | break; 365 | case 2: 366 | t = this.calculate(this.f4, (j * 3 + 5) & 15, k + 0x20); 367 | break; 368 | case 3: 369 | t = this.calculate(this.f5, (j * 7) & 15, k + 0x30); 370 | break; 371 | } 372 | this.B = this.D; 373 | this.D = this.A; 374 | this.A = this.C; 375 | this.C = rol(t, rotationTable[j >> 4][j & 3]) + this.C | 0; 376 | } 377 | 378 | this.incrementData(); 379 | } 380 | } 381 | 382 | protected incrementData() { 383 | this.encData[0] += this.B; 384 | this.encData[1] += this.C; 385 | this.encData[2] += this.A; 386 | this.encData[3] += this.D; 387 | 388 | this.encData.forEach((val, index) => { 389 | this.encData[index] = val | 0; 390 | }); 391 | } 392 | 393 | protected calculate(func: EncFunction, key1: number, key2: number): number { 394 | let temp = func(this.C, this.A, this.D); 395 | return this.B + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0; 396 | } 397 | } 398 | 399 | class TagBF97Encoder extends Tag6FF1Encoder { 400 | protected counter1 = 31; 401 | } 402 | 403 | export class TagE7A8Encoder extends Tag595BEncoder { 404 | protected readonly md5table = md5magic2; 405 | 406 | protected readonly loopParams = [17, 13, 12, 8]; 407 | 408 | protected readonly encodeParams = Uint32Array.from([ 409 | 0x50501010, 0xA010908, 0xA08097, 0x60606161, 410 | 0x60606161, 0xA0008, 0x100097, 0x50501010 411 | ]); 412 | 413 | public makeEncode(): void { 414 | 415 | for (let p = 0; p < this.loopParams[0]; p++) { 416 | this.A |= this.encodeParams[0]; 417 | this.B ^= this.encodeParams[1]; 418 | this.C |= this.encodeParams[2] - p; 419 | this.D ^= this.encodeParams[3] + p; 420 | 421 | for (let j = 0; j < this.loopParams[2]; j += 4) { 422 | this.shortcut(this.f2, j, j + 32, 0, [0, 1, 2, 3]); 423 | } 424 | 425 | for (let j = 0; j < this.loopParams[2]; j += 4) { 426 | this.shortcut(this.f3, j, j, 1, [1, -2, -1, 0]); 427 | } 428 | 429 | for (let j = this.loopParams[3]; j > 3; j -= 4) { 430 | this.shortcut(this.f4, j, j + 16, 2, [-3, -4, -1, 2]); 431 | } 432 | 433 | for (let j = this.loopParams[3]; j > 3 ; j -= 4) { 434 | this.shortcut(this.f5, j, j + 48, 3, [2, 3, 2, -3]); 435 | } 436 | 437 | this.incrementData(); 438 | } 439 | 440 | for (let p = 0; p < this.loopParams[1]; p++) { 441 | this.A |= this.encodeParams[4]; 442 | this.B ^= this.encodeParams[5]; 443 | this.C |= this.encodeParams[6] - p; 444 | this.D ^= this.encodeParams[7] + p; 445 | 446 | for (let j = this.loopParams[3]; j > 3 ; j -= 4) { 447 | this.shortcut(this.f4, j, j + 16, 2, [-3, -4, -1, 2]); 448 | } 449 | 450 | for (let j = 0; j < this.loopParams[2]; j += 4) { 451 | this.shortcut(this.f5, j, j + 32, 3, [2, 3, 2, -3]); 452 | } 453 | 454 | for (let j = this.loopParams[3]; j > 0 ; j -= 4) { 455 | 456 | this.shortcut(this.f2, j, j, 0, [0, 1, 2, 3]); 457 | 458 | } 459 | 460 | for (let j = 0; j < this.loopParams[2]; j += 4) { 461 | this.shortcut(this.f3, j, j + 48, 1, [1, -2, 3, 0]); 462 | } 463 | 464 | this.incrementData(); 465 | } 466 | } 467 | 468 | protected initialData(): number[] { 469 | return [0, 0, 0, 0]; 470 | } 471 | 472 | private shortcut(fun: EncFunction, j: number, md5_index: number, rot_index: number, indexes: number[]): void { 473 | 474 | for (let i = 0; i < 4; i++) { 475 | const t = this.calculate(fun, (j + indexes[i]) & 7, i + md5_index); 476 | this.A = this.D; 477 | this.D = this.C; 478 | this.C = this.B; 479 | this.B = rol(t, rotationTable[rot_index][i]) + this.B | 0; 480 | } 481 | } 482 | } 483 | 484 | export class TagE7A8EncoderSecond extends TagE7A8Encoder { 485 | 486 | // this model has bug and it goes over the array limit 487 | protected readonly md5table = (() => { 488 | const overfillArr = [ 489 | 0xa0008 ^ 0x6d2f93a5, 0xa08097 ^ 0x6d2f93a5, 0xa010908 ^ 0x6d2f93a5, 0x60606161 ^ 0x6d2f93a5 490 | ]; 491 | let arr = new Uint32Array(md5magic2.length + overfillArr.length); 492 | arr.set(md5magic2); 493 | arr.set(overfillArr, md5magic2.length); 494 | return arr; 495 | })(); 496 | 497 | protected readonly loopParams = [17, 13, 12, 16]; 498 | } 499 | 500 | const encoders: {readonly [P in DellTag]: Encoder} = { 501 | "595B": Tag595BEncoder, 502 | "2A7B": Tag595BEncoder, // same as 595B 503 | "A95B": Tag595BEncoder, // same as 595B 504 | "1D3B": Tag1D3BEncoder, 505 | "D35B": TagD35BEncoder, 506 | "1F66": Tag1F66Encoder, 507 | "6FF1": Tag6FF1Encoder, 508 | "1F5A": Tag1F5AEncoder, 509 | "BF97": TagBF97Encoder, 510 | "E7A8": TagE7A8Encoder 511 | }; 512 | 513 | export function blockEncode(encBlock: number[], tag: DellTag): number[] { 514 | return encoders[tag].encode(encBlock); 515 | } 516 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------