mirror of
https://github.com/bacher09/pwgen-for-bios.git
synced 2024-09-19 07:18:53 -04:00
Switch code linter to eslint and update deps
Tslint is outdated for quite a while and has been replaced by eslint which now can work with TypeScript as well. This also updates dependencies and fixes all linting errors.
This commit is contained in:
parent
ee5f3a8d0d
commit
ea85f539d4
21 changed files with 5626 additions and 5550 deletions
178
.eslintrc.js
Normal file
178
.eslintrc.js
Normal file
|
@ -0,0 +1,178 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"browser": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"eslint-plugin-no-null",
|
||||
"eslint-plugin-jsdoc",
|
||||
"eslint-plugin-prefer-arrow",
|
||||
"@typescript-eslint",
|
||||
],
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"semi": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}],
|
||||
"@typescript-eslint/semi": ["error"],
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{
|
||||
"default": "array"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"Object": {
|
||||
"message": "Avoid using the `Object` type. Did you mean `object`?"
|
||||
},
|
||||
"Function": {
|
||||
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
|
||||
},
|
||||
"Boolean": {
|
||||
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
|
||||
},
|
||||
"Number": {
|
||||
"message": "Avoid using the `Number` type. Did you mean `number`?"
|
||||
},
|
||||
"String": {
|
||||
"message": "Avoid using the `String` type. Did you mean `string`?"
|
||||
},
|
||||
"Symbol": {
|
||||
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/dot-notation": "error",
|
||||
"@typescript-eslint/indent": "error",
|
||||
"@typescript-eslint/member-ordering": "error",
|
||||
"@typescript-eslint/naming-convention": ["error",
|
||||
{"selector": "function","format": ["PascalCase", "camelCase"]},
|
||||
{"selector": "classProperty","format": ["camelCase", "UPPER_CASE"]}
|
||||
],
|
||||
"@typescript-eslint/no-empty-function": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-parameter-properties": "off",
|
||||
"@typescript-eslint/no-shadow": [
|
||||
"error",
|
||||
{
|
||||
"hoist": "all"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-unused-expressions": "error",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "off", // TODO: maybe enable it ?
|
||||
"@typescript-eslint/prefer-function-type": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||
"@typescript-eslint/triple-slash-reference": [
|
||||
"error",
|
||||
{
|
||||
"path": "always",
|
||||
"types": "prefer-import",
|
||||
"lib": "always"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/unified-signatures": "error",
|
||||
"comma-dangle": "off",
|
||||
"complexity": "off",
|
||||
"constructor-super": "error",
|
||||
"dot-notation": "error",
|
||||
"eol-last": "error",
|
||||
"eqeqeq": [
|
||||
"error",
|
||||
"smart"
|
||||
],
|
||||
"guard-for-in": "error",
|
||||
"id-denylist": [
|
||||
"error",
|
||||
"any",
|
||||
"Number",
|
||||
"number",
|
||||
"String",
|
||||
"string",
|
||||
"Boolean",
|
||||
"boolean",
|
||||
"Undefined",
|
||||
"undefined"
|
||||
],
|
||||
"id-match": "error",
|
||||
"indent": "off",
|
||||
"@typescript-eslint/indent": [
|
||||
"error",
|
||||
4,
|
||||
{
|
||||
"FunctionDeclaration": {
|
||||
"parameters": "first"
|
||||
},
|
||||
"FunctionExpression": {
|
||||
"parameters": "first"
|
||||
},
|
||||
"SwitchCase": 1,
|
||||
}
|
||||
],
|
||||
"jsdoc/check-alignment": "error",
|
||||
"jsdoc/check-indentation": "error",
|
||||
"jsdoc/newline-after-description": "error",
|
||||
"max-classes-per-file": "off",
|
||||
"new-parens": "error",
|
||||
"no-bitwise": "error",
|
||||
"no-caller": "error",
|
||||
"no-cond-assign": "error",
|
||||
"no-console": "error",
|
||||
"no-debugger": "error",
|
||||
"no-empty": "error",
|
||||
"no-empty-function": "error",
|
||||
"no-eval": "error",
|
||||
"no-fallthrough": "off",
|
||||
"no-invalid-this": "off",
|
||||
"no-new-wrappers": "error",
|
||||
"no-null/no-null": "error",
|
||||
"no-shadow": "off",
|
||||
"no-throw-literal": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-underscore-dangle": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-use-before-define": "off",
|
||||
"no-var": "error",
|
||||
"object-shorthand": "error",
|
||||
"one-var": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"prefer-arrow/prefer-arrow-functions": "off",
|
||||
"prefer-const": "off",
|
||||
"quote-props": "off",
|
||||
"radix": "error",
|
||||
"spaced-comment": [
|
||||
"error",
|
||||
"always",
|
||||
{
|
||||
"markers": [
|
||||
"/"
|
||||
]
|
||||
}
|
||||
],
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "off",
|
||||
}
|
||||
};
|
10115
package-lock.json
generated
10115
package-lock.json
generated
File diff suppressed because it is too large
Load diff
50
package.json
50
package.json
|
@ -8,39 +8,45 @@
|
|||
"jsbi": "^3.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"@babel/core": "^7.17.0",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
||||
"@types/jasmine": "^3.10.2",
|
||||
"@types/jasmine": "^3.10.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
||||
"@typescript-eslint/parser": "^5.11.0",
|
||||
"ajv": "^8.10.0",
|
||||
"babel-loader": "^8.2.3",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"copy-webpack-plugin": "^5.1.2",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"copy-webpack-plugin": "^10.2.4",
|
||||
"coveralls": "^3.1.1",
|
||||
"eslint": "^8.8.0",
|
||||
"eslint-plugin-jsdoc": "^37.8.0",
|
||||
"eslint-plugin-no-null": "^1.0.2",
|
||||
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||
"esm": "^3.2.25",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"jasmine": "^3.10.0",
|
||||
"jasmine-spec-reporter": "^5.0.2",
|
||||
"karma": "^5.2.3",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"jasmine": "^3.99.0",
|
||||
"jasmine-spec-reporter": "^7.0",
|
||||
"karma": "^6.3.15",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-coverage-istanbul-reporter": "^3.0.3",
|
||||
"karma-firefox-launcher": "^1.3.0",
|
||||
"karma-jasmine": "^3.3.1",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-firefox-launcher": "^2.1.2",
|
||||
"karma-jasmine": "^4.0.1",
|
||||
"karma-sauce-launcher": "^4.3.6",
|
||||
"karma-sourcemap-loader": "^0.3.8",
|
||||
"karma-webpack": "^4.0.2",
|
||||
"terser-webpack-plugin": "^3.1.0",
|
||||
"ts-loader": "^8.3.0",
|
||||
"ts-node": "^10.4.0",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^4.5.4",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-dev-server": "^3.11.3"
|
||||
"karma-webpack": "^5.0.0",
|
||||
"terser-webpack-plugin": "^5.3.1",
|
||||
"ts-loader": "^9.2.6",
|
||||
"ts-node": "^10.5.0",
|
||||
"typescript": "^4.5.5",
|
||||
"webpack": "^5.68.0",
|
||||
"webpack-cli": "^4.9.2",
|
||||
"webpack-dev-server": "^4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node -r esm -r ts-node/register node_modules/.bin/jasmine --config=jasmine.json",
|
||||
"browser-test": "karma start",
|
||||
"lint": "tslint src/**/*.ts",
|
||||
"lint": "eslint -c .eslintrc.js --ext .ts src/",
|
||||
"all": "npm test && npm run lint && npm run browser-test",
|
||||
"build-prod": "PRODUCTION=1 GOOGLE_ANALYTICS_TAG=UA-112154345-1 webpack",
|
||||
"build-stage": "PRODUCTION=1 GOOGLE_ANALYTICS_TAG=UA-112154345-2 webpack",
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/* tslint:disable:no-empty */
|
||||
/* tslint:disable:only-arrow-functions */
|
||||
/* eslint-disable no-empty */
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
/* eslint-disable no-empty-function */
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
||||
/* eslint-disable prefer-rest-params */
|
||||
/** @type {function(...*):void} */
|
||||
export let gtag: (...args: any[]) => void = () => {};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// based on dogbert's pwgen-asus.py
|
||||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
import { makeSolver } from "./utils";
|
||||
|
||||
/** @type {function(number=,number=,number=):Array<number>} */
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
/* eslint-disable @typescript-eslint/no-shadow */
|
||||
/* eslint-disable no-shadow */
|
||||
import JSBI from "jsbi";
|
||||
|
||||
export class Crc64 {
|
||||
private static tableCache: {[key: string]: JSBI[]} = {};
|
||||
// ECMA 182 0xC96C5795D7870F42
|
||||
public static readonly ECMA_POLYNOMIAL = JSBI.BigInt("14514072000185962306");
|
||||
|
||||
private static tableCache: {[key: string]: JSBI[]} = {};
|
||||
|
||||
public readonly polynom: JSBI;
|
||||
|
||||
private table: JSBI[];
|
||||
private crc: JSBI;
|
||||
public readonly polynom: JSBI;
|
||||
|
||||
constructor(poly: JSBI, table?: JSBI[]) {
|
||||
this.polynom = poly;
|
||||
|
@ -20,27 +24,6 @@ export class Crc64 {
|
|||
this.crc = JSBI.BigInt(0);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.crc = JSBI.BigInt(0);
|
||||
}
|
||||
|
||||
public update(input: Uint8Array | number[]) {
|
||||
/* tslint:disable-next-line:prefer-for-of */
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i] & 0xFF;
|
||||
const index = JSBI.toNumber(JSBI.asUintN(8, JSBI.bitwiseXor(this.crc, JSBI.BigInt(b))));
|
||||
const temp = JSBI.bitwiseXor(this.table[index], JSBI.signedRightShift(this.crc, JSBI.BigInt(8)));
|
||||
this.crc = JSBI.asUintN(64, temp);
|
||||
}
|
||||
}
|
||||
|
||||
public digest(): JSBI {
|
||||
return this.crc;
|
||||
}
|
||||
|
||||
public hexdigest(): string {
|
||||
return ("0".repeat(16) + this.digest().toString(16)).slice(-16);
|
||||
}
|
||||
private static makeTable(poly: JSBI): JSBI[] {
|
||||
let table: JSBI[] = [];
|
||||
for (let i = 0; i < 256; i++) {
|
||||
|
@ -70,9 +53,29 @@ export class Crc64 {
|
|||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.crc = JSBI.BigInt(0);
|
||||
}
|
||||
|
||||
public update(input: Uint8Array | number[]) {
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i] & 0xFF;
|
||||
const index = JSBI.toNumber(JSBI.asUintN(8, JSBI.bitwiseXor(this.crc, JSBI.BigInt(b))));
|
||||
const temp = JSBI.bitwiseXor(this.table[index], JSBI.signedRightShift(this.crc, JSBI.BigInt(8)));
|
||||
this.crc = JSBI.asUintN(64, temp);
|
||||
}
|
||||
}
|
||||
|
||||
public digest(): JSBI {
|
||||
return this.crc;
|
||||
}
|
||||
|
||||
public hexdigest(): string {
|
||||
return ("0".repeat(16) + this.digest().toString(16)).slice(-16);
|
||||
}
|
||||
}
|
||||
|
||||
/* tslint:disable:no-shadowed-variable */
|
||||
export class Sha256 {
|
||||
private static readonly SHA256_CONSTANTS: Uint32Array = Uint32Array.from([
|
||||
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
|
||||
|
@ -114,6 +117,32 @@ export class Sha256 {
|
|||
}
|
||||
}
|
||||
|
||||
public update(input: Uint8Array) {
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i];
|
||||
this.data[this.datalen] = b;
|
||||
this.datalen++;
|
||||
|
||||
if (this.datalen >= 64) {
|
||||
this.transform();
|
||||
this.bitlen = JSBI.add(this.bitlen, JSBI.BigInt(512));
|
||||
this.datalen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public digest(): Uint8Array {
|
||||
let item = this.copy();
|
||||
return item.final();
|
||||
}
|
||||
|
||||
public hexdigest() {
|
||||
return Array.from(this.digest()).map((x) => {
|
||||
x = x & 0xFF;
|
||||
return (x < 0xf) ? "0" + x.toString(16) : x.toString(16);
|
||||
}).join("");
|
||||
}
|
||||
|
||||
private transform() {
|
||||
let m: Uint32Array = new Uint32Array(64);
|
||||
|
||||
|
@ -168,6 +197,15 @@ export class Sha256 {
|
|||
this.state[7] += h;
|
||||
}
|
||||
|
||||
private copy(): Sha256 {
|
||||
let item = new Sha256();
|
||||
item.state = this.state.slice();
|
||||
item.data = this.data.slice();
|
||||
item.bitlen = this.bitlen;
|
||||
item.datalen = this.datalen;
|
||||
return item;
|
||||
}
|
||||
|
||||
private final(): Uint8Array {
|
||||
let i = this.datalen & 63;
|
||||
if (this.datalen < 56) {
|
||||
|
@ -200,42 +238,6 @@ export class Sha256 {
|
|||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
private copy(): Sha256 {
|
||||
let item = new Sha256();
|
||||
item.state = this.state.slice();
|
||||
item.data = this.data.slice();
|
||||
item.bitlen = this.bitlen;
|
||||
item.datalen = this.datalen;
|
||||
return item;
|
||||
}
|
||||
|
||||
public update(input: Uint8Array) {
|
||||
/* tslint:disable-next-line:prefer-for-of */
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i];
|
||||
this.data[this.datalen] = b;
|
||||
this.datalen++;
|
||||
|
||||
if (this.datalen >= 64) {
|
||||
this.transform();
|
||||
this.bitlen = JSBI.add(this.bitlen, JSBI.BigInt(512));
|
||||
this.datalen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public digest(): Uint8Array {
|
||||
let item = this.copy();
|
||||
return item.final();
|
||||
}
|
||||
|
||||
public hexdigest() {
|
||||
return Array.from(this.digest()).map((x) => {
|
||||
x = x & 0xFF;
|
||||
return (x < 0xf) ? "0" + x.toString(16) : x.toString(16);
|
||||
}).join("");
|
||||
}
|
||||
}
|
||||
|
||||
export class AES128 {
|
||||
|
@ -273,25 +275,6 @@ export class AES128 {
|
|||
this.roundKey = AES128.keyExpansion(key);
|
||||
}
|
||||
|
||||
public encryptBlock(input: Uint8Array): Uint8Array {
|
||||
if (input.length !== 16) {
|
||||
throw new Error("Invalid block length");
|
||||
}
|
||||
let state = input.slice();
|
||||
AES128.addRoundKey(0, state, this.roundKey);
|
||||
for (let round = 1; ; round++) {
|
||||
AES128.subBytes(state);
|
||||
AES128.shiftRows(state);
|
||||
if (round === 10) {
|
||||
break;
|
||||
}
|
||||
AES128.mixColumns(state);
|
||||
AES128.addRoundKey(round, state, this.roundKey);
|
||||
}
|
||||
AES128.addRoundKey(AES128.NR, state, this.roundKey);
|
||||
return state;
|
||||
}
|
||||
|
||||
private static keyExpansion(key: Uint8Array): Uint8Array {
|
||||
if (key.length !== 16) {
|
||||
throw new Error("Key should be 16 bytes");
|
||||
|
@ -402,4 +385,23 @@ export class AES128 {
|
|||
state[i * 4 + 3] ^= tmp2 ^ tmp1;
|
||||
}
|
||||
}
|
||||
|
||||
public encryptBlock(input: Uint8Array): Uint8Array {
|
||||
if (input.length !== 16) {
|
||||
throw new Error("Invalid block length");
|
||||
}
|
||||
let state = input.slice();
|
||||
AES128.addRoundKey(0, state, this.roundKey);
|
||||
for (let round = 1; ; round++) {
|
||||
AES128.subBytes(state);
|
||||
AES128.shiftRows(state);
|
||||
if (round === 10) {
|
||||
break;
|
||||
}
|
||||
AES128.mixColumns(state);
|
||||
AES128.addRoundKey(round, state, this.roundKey);
|
||||
}
|
||||
AES128.addRoundKey(AES128.NR, state, this.roundKey);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,179 +123,180 @@ describe("Test calculateSuffix", () => {
|
|||
describe("Test keygenDell", () => {
|
||||
it("Dell password for: 1234567-595B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag595B, SuffixType.ServiceTag))
|
||||
.toEqual(["46rg65ky"]);
|
||||
.toEqual(["46rg65ky"]);
|
||||
});
|
||||
it("Dell password for: 1234567-D35B", () => {
|
||||
expect(keygenDell("1234567", DellTag.TagD35B, SuffixType.ServiceTag))
|
||||
.toEqual(["5tc8q9re"]);
|
||||
.toEqual(["5tc8q9re"]);
|
||||
});
|
||||
it("Dell password for: 1234567-2A7B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag2A7B, SuffixType.ServiceTag))
|
||||
.toEqual(["J1KuwWpSUgnDarfi"]);
|
||||
.toEqual(["J1KuwWpSUgnDarfi"]);
|
||||
});
|
||||
it("Dell password for: 1234567-A95B", () => {
|
||||
expect(keygenDell("1234567", DellTag.TagA95B, SuffixType.ServiceTag))
|
||||
.toEqual(["46rg65ky"]);
|
||||
.toEqual(["46rg65ky"]);
|
||||
});
|
||||
it("Dell password for: 1234567-1D3B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual(["Sn4fkF8bS57NymZl"]);
|
||||
.toEqual(["Sn4fkF8bS57NymZl"]);
|
||||
});
|
||||
it("Dell password for: 1234567-1F66", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual(["kIpTBzx0m3s10JDR"]);
|
||||
.toEqual(["kIpTBzx0m3s10JDR"]);
|
||||
});
|
||||
it("Dell password for: 1234567-6FF1", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag6FF1, SuffixType.ServiceTag))
|
||||
.toEqual(["Rzn1wGe555H5bM2r"]);
|
||||
.toEqual(["Rzn1wGe555H5bM2r"]);
|
||||
});
|
||||
it("Dell password for: OPENSRC-1D3B", () => {
|
||||
expect(keygenDell("OPENSRC", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual(["S3yJ91q0Gar3O72I"]);
|
||||
.toEqual(["S3yJ91q0Gar3O72I"]);
|
||||
});
|
||||
it("Dell password for: ABCDEFG-1D3B", () => {
|
||||
expect(keygenDell("ABCDEFG", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual(["xvn0qEeftqyrkG52"]);
|
||||
.toEqual(["xvn0qEeftqyrkG52"]);
|
||||
});
|
||||
it("Dell password for: 7G9C0G2-6FF1", () => {
|
||||
expect(keygenDell("7G9C0G2", DellTag.Tag6FF1, SuffixType.ServiceTag))
|
||||
.toEqual(["35c0b0tVb32Z6ivD"]);
|
||||
.toEqual(["35c0b0tVb32Z6ivD"]);
|
||||
});
|
||||
it("Dell password for: DELLSUX-1F66", () => {
|
||||
expect(keygenDell("DELLSUX", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual(["qHXaL0ntli6Gu4c0"]);
|
||||
.toEqual(["qHXaL0ntli6Gu4c0"]);
|
||||
});
|
||||
it("Dell password for: CRPP562-1F66", () => {
|
||||
expect(keygenDell("CRPP562", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual(["8i5qLGa9woA919Ys"]);
|
||||
.toEqual(["8i5qLGa9woA919Ys"]);
|
||||
});
|
||||
it("Dell password for: CDG8T32-1F66", () => {
|
||||
expect(keygenDell("CDG8T32", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual(["4Ke3y2L3kTP2f6Vo"]);
|
||||
.toEqual(["4Ke3y2L3kTP2f6Vo"]);
|
||||
});
|
||||
it("Dell password for: 8M5RQ32-1F66", () => {
|
||||
expect(keygenDell("8M5RQ32", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual(["3rlrbaSj46Iw221g"]); });
|
||||
.toEqual(["3rlrbaSj46Iw221g"]);
|
||||
});
|
||||
|
||||
it("Dell password for: 1234567-1F5A", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag1F5A, SuffixType.ServiceTag))
|
||||
.toEqual(["2ls2b8GiP9H032kx"]);
|
||||
.toEqual(["2ls2b8GiP9H032kx"]);
|
||||
});
|
||||
|
||||
it("Dell password for: OPENSRC-1F5A", () => {
|
||||
expect(keygenDell("OPENSRC", DellTag.Tag1F5A, SuffixType.ServiceTag))
|
||||
.toEqual(["ZC3j2t56eIe4Thgi"]);
|
||||
.toEqual(["ZC3j2t56eIe4Thgi"]);
|
||||
});
|
||||
|
||||
it("Dell password for: ABCDEFG-1F5A", () => {
|
||||
expect(keygenDell("ABCDEFG", DellTag.Tag1F5A, SuffixType.ServiceTag))
|
||||
.toEqual(["x2zL5n7jj2Gl2TIh"]);
|
||||
.toEqual(["x2zL5n7jj2Gl2TIh"]);
|
||||
});
|
||||
|
||||
it("Dell password for: 1234567-BF97", () => {
|
||||
expect(keygenDell("1234567", DellTag.TagBF97, SuffixType.ServiceTag))
|
||||
.toEqual(["2r09GZhU[r0kW2zr"]);
|
||||
.toEqual(["2r09GZhU[r0kW2zr"]);
|
||||
});
|
||||
|
||||
it("Dell password for: OPENSRC-BF97", () => {
|
||||
expect(keygenDell("OPENSRC", DellTag.TagBF97, SuffixType.ServiceTag))
|
||||
.toEqual(["Dp29XkbyMrkBrp6Z"]);
|
||||
.toEqual(["Dp29XkbyMrkBrp6Z"]);
|
||||
});
|
||||
|
||||
it("Dell password for: ABCDEFG-BF97", () => {
|
||||
expect(keygenDell("ABCDEFG", DellTag.TagBF97, SuffixType.ServiceTag))
|
||||
.toEqual(["kr9Z1cmPpahGzsQ["]);
|
||||
.toEqual(["kr9Z1cmPpahGzsQ["]);
|
||||
});
|
||||
|
||||
it("Dell password for: DELLSUX-BF97", () => {
|
||||
expect(keygenDell("DELLSUX", DellTag.TagBF97, SuffixType.ServiceTag))
|
||||
.toEqual(["rrNM2LrbD8nGsd2P"]);
|
||||
.toEqual(["rrNM2LrbD8nGsd2P"]);
|
||||
});
|
||||
it("Dell password for: 1234567-E7A8", () => {
|
||||
expect(keygenDell("1234567", DellTag.TagE7A8, SuffixType.ServiceTag).sort())
|
||||
.toEqual(["Qk3LkU22kPeyq2jd", "rLIqjUy59IG2JU2R"].sort());
|
||||
.toEqual(["Qk3LkU22kPeyq2jd", "rLIqjUy59IG2JU2R"].sort());
|
||||
});
|
||||
it("Dell password for: D875TG2-E7A8", () => {
|
||||
expect(keygenDell("D875TG2", DellTag.TagE7A8, SuffixType.ServiceTag).sort())
|
||||
.toEqual(["rLZc96rMZyGQ2GMG", "1Q6rxIWMGUznXZNy"].sort());
|
||||
.toEqual(["rLZc96rMZyGQ2GMG", "1Q6rxIWMGUznXZNy"].sort());
|
||||
});
|
||||
it("Dell password for: 2XSX273-E7A8", () => {
|
||||
expect(keygenDell("2XSX273", DellTag.TagE7A8, SuffixType.ServiceTag).sort())
|
||||
.toEqual(["rPQ0DGLdqckG2kUZ", "0ZaP6RzW9qk73rmq"].sort());
|
||||
.toEqual(["rPQ0DGLdqckG2kUZ", "0ZaP6RzW9qk73rmq"].sort());
|
||||
});
|
||||
it("Dell password for: CZXKYX2-E7A8", () => {
|
||||
expect(keygenDell("CZXKYX2", DellTag.TagE7A8, SuffixType.ServiceTag).sort())
|
||||
.toEqual(["RGWD2BIR9UB9ZdIy", "38Gr7brmRGBPPIkz"].sort());
|
||||
.toEqual(["RGWD2BIR9UB9ZdIy", "38Gr7brmRGBPPIkz"].sort());
|
||||
});
|
||||
it("Dell password for: 6651WZ2-E7A8", () => {
|
||||
expect(keygenDell("6651WZ2", DellTag.TagE7A8, SuffixType.ServiceTag).sort())
|
||||
.toEqual(["PBjMMMsZUQR2MhmR", "Q1N6k2sLRkGGGrEN"].sort());
|
||||
.toEqual(["PBjMMMsZUQR2MhmR", "Q1N6k2sLRkGGGrEN"].sort());
|
||||
});
|
||||
it("Dell password for: 9M2JTG2-E7A8", () => {
|
||||
expect(keygenDell("9M2JTG2", DellTag.TagE7A8, SuffixType.ServiceTag))
|
||||
.toContain("J2yR66N1kdn2N17m");
|
||||
.toContain("J2yR66N1kdn2N17m");
|
||||
});
|
||||
it("Dell password for: 1219P73-E7A8", () => {
|
||||
expect(keygenDell("1219P73", DellTag.TagE7A8, SuffixType.ServiceTag))
|
||||
.toContain("ksM02GskJ341hnDx");
|
||||
.toContain("ksM02GskJ341hnDx");
|
||||
});
|
||||
|
||||
// HDD
|
||||
it("Dell HDD password for: 1234567890A-595B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag595B, SuffixType.HDD))
|
||||
.toEqual(["nyoap4lq"]);
|
||||
.toEqual(["nyoap4lq"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-D35B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.TagD35B, SuffixType.HDD))
|
||||
.toEqual(["dc14blrd"]);
|
||||
.toEqual(["dc14blrd"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-2A7B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag2A7B, SuffixType.HDD))
|
||||
.toEqual(["h6lwdi91qluUyt3u"]);
|
||||
.toEqual(["h6lwdi91qluUyt3u"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-A95B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.TagA95B, SuffixType.HDD))
|
||||
.toEqual(["qr0s6x4n"]);
|
||||
.toEqual(["qr0s6x4n"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-1D3B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag1D3B, SuffixType.HDD))
|
||||
.toEqual(["6JQ1WacHNNR0Taia"]);
|
||||
.toEqual(["6JQ1WacHNNR0Taia"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-1F66", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag1F66, SuffixType.HDD))
|
||||
.toEqual(["vP0M31x066Z7Rq9p"]);
|
||||
.toEqual(["vP0M31x066Z7Rq9p"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-6FF1", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag6FF1, SuffixType.HDD))
|
||||
.toEqual(["5enLLpM3Immfb8CK"]);
|
||||
.toEqual(["5enLLpM3Immfb8CK"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-1F5A", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag1F5A, SuffixType.HDD))
|
||||
.toEqual(["L9IJjYoUIXeY5wOy"]);
|
||||
.toEqual(["L9IJjYoUIXeY5wOy"]);
|
||||
});
|
||||
it("Dell HDD password for: 12345678901-1F5A", () => {
|
||||
expect(keygenDell("12345678901", DellTag.Tag1F5A, SuffixType.HDD))
|
||||
.toEqual(["QwO5Dki1zeR1n1t2"]);
|
||||
.toEqual(["QwO5Dki1zeR1n1t2"]);
|
||||
});
|
||||
it("Dell HDD password for: 12345678901-BF97", () => {
|
||||
expect(keygenDell("12345678901", DellTag.TagBF97, SuffixType.HDD))
|
||||
.toEqual(["nDrmUU6U5DI9ZLMI"]);
|
||||
.toEqual(["nDrmUU6U5DI9ZLMI"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-BF97", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.TagBF97, SuffixType.HDD))
|
||||
.toEqual(["pRrky3r9ryEPNNJz"]);
|
||||
.toEqual(["pRrky3r9ryEPNNJz"]);
|
||||
});
|
||||
it("Dell HDD password for: 234567890AB-BF97", () => {
|
||||
expect(keygenDell("234567890AB", DellTag.TagBF97, SuffixType.HDD))
|
||||
.toEqual(["h2RDrReN37I1NLmr"]);
|
||||
.toEqual(["h2RDrReN37I1NLmr"]);
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-E7A8", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.TagE7A8, SuffixType.HDD).sort())
|
||||
.toEqual(["rN2rE2RBQh[X00yr", "G1bFzRGzjXIGzr22"].sort());
|
||||
.toEqual(["rN2rE2RBQh[X00yr", "G1bFzRGzjXIGzr22"].sort());
|
||||
});
|
||||
it("Dell HDD password for: 1234567890B-E7A8", () => {
|
||||
expect(keygenDell("1234567890B", DellTag.TagE7A8, SuffixType.HDD).sort())
|
||||
.toEqual(["Ic18yqyXXZI5Qj22", "kzzMazZrz53sRZJm"].sort());
|
||||
.toEqual(["Ic18yqyXXZI5Qj22", "kzzMazZrz53sRZJm"].sort());
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
import { DellTag } from "./types";
|
||||
|
||||
const md5magic = Uint32Array.from([
|
||||
|
@ -126,24 +126,10 @@ class Tag595BEncoder {
|
|||
this.D = this.encData[3];
|
||||
}
|
||||
|
||||
protected initialData(): number[] {
|
||||
return initialData.slice();
|
||||
}
|
||||
|
||||
protected calculate(func: EncFunction, key1: number, key2: number): number {
|
||||
let temp = func(this.B, this.C, this.D);
|
||||
return this.A + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0;
|
||||
}
|
||||
|
||||
protected incrementData() {
|
||||
this.encData[0] += this.A;
|
||||
this.encData[1] += this.B;
|
||||
this.encData[2] += this.C;
|
||||
this.encData[3] += this.D;
|
||||
|
||||
this.encData.forEach((val, index) => {
|
||||
this.encData[index] = val | 0;
|
||||
});
|
||||
public static encode(encBlock: number[]): number[] {
|
||||
let obj = new this(encBlock);
|
||||
obj.makeEncode();
|
||||
return obj.result();
|
||||
}
|
||||
|
||||
public makeEncode(): void {
|
||||
|
@ -176,10 +162,24 @@ class Tag595BEncoder {
|
|||
return this.encData.map((v) => (v | 0) >>> 0);
|
||||
}
|
||||
|
||||
public static encode(encBlock: number[]): number[] {
|
||||
let obj = new this(encBlock);
|
||||
obj.makeEncode();
|
||||
return obj.result();
|
||||
protected initialData(): number[] {
|
||||
return initialData.slice();
|
||||
}
|
||||
|
||||
protected calculate(func: EncFunction, key1: number, key2: number): number {
|
||||
let temp = func(this.B, this.C, this.D);
|
||||
return this.A + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0;
|
||||
}
|
||||
|
||||
protected incrementData() {
|
||||
this.encData[0] += this.A;
|
||||
this.encData[1] += this.B;
|
||||
this.encData[2] += this.C;
|
||||
this.encData[3] += this.D;
|
||||
|
||||
this.encData.forEach((val, index) => {
|
||||
this.encData[index] = val | 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,22 +350,6 @@ class Tag6FF1Encoder extends Tag595BEncoder {
|
|||
class Tag1F5AEncoder extends Tag595BEncoder {
|
||||
protected readonly md5table = md5magic2;
|
||||
|
||||
protected incrementData() {
|
||||
this.encData[0] += this.B;
|
||||
this.encData[1] += this.C;
|
||||
this.encData[2] += this.A;
|
||||
this.encData[3] += this.D;
|
||||
|
||||
this.encData.forEach((val, index) => {
|
||||
this.encData[index] = val | 0;
|
||||
});
|
||||
}
|
||||
|
||||
protected calculate(func: EncFunction, key1: number, key2: number): number {
|
||||
let temp = func(this.C, this.A, this.D);
|
||||
return this.B + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0;
|
||||
}
|
||||
|
||||
public makeEncode(): void {
|
||||
let t: number = 0;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
|
@ -394,6 +378,22 @@ class Tag1F5AEncoder extends Tag595BEncoder {
|
|||
this.incrementData();
|
||||
}
|
||||
}
|
||||
|
||||
protected incrementData() {
|
||||
this.encData[0] += this.B;
|
||||
this.encData[1] += this.C;
|
||||
this.encData[2] += this.A;
|
||||
this.encData[3] += this.D;
|
||||
|
||||
this.encData.forEach((val, index) => {
|
||||
this.encData[index] = val | 0;
|
||||
});
|
||||
}
|
||||
|
||||
protected calculate(func: EncFunction, key1: number, key2: number): number {
|
||||
let temp = func(this.C, this.A, this.D);
|
||||
return this.B + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0;
|
||||
}
|
||||
}
|
||||
|
||||
class TagBF97Encoder extends Tag6FF1Encoder {
|
||||
|
@ -410,21 +410,6 @@ export class TagE7A8Encoder extends Tag595BEncoder {
|
|||
0x60606161, 0xA0008, 0x100097, 0x50501010
|
||||
]);
|
||||
|
||||
protected initialData(): number[] {
|
||||
return [0, 0, 0, 0];
|
||||
}
|
||||
|
||||
private shortcut(fun: EncFunction, j: number, md5_index: number, rot_index: number, indexes: number[]): void {
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const t = this.calculate(fun, (j + indexes[i]) & 7, i + md5_index);
|
||||
this.A = this.D;
|
||||
this.D = this.C;
|
||||
this.C = this.B;
|
||||
this.B = rol(t, rotationTable[rot_index][i]) + this.B | 0;
|
||||
}
|
||||
}
|
||||
|
||||
public makeEncode(): void {
|
||||
|
||||
for (let p = 0; p < this.loopParams[0]; p++) {
|
||||
|
@ -434,7 +419,7 @@ export class TagE7A8Encoder extends Tag595BEncoder {
|
|||
this.D ^= this.encodeParams[3] + p;
|
||||
|
||||
for (let j = 0; j < this.loopParams[2]; j += 4) {
|
||||
this.shortcut(this.f2, j, j + 32, 0, [0, 1, 2, 3]);
|
||||
this.shortcut(this.f2, j, j + 32, 0, [0, 1, 2, 3]);
|
||||
}
|
||||
|
||||
for (let j = 0; j < this.loopParams[2]; j += 4) {
|
||||
|
@ -479,6 +464,21 @@ export class TagE7A8Encoder extends Tag595BEncoder {
|
|||
this.incrementData();
|
||||
}
|
||||
}
|
||||
|
||||
protected initialData(): number[] {
|
||||
return [0, 0, 0, 0];
|
||||
}
|
||||
|
||||
private shortcut(fun: EncFunction, j: number, md5_index: number, rot_index: number, indexes: number[]): void {
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const t = this.calculate(fun, (j + indexes[i]) & 7, i + md5_index);
|
||||
this.A = this.D;
|
||||
this.D = this.C;
|
||||
this.C = this.B;
|
||||
this.B = rol(t, rotationTable[rot_index][i]) + this.B | 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class TagE7A8EncoderSecond extends TagE7A8Encoder {
|
||||
|
@ -492,7 +492,7 @@ export class TagE7A8EncoderSecond extends TagE7A8Encoder {
|
|||
arr.set(md5magic2);
|
||||
arr.set(overfillArr, md5magic2.length);
|
||||
return arr;
|
||||
})()
|
||||
})();
|
||||
|
||||
protected readonly loopParams = [17, 13, 12, 16];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
import { makeSolver } from "../utils";
|
||||
import { blockEncode, TagE7A8Encoder, TagE7A8EncoderSecond } from "./encode";
|
||||
import { DES, latitude3540Keygen } from "./latitude";
|
||||
|
@ -133,6 +133,7 @@ function resultToString(arr: number[] | Uint8Array, tag: DellTag): string {
|
|||
*/
|
||||
export function keygenDell(serial: string, tag: DellTag, type: SuffixType): string[] {
|
||||
let fullSerial: string;
|
||||
let encBlock: number[];
|
||||
|
||||
function byteArrayToInt(arr: number[]): number[] {
|
||||
// convert byte array to 32-bit little-endian int array
|
||||
|
@ -158,7 +159,7 @@ export function keygenDell(serial: string, tag: DellTag, type: SuffixType): stri
|
|||
return result;
|
||||
}
|
||||
|
||||
function calculate_e7a8(block: number[], klass: any): string {
|
||||
function calculateE7A8(block: number[], klass: {encode(data: number[]): number[]}): string {
|
||||
// TODO: refactor this
|
||||
const table = "Q92G0drk9y63r5DG1hLqJGW1EnRk[QxrFMNZ328I6myLr4MsPNeZR2z72czpzUJBGXbaIjkZ";
|
||||
const res = intArrayToByte(klass.encode(block));
|
||||
|
@ -174,13 +175,13 @@ export function keygenDell(serial: string, tag: DellTag, type: SuffixType): stri
|
|||
if (tag === DellTag.TagA95B) {
|
||||
|
||||
if (type === SuffixType.ServiceTag) {
|
||||
fullSerial = serial + DellTag.Tag595B as string;
|
||||
fullSerial = serial + DellTag.Tag595B;
|
||||
} else { // HDD
|
||||
fullSerial = serial.slice(3) + "\0\0\0" + DellTag.Tag595B as string;
|
||||
fullSerial = serial.slice(3) + "\0\0\0" + DellTag.Tag595B;
|
||||
}
|
||||
|
||||
} else {
|
||||
fullSerial = serial + tag as string;
|
||||
fullSerial = serial + tag;
|
||||
}
|
||||
|
||||
let fullSerialArray: number[] = [];
|
||||
|
@ -189,31 +190,31 @@ export function keygenDell(serial: string, tag: DellTag, type: SuffixType): stri
|
|||
// Maybe protect against unicode symbols with: charCode & 0xFF ?
|
||||
fullSerialArray.push(fullSerial.charCodeAt(i));
|
||||
}
|
||||
if (tag == DellTag.TagE7A8) {
|
||||
if (tag === DellTag.TagE7A8) {
|
||||
// TODO: refactor all this
|
||||
let encBlock = byteArrayToInt(fullSerialArray);
|
||||
encBlock = byteArrayToInt(fullSerialArray);
|
||||
for (let i = 0; i < 16; i++) {
|
||||
if (encBlock[i] === undefined) {
|
||||
encBlock[i] = 0;
|
||||
}
|
||||
}
|
||||
const out_str1 = calculate_e7a8(encBlock, TagE7A8Encoder);
|
||||
const out_str2 = calculate_e7a8(encBlock, TagE7A8EncoderSecond);
|
||||
let result = [];
|
||||
const out_str1 = calculateE7A8(encBlock, TagE7A8Encoder);
|
||||
const out_str2 = calculateE7A8(encBlock, TagE7A8EncoderSecond);
|
||||
let output = [];
|
||||
if (out_str1) {
|
||||
result.push(out_str1);
|
||||
output.push(out_str1);
|
||||
}
|
||||
if (out_str2) {
|
||||
result.push(out_str2);
|
||||
output.push(out_str2);
|
||||
}
|
||||
return result;
|
||||
return output;
|
||||
}
|
||||
|
||||
fullSerialArray = fullSerialArray.concat(calculateSuffix(fullSerialArray, tag, type));
|
||||
const cnt = 23;
|
||||
// NOTE: after this array might contain undefined values
|
||||
fullSerialArray[cnt] = 0x80;
|
||||
let encBlock = byteArrayToInt(fullSerialArray);
|
||||
encBlock = byteArrayToInt(fullSerialArray);
|
||||
// fill empty values with zeros
|
||||
for (let i = 0; i < 16; i++) {
|
||||
if (encBlock[i] === undefined) {
|
||||
|
@ -222,8 +223,8 @@ export function keygenDell(serial: string, tag: DellTag, type: SuffixType): stri
|
|||
}
|
||||
encBlock[14] = cnt << 3;
|
||||
let decodedBytes = intArrayToByte(blockEncode(encBlock, tag));
|
||||
const result = resultToString(decodedBytes, tag);
|
||||
return (result) ? [result] : [];
|
||||
const outputResult = resultToString(decodedBytes, tag);
|
||||
return (outputResult) ? [outputResult] : [];
|
||||
}
|
||||
|
||||
function checkDellTag(tag: string): boolean {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable no-bitwise */
|
||||
|
||||
export class DES {
|
||||
// DES ECB mode
|
||||
// Initial permutation table
|
||||
|
@ -49,8 +51,8 @@ export class DES {
|
|||
// expansion table (E table)
|
||||
private static readonly EXPANSION: Uint8Array = Uint8Array.from([
|
||||
32, 1, 2, 3, 4, 5,
|
||||
4, 5, 6, 7, 8, 9,
|
||||
8, 9, 10, 11, 12, 13,
|
||||
4, 5, 6, 7, 8, 9,
|
||||
8, 9, 10, 11, 12, 13,
|
||||
12, 13, 14, 15, 16, 17,
|
||||
16, 17, 18, 19, 20, 21,
|
||||
20, 21, 22, 23, 24, 25,
|
||||
|
@ -62,9 +64,9 @@ export class DES {
|
|||
private static readonly POST_SBOX: Uint8Array = Uint8Array.from([
|
||||
16, 7, 20, 21,
|
||||
29, 12, 28, 17,
|
||||
1, 15, 23, 26,
|
||||
5, 18, 31, 10,
|
||||
2, 8, 24, 14,
|
||||
1, 15, 23, 26,
|
||||
5, 18, 31, 10,
|
||||
2, 8, 24, 14,
|
||||
32, 27, 3, 9,
|
||||
19, 13, 30, 6,
|
||||
22, 11, 4, 25,
|
||||
|
@ -77,48 +79,49 @@ export class DES {
|
|||
private static readonly SBOX: Uint8Array = Uint8Array.from([
|
||||
// S1
|
||||
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
|
||||
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
|
||||
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
|
||||
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
|
||||
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
|
||||
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
|
||||
// S2
|
||||
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
|
||||
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
|
||||
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
|
||||
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
|
||||
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
|
||||
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
|
||||
// S3
|
||||
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
|
||||
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
|
||||
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
|
||||
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
|
||||
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
|
||||
// S4
|
||||
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
|
||||
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
|
||||
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
|
||||
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
|
||||
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
|
||||
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
|
||||
// S5
|
||||
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
|
||||
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
|
||||
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
|
||||
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
|
||||
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
|
||||
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
|
||||
// S6
|
||||
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
|
||||
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
|
||||
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
|
||||
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
|
||||
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
|
||||
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
|
||||
// S7
|
||||
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
|
||||
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
|
||||
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
|
||||
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
|
||||
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
|
||||
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
|
||||
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
|
||||
// S8
|
||||
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
|
||||
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
|
||||
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
|
||||
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
|
||||
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
|
||||
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
|
||||
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
|
||||
]);
|
||||
|
||||
private key: Uint8Array;
|
||||
private subKeys: Uint32Array;
|
||||
|
||||
constructor(key: Uint8Array) {
|
||||
if (key.length !== 8) {
|
||||
throw new Error("DES key should be 8 bytes long");
|
||||
|
@ -129,98 +132,6 @@ export class DES {
|
|||
this.generateSubkeys();
|
||||
}
|
||||
|
||||
private generateSubkeys() {
|
||||
let leftpart: number = 0;
|
||||
let rightpart: number = 0;
|
||||
|
||||
for (let i = 0; i < 56; i++) {
|
||||
const index = DES.PC1[i] - 1;
|
||||
const bit = (this.key[index >>> 3] >>> (7 - (index & 0b111))) & 1;
|
||||
if (i < 28) {
|
||||
leftpart |= (bit << i);
|
||||
} else {
|
||||
rightpart |= (bit << (i - 28));
|
||||
}
|
||||
}
|
||||
function rightShift(part: number, val: number) {
|
||||
return (part >>> val | part << (28 - val)) & 0xfffffff;
|
||||
}
|
||||
|
||||
for (let round = 0; round < 16; round++) {
|
||||
let subkeyPart1: number = 0;
|
||||
let subkeyPart2: number = 0;
|
||||
|
||||
leftpart = rightShift(leftpart, DES.ITERATION_SHIFT[round]);
|
||||
rightpart = rightShift(rightpart, DES.ITERATION_SHIFT[round]);
|
||||
for (let i = 0; i < 48; i++) {
|
||||
const index = DES.PC2[i] - 1;
|
||||
const bit = ((index < 28) ? (leftpart >>> index) : (rightpart >>> (index - 28))) & 1;
|
||||
if (i < 32) {
|
||||
subkeyPart1 |= (bit << i);
|
||||
} else {
|
||||
subkeyPart2 |= (bit << (i - 32));
|
||||
}
|
||||
}
|
||||
this.subKeys[round << 1] = subkeyPart2;
|
||||
this.subKeys[round << 1 | 1] = subkeyPart1;
|
||||
}
|
||||
}
|
||||
|
||||
private cryptBlock(input: Uint8Array, encrypt: boolean = true): Uint8Array {
|
||||
if (input.length !== 8) {
|
||||
throw new Error("Input should be 8 bytes long");
|
||||
}
|
||||
let leftpart: number = 0;
|
||||
let rightpart: number = 0;
|
||||
// initial permutation
|
||||
for (let i = 0; i < 64; i++) {
|
||||
const index = DES.IP[i] - 1;
|
||||
const bit = (input[index >>> 3] >>> (7 - (index & 0b111))) & 1;
|
||||
if (i < 32) {
|
||||
leftpart |= (bit << i);
|
||||
} else {
|
||||
rightpart |= (bit << (i - 32));
|
||||
}
|
||||
}
|
||||
if (encrypt) {
|
||||
for (let round = 0; round < 16; round++) {
|
||||
const temp = rightpart;
|
||||
rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1],
|
||||
this.subKeys[round << 1 | 1]);
|
||||
leftpart = temp;
|
||||
}
|
||||
} else {
|
||||
// reverse order
|
||||
for (let round = 15; round >= 0; round--) {
|
||||
const temp = rightpart;
|
||||
rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1],
|
||||
this.subKeys[round << 1 | 1]);
|
||||
leftpart = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// final permutation
|
||||
let output: Uint8Array = new Uint8Array(8);
|
||||
for (let i = 0; i < 64; i++) {
|
||||
const index = DES.FP[i] - 1;
|
||||
let bit: number;
|
||||
if (index < 32) {
|
||||
bit = (rightpart >>> index) & 1;
|
||||
} else {
|
||||
bit = (leftpart >>> (index - 32)) & 1;
|
||||
}
|
||||
output[i >>> 3] |= (bit << (7 - (i & 0b111)));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
public encryptBlock(input: Uint8Array): Uint8Array {
|
||||
return this.cryptBlock(input, true);
|
||||
}
|
||||
|
||||
public decryptBlock(input: Uint8Array): Uint8Array {
|
||||
return this.cryptBlock(input, false);
|
||||
}
|
||||
|
||||
private static FUNC(data: number, subkey2: number, subkey1: number): number {
|
||||
let part1: number = 0;
|
||||
let part2: number = 0;
|
||||
|
@ -260,6 +171,99 @@ export class DES {
|
|||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public encryptBlock(input: Uint8Array): Uint8Array {
|
||||
return this.cryptBlock(input, true);
|
||||
}
|
||||
|
||||
public decryptBlock(input: Uint8Array): Uint8Array {
|
||||
return this.cryptBlock(input, false);
|
||||
}
|
||||
|
||||
private generateSubkeys() {
|
||||
let leftpart: number = 0;
|
||||
let rightpart: number = 0;
|
||||
|
||||
for (let i = 0; i < 56; i++) {
|
||||
const index = DES.PC1[i] - 1;
|
||||
const bit = (this.key[index >>> 3] >>> (7 - (index & 0b111))) & 1;
|
||||
if (i < 28) {
|
||||
leftpart |= (bit << i);
|
||||
} else {
|
||||
rightpart |= (bit << (i - 28));
|
||||
}
|
||||
}
|
||||
function rightShift(part: number, val: number) {
|
||||
return (part >>> val | part << (28 - val)) & 0xfffffff;
|
||||
}
|
||||
|
||||
for (let round = 0; round < 16; round++) {
|
||||
let subkeyPart1: number = 0;
|
||||
let subkeyPart2: number = 0;
|
||||
|
||||
leftpart = rightShift(leftpart, DES.ITERATION_SHIFT[round]);
|
||||
rightpart = rightShift(rightpart, DES.ITERATION_SHIFT[round]);
|
||||
for (let i = 0; i < 48; i++) {
|
||||
const index = DES.PC2[i] - 1;
|
||||
const bit = ((index < 28) ? (leftpart >>> index) : (rightpart >>> (index - 28))) & 1;
|
||||
if (i < 32) {
|
||||
subkeyPart1 |= (bit << i);
|
||||
} else {
|
||||
subkeyPart2 |= (bit << (i - 32));
|
||||
}
|
||||
}
|
||||
this.subKeys[round << 1] = subkeyPart2;
|
||||
this.subKeys[round << 1 | 1] = subkeyPart1;
|
||||
}
|
||||
}
|
||||
|
||||
private cryptBlock(input: Uint8Array, encrypt: boolean = true): Uint8Array {
|
||||
if (input.length !== 8) {
|
||||
throw new Error("Input should be 8 bytes long");
|
||||
}
|
||||
let leftpart: number = 0;
|
||||
let rightpart: number = 0;
|
||||
// initial permutation
|
||||
for (let i = 0; i < 64; i++) {
|
||||
const index = DES.IP[i] - 1;
|
||||
const bit = (input[index >>> 3] >>> (7 - (index & 0b111))) & 1;
|
||||
if (i < 32) {
|
||||
leftpart |= (bit << i);
|
||||
} else {
|
||||
rightpart |= (bit << (i - 32));
|
||||
}
|
||||
}
|
||||
if (encrypt) {
|
||||
for (let round = 0; round < 16; round++) {
|
||||
const temp = rightpart;
|
||||
rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1],
|
||||
this.subKeys[round << 1 | 1]);
|
||||
leftpart = temp;
|
||||
}
|
||||
} else {
|
||||
// reverse order
|
||||
for (let round = 15; round >= 0; round--) {
|
||||
const temp = rightpart;
|
||||
rightpart = leftpart ^ DES.FUNC(rightpart, this.subKeys[round << 1],
|
||||
this.subKeys[round << 1 | 1]);
|
||||
leftpart = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// final permutation
|
||||
let output: Uint8Array = new Uint8Array(8);
|
||||
for (let i = 0; i < 64; i++) {
|
||||
const index = DES.FP[i] - 1;
|
||||
let bit: number;
|
||||
if (index < 32) {
|
||||
bit = (rightpart >>> index) & 1;
|
||||
} else {
|
||||
bit = (leftpart >>> (index - 32)) & 1;
|
||||
}
|
||||
output[i >>> 3] |= (bit << (7 - (i & 0b111)));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable no-bitwise */
|
||||
import { makeSolver } from "./utils";
|
||||
/* tslint:disable:no-bitwise */
|
||||
|
||||
function generateCRC16Table(): number[] {
|
||||
let table: number[] = [];
|
||||
|
@ -74,7 +74,7 @@ function fsi20DecOldKeygen(serial: string): string {
|
|||
return arr;
|
||||
}
|
||||
|
||||
function decryptCode_old(bytes: number[]) {
|
||||
function decryptCodeOld(bytes: number[]) {
|
||||
const xorKey = ":3-v@e4i";
|
||||
// apply XOR key
|
||||
bytes.forEach((val, i, arr) => {
|
||||
|
@ -96,7 +96,7 @@ function fsi20DecOldKeygen(serial: string): string {
|
|||
return bytes.map((b) => (b % 36).toString(36)).join("");
|
||||
}
|
||||
|
||||
return decryptCode_old(codeToBytes(serial));
|
||||
return decryptCodeOld(codeToBytes(serial));
|
||||
}
|
||||
|
||||
/* For Fujitsu-Simens. 6x4 decimal digits */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
import { makeSolver } from "./utils";
|
||||
|
||||
export class Crc32 {
|
||||
|
||||
private static tableCache: {[key: string]: Uint32Array} = {};
|
||||
public static readonly IEEE_POLYNOMIAL = 0xEDB88320;
|
||||
private static tableCache: {[key: string]: Uint32Array} = {};
|
||||
|
||||
private table: Uint32Array;
|
||||
private crc: number;
|
||||
|
@ -17,31 +17,6 @@ export class Crc32 {
|
|||
this.crc = 0;
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.crc = 0;
|
||||
}
|
||||
|
||||
public update(input: Uint8Array | number[]) {
|
||||
this.crc ^= -1;
|
||||
|
||||
/* tslint:disable-next-line:prefer-for-of */
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i] & 0xFF;
|
||||
const index = (this.crc ^ b) & 0xFF;
|
||||
this.crc = (this.crc >>> 8) ^ this.table[index];
|
||||
}
|
||||
|
||||
this.crc = ((this.crc ^ (-1)) >>> 0);
|
||||
}
|
||||
|
||||
public digest(): number {
|
||||
return this.crc;
|
||||
}
|
||||
|
||||
public hexdigest(): string {
|
||||
return ("0".repeat(8) + this.digest().toString(16)).slice(-8);
|
||||
}
|
||||
|
||||
private static makeTable(poly: number): Uint32Array {
|
||||
let crcTable = new Uint32Array(256);
|
||||
for (let i = 0; i < 256; i++) {
|
||||
|
@ -68,6 +43,30 @@ export class Crc32 {
|
|||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.crc = 0;
|
||||
}
|
||||
|
||||
public update(input: Uint8Array | number[]) {
|
||||
this.crc ^= -1;
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const b = input[i] & 0xFF;
|
||||
const index = (this.crc ^ b) & 0xFF;
|
||||
this.crc = (this.crc >>> 8) ^ this.table[index];
|
||||
}
|
||||
|
||||
this.crc = ((this.crc ^ (-1)) >>> 0);
|
||||
}
|
||||
|
||||
public digest(): number {
|
||||
return this.crc;
|
||||
}
|
||||
|
||||
public hexdigest(): string {
|
||||
return ("0".repeat(8) + this.digest().toString(16)).slice(-8);
|
||||
}
|
||||
}
|
||||
|
||||
function hpAmiKeygen(input: string): string | undefined {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* tslint:disable:no-var-requires */
|
||||
/* tslint:disable:no-shadowed-variable */
|
||||
/* eslint-disable no-bitwise */
|
||||
/* eslint-disable @typescript-eslint/no-shadow */
|
||||
/* eslint-disable no-shadow */
|
||||
/* Maybe need fixing for browsers where numbers is 32-bits */
|
||||
/* Some Acer, HP laptops. 8 digit */
|
||||
import { makeSolver } from "./utils";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
import {
|
||||
asciiToKeyboardEnc, keyboardEncToAscii, reversedScanCodes, Solver
|
||||
} from "./utils";
|
||||
|
@ -16,14 +16,9 @@ export interface PhoenixInfo {
|
|||
maxLen: number;
|
||||
}
|
||||
|
||||
export interface PhoenixBios {
|
||||
export interface PhoenixBios extends Partial<PhoenixInfo> {
|
||||
name: string;
|
||||
description?: string;
|
||||
shift?: number;
|
||||
salt?: number;
|
||||
dictionary?: string[];
|
||||
minLen?: number;
|
||||
maxLen?: number;
|
||||
}
|
||||
|
||||
export interface PhoenixSolver extends Solver {
|
||||
|
@ -56,7 +51,6 @@ const defaultPhoenix: PhoenixInfo = {
|
|||
function badCRC16(pwd: number[], salt: number = 0): number {
|
||||
|
||||
let hash = salt;
|
||||
// tslint:disable-next-line:prefer-for-of
|
||||
for (let c = 0; c < pwd.length; c++) {
|
||||
hash ^= pwd[c];
|
||||
for (let i = 8; i--;) {
|
||||
|
@ -79,7 +73,6 @@ function searchBadCRC16(pwd: number[], salt: number, requiredHash: number, minLe
|
|||
|
||||
minLen--;
|
||||
let hash = salt;
|
||||
// tslint:disable-next-line:prefer-for-of
|
||||
for (let c = 0; c < pwd.length; c++) {
|
||||
hash ^= pwd[c];
|
||||
for (let i = 8; i--;) {
|
||||
|
@ -135,13 +128,16 @@ function bruteForce(hash: number, salt: number = 0, characters: string[] = lette
|
|||
}
|
||||
|
||||
function makePhoenixSolver(description?: PhoenixBios): PhoenixSolver {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
if (description === void 0) {
|
||||
description = {} as PhoenixBios;
|
||||
}
|
||||
|
||||
for (let key in defaultPhoenix) {
|
||||
if ((description as any)[key] === void 0) {
|
||||
(description as any)[key] = (defaultPhoenix as any)[key];
|
||||
let key: keyof PhoenixInfo;
|
||||
for (key in defaultPhoenix) {
|
||||
if (description[key] === void 0) {
|
||||
(description[key] as (PhoenixInfo[keyof PhoenixInfo])) = defaultPhoenix[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +151,7 @@ function makePhoenixSolver(description?: PhoenixBios): PhoenixSolver {
|
|||
|
||||
let keygen = (code: string) => {
|
||||
let password = bruteForce(parseInt(code, 10) + info.shift, info.salt,
|
||||
info.dictionary, info.minLen, info.maxLen);
|
||||
info.dictionary, info.minLen, info.maxLen);
|
||||
|
||||
if (typeof password === "string") {
|
||||
return [password];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* tslint:disable:no-bitwise */
|
||||
/* eslint-disable no-bitwise */
|
||||
/* Return password for samsung laptops
|
||||
* 12 or 18 hexhecimal digits like 07088120410C0000
|
||||
*/
|
||||
|
@ -75,7 +75,7 @@ function samsungKeygen(serial: string): string[] {
|
|||
filter((code) => code ? true : false) as string[];
|
||||
}
|
||||
|
||||
function byte_rol(val: number, shift: number): number {
|
||||
function byteRol(val: number, shift: number): number {
|
||||
return ((val << shift) & 0xff) | (val >> (8 - shift));
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ export function samsung44HexKeygen(serial: string): string | undefined {
|
|||
const key = (hash[1] % 5) * 20;
|
||||
for (let i = 0; i < pwdLength; i++) {
|
||||
const shift = rotationMatrix3[key + i];
|
||||
const sym = byte_rol(byte_rol(hash[i + 2], shift), 4);
|
||||
const sym = byteRol(byteRol(hash[i + 2], shift), 4);
|
||||
if (nonprintable(sym)) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* tslint:disable:no-var-requires */
|
||||
import JSBI from "jsbi";
|
||||
import { modularPow, sony4x4Keygen, sony4x4Solver } from "./sony_4x4";
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// based on dogbert's pwgen-sony-4x4.py
|
||||
/* tslint:disable:no-bitwise */
|
||||
/* tslint:disable:no-var-requires */
|
||||
/* eslint-disable no-bitwise */
|
||||
import JSBI from "jsbi";
|
||||
import { makeSolver } from "./utils";
|
||||
|
||||
|
@ -51,7 +50,7 @@ function modInvEuclid(a: JSBI, m: JSBI): JSBI | undefined {
|
|||
// hack for javascript modulo operation
|
||||
// https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers
|
||||
const temp = JSBI.remainder(x, m);
|
||||
return JSBI.GE(temp, 0) ? temp : JSBI.ADD(temp, m);
|
||||
return JSBI.GE(temp, 0) ? temp : JSBI.ADD(temp, m) as JSBI;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -73,7 +72,7 @@ export function modularPow(base: JSBI, exponent: number, modulus: number | JSBI)
|
|||
|
||||
while (exponent > 0) {
|
||||
if ((exponent & 1) === 1) {
|
||||
result = JSBI.remainder(JSBI.multiply(result, base), modulus);
|
||||
result = JSBI.remainder(JSBI.multiply(result, base), modulus);
|
||||
}
|
||||
exponent = exponent >> 1;
|
||||
base = JSBI.remainder(JSBI.multiply(base, base), modulus);
|
||||
|
|
|
@ -74,9 +74,10 @@ function cleanSerial(serial: string): string {
|
|||
}
|
||||
|
||||
export function makeSolver(description: SolverDescription): Solver {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
let solver: any = (code: string) => {
|
||||
let cleanCode = solver.cleaner(code);
|
||||
let cleanCode = (solver as Solver).cleaner(code);
|
||||
if (description.inputValidator(cleanCode)) {
|
||||
return description.fun(cleanCode);
|
||||
} else {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
|
||||
function makeMonotonicTime(): () => number {
|
||||
if (typeof performance !== "undefined" && performance) {
|
||||
|
|
41
tslint.json
41
tslint.json
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": [
|
||||
"tslint:recommended"
|
||||
],
|
||||
"jsRules": {},
|
||||
"rules": {
|
||||
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
|
||||
"variable-name": [true, "ban-keywords", "check-format"],
|
||||
"prefer-const": false,
|
||||
"interface-name": [true, "never-prefix"],
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"class-name": true,
|
||||
"no-eval": true,
|
||||
"eofline": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"no-null-keyword": true,
|
||||
"encoding": true,
|
||||
"no-namespace": true,
|
||||
"max-classes-per-file": [false],
|
||||
"member-ordering": [true, {"order": [
|
||||
"private-static-field",
|
||||
"protected-static-field",
|
||||
"public-static-field",
|
||||
"private-instance-field",
|
||||
"protected-instance-field",
|
||||
"public-instance-field",
|
||||
"private-constructor",
|
||||
"protected-constructor",
|
||||
"public-constructor",
|
||||
"private-instance-method",
|
||||
"protected-instance-method",
|
||||
"public-instance-method",
|
||||
"private-static-method",
|
||||
"protected-static-method",
|
||||
"public-static-method"
|
||||
]}]
|
||||
},
|
||||
"rulesDirectory": []
|
||||
}
|
|
@ -52,11 +52,13 @@ function getWebpackConfig(production, gtag) {
|
|||
|
||||
var plugins = [
|
||||
new CleanWebpackPlugin(),
|
||||
new CopyWebpackPlugin([
|
||||
{from: 'assets/bootstrap.min.css', to: 'assets/'},
|
||||
{from: 'assets/images/favicon.ico', to: 'favicon.ico'},
|
||||
{from: 'assets/images/', to: 'assets/images/'},
|
||||
]),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{from: 'assets/bootstrap.min.css', to: 'assets/'},
|
||||
{from: 'assets/images/favicon.ico', to: 'favicon.ico'},
|
||||
{from: 'assets/images/', to: 'assets/images/'},
|
||||
]
|
||||
}),
|
||||
new DefinePlugin({
|
||||
GOOGLE_ANALYTICS_TAG: JSON.stringify(gtag)
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue