mirror of
https://github.com/bacher09/pwgen-for-bios.git
synced 2024-09-19 07:18:53 -04:00
Add support for dell tag 1F5A
This commit is contained in:
parent
c40b6fd556
commit
2c87bd691e
4 changed files with 91 additions and 5 deletions
|
@ -52,6 +52,16 @@ describe("Test calculateSuffix", () => {
|
|||
expect(suffix).toEqual([117, 66, 48, 111, 83, 107, 85, 111]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-1F5A", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag1F5A, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([101, 103, 102, 117, 115, 100, 97, 117]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: ABCDEFG-1F5A", () => {
|
||||
let suffix = checkSuffix("ABCDEFG", DellTag.Tag1F5A, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([0x74, 0x6e, 0x76, 0x75, 0x69, 0x6f, 0x74, 0x68]);
|
||||
});
|
||||
|
||||
// HDD
|
||||
it("Check hdd suffix for: 12345678901-595B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag595B, SuffixType.HDD);
|
||||
|
@ -144,8 +154,23 @@ describe("Test keygenDell", () => {
|
|||
});
|
||||
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");
|
||||
});
|
||||
|
||||
it("Dell password for: OPENSRC-1F5A", () => {
|
||||
expect(keygenDell("OPENSRC", DellTag.Tag1F5A, SuffixType.ServiceTag))
|
||||
.toEqual("ZC3j2t56eIe4Thgi");
|
||||
});
|
||||
|
||||
it("Dell password for: ABCDEFG-1F5A", () => {
|
||||
expect(keygenDell("ABCDEFG", DellTag.Tag1F5A, SuffixType.ServiceTag))
|
||||
.toEqual("x2zL5n7jj2Gl2TIh");
|
||||
});
|
||||
|
||||
// HDD
|
||||
it("Dell HDD password for: 1234567890A-595B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag595B, SuffixType.HDD))
|
||||
|
@ -175,6 +200,7 @@ describe("Test keygenDell", () => {
|
|||
expect(keygenDell("1234567890A", DellTag.Tag6FF1, SuffixType.HDD))
|
||||
.toEqual("5enLLpM3Immfb8CK");
|
||||
});
|
||||
// TODO: add HDD 1F5A
|
||||
});
|
||||
|
||||
describe("Test Dell BIOS", () => {
|
||||
|
|
|
@ -59,6 +59,7 @@ interface Encoder {
|
|||
encode(data: number[]): number[];
|
||||
}
|
||||
|
||||
// Maybe optimize ? return (((param2 >>> (0x20 - param7))) | (param2 << param7)) + num1;
|
||||
function rol(x: number, bitsrot: number): number {
|
||||
// n >>> 0 used to convert signed number to unsigned
|
||||
// (unsigned(x) >> (32 - bitsrot)) | (unsigned(x) << bitsrot);
|
||||
|
@ -168,7 +169,7 @@ class Tag595BEncoder {
|
|||
}
|
||||
|
||||
public result(): number[] {
|
||||
return this.encData.map((v) => v | 0);
|
||||
return this.encData.map((v) => (v | 0) >>> 0);
|
||||
}
|
||||
|
||||
public static encode(encBlock: number[]): number[] {
|
||||
|
@ -355,6 +356,60 @@ class Tag6FF1Encoder extends Tag595BEncoder {
|
|||
}
|
||||
}
|
||||
|
||||
class Tag1F5AEncoder extends Tag595BEncoder {
|
||||
protected md5table = md5magic2;
|
||||
protected f1 = encF1N;
|
||||
protected f2 = encF2N;
|
||||
protected f3 = encF3;
|
||||
protected f4 = encF4N;
|
||||
protected f5 = encF5N;
|
||||
|
||||
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++) {
|
||||
for (let j = 0; j < 64; j++) {
|
||||
let k = 12 + (j & 3) - (j & 12);
|
||||
switch (j >> 4) {
|
||||
case 0:
|
||||
t = this.calculate(this.f2, j & 15, j);
|
||||
break;
|
||||
case 1:
|
||||
t = this.calculate(this.f3, (j * 5 + 1) & 15, j);
|
||||
break;
|
||||
case 2:
|
||||
t = this.calculate(this.f4, (j * 3 + 5) & 15, k + 0x20);
|
||||
break;
|
||||
case 3:
|
||||
t = this.calculate(this.f5, (j * 7) & 15, k + 0x30);
|
||||
break;
|
||||
}
|
||||
this.B = this.D;
|
||||
this.D = this.A;
|
||||
this.A = this.C;
|
||||
this.C = rol(t, rotationTable[j >> 4][j & 3]) + this.C | 0;
|
||||
}
|
||||
|
||||
this.incrementData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const encoders: {readonly [P in DellTag]: Encoder} = {
|
||||
"595B": Tag595BEncoder,
|
||||
"2A7B": Tag595BEncoder, // same as 595B
|
||||
|
@ -362,7 +417,8 @@ const encoders: {readonly [P in DellTag]: Encoder} = {
|
|||
"1D3B": Tag1D3BEncoder,
|
||||
"D35B": TagD35BEncoder,
|
||||
"1F66": Tag1F66Encoder,
|
||||
"6FF1": Tag6FF1Encoder
|
||||
"6FF1": Tag6FF1Encoder,
|
||||
"1F5A": Tag1F5AEncoder
|
||||
};
|
||||
|
||||
export function blockEncode(encBlock: number[], tag: DellTag): number[] {
|
||||
|
|
|
@ -13,8 +13,11 @@ const encscans: number[] = [
|
|||
0x24, 0x23, 0x31, 0x20, 0x1E, 0x08, 0x2D, 0x21, 0x04, 0x0B, 0x12, 0x2E
|
||||
];
|
||||
|
||||
const asciiPrintable = "012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0";
|
||||
|
||||
const extraCharacters: {readonly [P in DellTag]?: string} = {
|
||||
"2A7B": "012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0",
|
||||
"2A7B": asciiPrintable,
|
||||
"1F5A": asciiPrintable,
|
||||
"1D3B": "0BfIUG1kuPvc8A9Nl5DLZYSno7Ka6HMgqsJWm65yCQR94b21OTp7VFX2z0jihE33d4xtrew0",
|
||||
"1F66": "0ewr3d4xtUG1ku0BfIp7VFb21OTSno7KDLZYqsJWa6HMgCQR94m65y9Nl5Pvc8AjihE3X2z0",
|
||||
"6FF1": "08rptBxfbGVMz38IiSoeb360MKcLf4QtBCbWVzmH5wmZUcRR5DZG2xNCEv1nFtzsZB2bw1X0"
|
||||
|
|
|
@ -6,7 +6,8 @@ export enum DellTag {
|
|||
TagA95B = "A95B",
|
||||
Tag1D3B = "1D3B",
|
||||
Tag6FF1 = "6FF1",
|
||||
Tag1F66 = "1F66"
|
||||
Tag1F66 = "1F66",
|
||||
Tag1F5A = "1F5A"
|
||||
}
|
||||
|
||||
export const enum SuffixType {
|
||||
|
|
Loading…
Reference in a new issue