Add typescript version for dell keygen
This commit is contained in:
1 parent
eaff9eaf70
commit
5a13261b47
2 files changed
+711
No files matched your search
@@ -0,0 +1,158 @@
|
||||
// OPENSRC-1D3B = S3yJ91q0Gar3O72I
|
||||
// ABCDEFG-1D3B xvn0qEeftqyrkG52
|
||||
// NOSOUP4-3A5B zvd97y9h
|
||||
// 7G9C0G2-6FF1 35c0b0tVb32Z6ivD
|
||||
//
|
||||
//
|
||||
// HDD SN WXH109A14712 ?
|
||||
import { calculateSuffix, DellTag, hddOldSolver, keygenDell, SuffixType } from "./dell";
|
||||
|
||||
// shortcut for simpler testing
|
||||
function checkSuffix(serial: string, tag: DellTag, type: SuffixType): number[] {
|
||||
serial = serial.concat(tag);
|
||||
let serialArr: number[] = serial.split("").map((c) => c.charCodeAt(0));
|
||||
return calculateSuffix(serialArr, tag, type);
|
||||
}
|
||||
|
||||
describe("Test calculateSuffix", () => {
|
||||
it("Check tag suffix for: 1234567-595B", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag595B, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-D35B", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.TagD35B, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-2A7B", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag2A7B, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([101, 103, 102, 117, 115, 100, 97, 117]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-A95B", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.TagA95B, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([25, 34, 38, 8, 32, 48, 23, 8]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-1D3B", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag1D3B, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([65, 78, 57, 72, 97, 56, 80, 72]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-6FF1", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag6FF1, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([51, 73, 56, 52, 76, 122, 71, 52]);
|
||||
});
|
||||
|
||||
it("Check tag suffix for: 1234567-1F66", () => {
|
||||
let suffix = checkSuffix("1234567", DellTag.Tag1F66, SuffixType.ServiceTag);
|
||||
expect(suffix).toEqual([117, 66, 48, 111, 83, 107, 85, 111]);
|
||||
});
|
||||
|
||||
// HDD
|
||||
it("Check hdd suffix for: 12345678901-595B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag595B, SuffixType.HDD);
|
||||
expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-D35B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.TagD35B, SuffixType.HDD);
|
||||
expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-2A7B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag2A7B, SuffixType.HDD);
|
||||
expect(suffix).toEqual([48, 51, 113, 98, 107, 48, 99, 115]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-A95B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.TagA95B, SuffixType.HDD);
|
||||
expect(suffix).toEqual([5, 9, 35, 6, 47, 5, 21, 32]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-1D3B", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag1D3B, SuffixType.HDD);
|
||||
expect(suffix).toEqual([48, 73, 55, 118, 76, 48, 99, 97]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-6FF1", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag6FF1, SuffixType.HDD);
|
||||
expect(suffix).toEqual([48, 112, 75, 86, 101, 48, 77, 76]);
|
||||
});
|
||||
|
||||
it("Check hdd suffix for: 12345678901-1F66", () => {
|
||||
let suffix = checkSuffix("12345678901", DellTag.Tag1F66, SuffixType.HDD);
|
||||
expect(suffix).toEqual([48, 114, 79, 71, 55, 48, 49, 83]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test keygenDell", () => {
|
||||
it("Dell password for: 1234567-595B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag595B, SuffixType.ServiceTag))
|
||||
.toEqual("46rg65ky");
|
||||
});
|
||||
it("Dell password for: 1234567-D35B", () => {
|
||||
expect(keygenDell("1234567", DellTag.TagD35B, SuffixType.ServiceTag))
|
||||
.toEqual("5tc8q9re");
|
||||
});
|
||||
it("Dell password for: 1234567-2A7B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag2A7B, SuffixType.ServiceTag))
|
||||
.toEqual("J1KuwWpSUgnDarfi");
|
||||
});
|
||||
it("Dell password for: 1234567-1D3B", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual("Sn4fkF8bS57NymZl");
|
||||
});
|
||||
it("Dell password for: 1234567-1F66", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag1F66, SuffixType.ServiceTag))
|
||||
.toEqual("kIpTBzx0m3s10JDR");
|
||||
});
|
||||
it("Dell password for: 1234567-6FF1", () => {
|
||||
expect(keygenDell("1234567", DellTag.Tag6FF1, SuffixType.ServiceTag))
|
||||
.toEqual("Rzn1wGe555H5bM2r");
|
||||
});
|
||||
it("Dell password for: OPENSRC-1D3B", () => {
|
||||
expect(keygenDell("OPENSRC", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual("S3yJ91q0Gar3O72I");
|
||||
});
|
||||
it("Dell password for: ABCDEFG-1D3B", () => {
|
||||
expect(keygenDell("ABCDEFG", DellTag.Tag1D3B, SuffixType.ServiceTag))
|
||||
.toEqual("xvn0qEeftqyrkG52");
|
||||
});
|
||||
it("Dell password for: 7G9C0G2-6FF1", () => {
|
||||
expect(keygenDell("7G9C0G2", DellTag.Tag6FF1, SuffixType.ServiceTag))
|
||||
.toEqual("35c0b0tVb32Z6ivD");
|
||||
});
|
||||
// HDD
|
||||
it("Dell HDD password for: 1234567890A-595B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag595B, SuffixType.HDD))
|
||||
.toEqual("nyoap4lq");
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-D35B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.TagD35B, SuffixType.HDD))
|
||||
.toEqual("dc14blrd");
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-2A7B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag2A7B, SuffixType.HDD))
|
||||
.toEqual("h6lwdi91qluUyt3u");
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-1D3B", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag1D3B, SuffixType.HDD))
|
||||
.toEqual("6JQ1WacHNNR0Taia");
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-1F66", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag1F66, SuffixType.HDD))
|
||||
.toEqual("vP0M31x066Z7Rq9p");
|
||||
});
|
||||
it("Dell HDD password for: 1234567890A-6FF1", () => {
|
||||
expect(keygenDell("1234567890A", DellTag.Tag6FF1, SuffixType.HDD))
|
||||
.toEqual("5enLLpM3Immfb8CK");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test Dell BIOS", () => {
|
||||
it("Dell for 12345678901 is yyyyyhnn", () => {
|
||||
expect(hddOldSolver("12345678901")).toEqual(["yyyyyhnn"]);
|
||||
});
|
||||
});
|
||||
+553
@@ -0,0 +1,553 @@
|
||||
/* tslint:disable:no-bitwise */
|
||||
import { makeSolver } from "./utils";
|
||||
|
||||
const scanCodes: string =
|
||||
"\0\x1B1234567890-=\x08\x09qwertyuiop[]\x0D\xFFasdfghjkl;'`\xFF\\zxcvbnm,./";
|
||||
|
||||
const encscans: number[] = [
|
||||
0x05, 0x10, 0x13, 0x09, 0x32, 0x03, 0x25, 0x11, 0x1F, 0x17, 0x06, 0x15,
|
||||
0x30, 0x19, 0x26, 0x22, 0x0A, 0x02, 0x2C, 0x2F, 0x16, 0x14, 0x07, 0x18,
|
||||
0x24, 0x23, 0x31, 0x20, 0x1E, 0x08, 0x2D, 0x21, 0x04, 0x0B, 0x12, 0x2E
|
||||
];
|
||||
|
||||
const extraCharacters: {[key: string]: string} = {
|
||||
"2A7B": "012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0",
|
||||
"1D3B": "0BfIUG1kuPvc8A9Nl5DLZYSno7Ka6HMgqsJWm65yCQR94b21OTp7VFX2z0jihE33d4xtrew0",
|
||||
"1F66": "0ewr3d4xtUG1ku0BfIp7VFb21OTSno7KDLZYqsJWa6HMgCQR94m65y9Nl5Pvc8AjihE3X2z0",
|
||||
"6FF1": "08rptBxfbGVMz38IiSoeb360MKcLf4QtBCbWVzmH5wmZUcRR5DZG2xNCEv1nFtzsZB2bw1X0"
|
||||
};
|
||||
|
||||
const md5magic = [
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
|
||||
].map((v) => v | 0);
|
||||
|
||||
const md5magic2 = [
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039
|
||||
].map((v) => v | 0);
|
||||
|
||||
export enum DellTag {
|
||||
Tag595B = "595B",
|
||||
TagD35B = "D35B",
|
||||
Tag2A7B = "2A7B",
|
||||
TagA95B = "A95B",
|
||||
Tag1D3B = "1D3B",
|
||||
Tag6FF1 = "6FF1",
|
||||
Tag1F66 = "1F66"
|
||||
}
|
||||
|
||||
export const enum SuffixType {
|
||||
ServiceTag,
|
||||
HDD
|
||||
}
|
||||
|
||||
/*
|
||||
* Does this really work somewhere ?
|
||||
* Depends only in first two chars
|
||||
* Input: 11 symbols
|
||||
*/
|
||||
function keygenHddOld(serial: string): string {
|
||||
let serialArr: number[] = serial.split("").map((c) => c.charCodeAt(0));
|
||||
// encscans[26], encscans[0xAA % encscans.length]
|
||||
let ret: number[] = [49, 49, 49, 49, 49];
|
||||
ret.push(serialArr[1] >> 1);
|
||||
ret.push((serialArr[1] >> 6) | (serialArr[0] << 2));
|
||||
ret.push(serialArr[0] >> 3);
|
||||
// lower bits then 5 are never change
|
||||
for (let i = 0; i < 8; i++) {
|
||||
let r = 0xAA;
|
||||
if (ret[i] & 8) {
|
||||
r ^= serialArr[1];
|
||||
}
|
||||
if (ret[i] & 16) {
|
||||
r ^= serialArr[0];
|
||||
}
|
||||
ret[i] = encscans[r % encscans.length];
|
||||
}
|
||||
return ret.map((c) => scanCodes.charAt(c)).join("");
|
||||
}
|
||||
|
||||
export function calculateSuffix(serial: number[], tag: DellTag, type: SuffixType): number[] {
|
||||
let suffix: number[] = [];
|
||||
let codesTable: number[];
|
||||
let arr1: number[];
|
||||
let arr2: number[];
|
||||
|
||||
if (type === SuffixType.ServiceTag) {
|
||||
arr1 = [1, 2, 3, 4];
|
||||
arr2 = [4, 3, 2];
|
||||
} else {
|
||||
// SuffixType.HDD
|
||||
arr1 = [1, 10, 9, 8];
|
||||
arr2 = [8, 9, 10];
|
||||
}
|
||||
|
||||
suffix[0] = serial[arr1[3]];
|
||||
suffix[1] = (serial[arr1[3]] >> 5) |
|
||||
(((serial[arr1[2]] >> 5) | (serial[arr1[2]] << 3)) & 0xF1);
|
||||
suffix[2] = serial[arr1[2]] >> 2;
|
||||
suffix[3] = (serial[arr1[2]] >> 7) | (serial[arr1[1]] << 1);
|
||||
suffix[4] = (serial[arr1[1]] >> 4) | (serial[arr1[0]] << 4);
|
||||
suffix[5] = serial[1] >> 1;
|
||||
suffix[6] = (serial[1] >> 6) | (serial[0] << 2);
|
||||
suffix[7] = serial[0] >> 3;
|
||||
|
||||
// normalize bytes
|
||||
suffix.forEach((v, i) => {
|
||||
suffix[i] = v & 0xFF;
|
||||
});
|
||||
|
||||
if ((tag as string) in extraCharacters) {
|
||||
codesTable = extraCharacters[tag as string].split("").map((s) => s.charCodeAt(0));
|
||||
} else {
|
||||
codesTable = encscans;
|
||||
}
|
||||
|
||||
for (let i = 0; i < 8; i++) {
|
||||
let r = 0xAA;
|
||||
if (suffix[i] & 1) {
|
||||
r ^= serial[arr2[0] ];
|
||||
}
|
||||
if (suffix[i] & 2) {
|
||||
r ^= serial[arr2[1]];
|
||||
}
|
||||
if (suffix[i] & 4) {
|
||||
r ^= serial[arr2[2]];
|
||||
}
|
||||
if (suffix[i] & 8) {
|
||||
r ^= serial[1];
|
||||
}
|
||||
if (suffix[i] & 16) {
|
||||
r ^= serial[0];
|
||||
}
|
||||
|
||||
suffix[i] = codesTable[r % codesTable.length];
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
function blockEncode(encBlock: number[], f1: any, f2: any, f3: any, f4: any, f5: any, repeater: number) {
|
||||
// reinit each run
|
||||
let encData = [ 0x67452301 | 0, 0xEFCDAB89 | 0, 0x98BADCFE | 0, 0x10325476 | 0];
|
||||
|
||||
let A = encData[0] | 0; // For bit alignment
|
||||
let B = encData[1] | 0;
|
||||
let C = encData[2] | 0;
|
||||
let D = encData[3] | 0;
|
||||
|
||||
function rol(t: number, bitsrot: number): number {
|
||||
// n >>> 0 used to convert signed number to unsigned
|
||||
return ((t >>> 0)/ Math.pow(2, 32 - bitsrot)) |
|
||||
(((t >>> 0) << bitsrot) | 0 );
|
||||
}
|
||||
function f_shortcut(func: any, key: number, num: number): number {
|
||||
return (A + f1(func, B, C , D, md5magic[num] + encBlock[ key ])) | 0;
|
||||
}
|
||||
function f_shortcut2(func: any, key: number, num: number): number {
|
||||
return (A + f1(func, B, C, D, md5magic2[num] + encBlock[key])) | 0;
|
||||
}
|
||||
|
||||
let S = [ [ 7, 12, 17, 22 ],
|
||||
[ 5, 9, 14, 20 ],
|
||||
[ 4, 11, 16, 23 ],
|
||||
[ 6, 10, 15, 21 ] ];
|
||||
let t: number = 0;
|
||||
|
||||
for (let j=0; j<=repeater; j++) {
|
||||
if (repeater == 16) { // 1f66
|
||||
A |= 0x00100097;
|
||||
B ^= 0x000A0008;
|
||||
C |= (0x60606161 - j);
|
||||
D ^= (0x50501010 + j);
|
||||
for (let i = 0; i < 4; i++) {
|
||||
t = f_shortcut2(f2, (i * 4) & 15, 16 + (i * 4) | 0);
|
||||
A = D; D = C; C = B; B = (rol(t, S[0][0]) + B) | 0;
|
||||
|
||||
t = f_shortcut2(f2, (i*4+1) & 15, 16+(i*4)+1 | 0);
|
||||
A = D; D = C; C = B; B = (rol(t,S[0][1]) + B) | 0;
|
||||
|
||||
t=f_shortcut2(f2,(i*4+2) & 15, 16+(i*4)+2|0);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][2]) + B) | 0;
|
||||
|
||||
t = f_shortcut2(f2,(i*4+3) & 15, 16+(i*4)+3|0);
|
||||
A = D; D = C; C = B; B = (rol(t,S[0][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f3, i * 4 + 1, 48+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][0]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4+6)&15,48+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][1]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4-5)&15,48+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][2]) + B) | 0;
|
||||
t=f_shortcut2(f3,i*4 ,48+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f4,(i*4-7)&15,32+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][0]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-4)&15,32+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][1]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-1)&15,32+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][2]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4+2) ,32+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f5,(i*4+4)&15, 0+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][0]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-5)&15, 0+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][1]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4+2) , 0+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][2]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-7)&15, 0+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][3]) + B) | 0;
|
||||
}
|
||||
} else if (repeater == 22) {
|
||||
A|=0x00A08097;
|
||||
B^=0x0A010908;
|
||||
C|=(0x60606161 - j);
|
||||
D^=(0x50501010 + j);
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f2,(i*4 ) & 15,32+(i*4) |0);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][0]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+1) & 15,32+(i*4)+1|0);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][1]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+2) & 15,32+(i*4)+2|0);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][2]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+3) & 15,32+(i*4)+3|0);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f3,(i*4+1) , 0+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][0]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4+6)&15, 0+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][1]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4-5)&15, 0+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][2]) + B) | 0;
|
||||
t=f_shortcut2(f3,i*4 , 0+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f4,(i*4-7)&15,16+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][0]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-4)&15,16+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][1]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-1)&15,16+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][2]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4+2) ,16+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f5,(i*4+4)&15,48+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][0]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-5)&15,48+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][1]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4+2) ,48+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][2]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-7)&15,48+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][3]) + B) | 0;
|
||||
}
|
||||
} else {
|
||||
if (repeater) {
|
||||
A |=0x97;
|
||||
B ^=0x8;
|
||||
C |=(0x60606161 - j);
|
||||
D ^=(0x50501010 + j);
|
||||
}
|
||||
for(let i=0;i<64;i++){
|
||||
switch(i >> 4){
|
||||
case 0:
|
||||
t = f_shortcut(f2, i & 15, i); // Use half byte
|
||||
break;
|
||||
case 1:
|
||||
t = f_shortcut(f3, (i*5 + 1) & 15, i);
|
||||
break;
|
||||
case 2:
|
||||
t = f_shortcut(f4, (i*3 + 5) & 15, i);
|
||||
break;
|
||||
case 3:
|
||||
t = f_shortcut(f5, (i*7) & 15, i);
|
||||
break;
|
||||
}
|
||||
A = D, D = C, C = B, B = (rol(t, S[i >> 4][i & 3]) + B) | 0;
|
||||
}
|
||||
}
|
||||
encData[0]+=A;
|
||||
encData[1]+=B;
|
||||
encData[2]+=C;
|
||||
encData[3]+=D;
|
||||
}
|
||||
if (repeater == 16) { //1f66
|
||||
for(let j=0;j<=20;j++){ //1d3b
|
||||
A|=0x97;
|
||||
B^=0x8;
|
||||
C|=(0x50501010 - j);
|
||||
D^=(0x60606161 + j);
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f4,(i*4-7) & 15,32+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][0]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-4) & 15,32+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][1]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-1) & 15,32+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][2]) + B) | 0;
|
||||
t=f_shortcut2(f4,i*4+2,32+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f5,(i*4+4) & 15,48+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][0]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-5) & 15,48+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][1]) + B) | 0;
|
||||
t=f_shortcut2(f5,i*4+2,48+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][2]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-7) & 15,48+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f2,(i*4 ) & 15, 0+(i*4));
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][0]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+1) & 15, 0+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][1]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+2) & 15, 0+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][2]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+3) & 15, 0+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f3,(i*4+1),16+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][0]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4+6) & 15,16+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][1]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4-5) & 15,16+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][2]) + B) | 0;
|
||||
t=f_shortcut2(f3,i*4,16+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][3]) + B) | 0;
|
||||
}
|
||||
encData[0]+=A;
|
||||
encData[1]+=B;
|
||||
encData[2]+=C;
|
||||
encData[3]+=D;
|
||||
}
|
||||
} else if (repeater == 22) {
|
||||
for(let j=0;j<=16;j++){
|
||||
A|=0x00100097;
|
||||
B^=0x000A0008;
|
||||
C|=(0x50501010 - j);
|
||||
D^=(0x60606161 + j);
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f4,(i*4-7) & 15,16+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][0]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-4) & 15,16+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][1]) + B) | 0;
|
||||
t=f_shortcut2(f4,(i*4-1) & 15,16+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][2]) + B) | 0;
|
||||
t=f_shortcut2(f4,i*4+2,16+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[2][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f5,(i*4+4) & 15,32+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][0]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-5) & 15,32+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][1]) + B) | 0;
|
||||
t=f_shortcut2(f5,i*4+2,32+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][2]) + B) | 0;
|
||||
t=f_shortcut2(f5,(i*4-7) & 15,32+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[3][3]) + B) | 0;
|
||||
}
|
||||
for (let i=3;i>=0;i--) {
|
||||
t=f_shortcut2(f2,(i*4 ) & 15, 0+(i*4));
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][0]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+1) & 15, 0+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][1]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+2) & 15, 0+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][2]) + B) | 0;
|
||||
t=f_shortcut2(f2,(i*4+3) & 15, 0+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[0][3]) + B) | 0;
|
||||
}
|
||||
for (let i=0;i<4;i++) {
|
||||
t=f_shortcut2(f3,(i*4+1),48+(i*4) );
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][0]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4+6) & 15,48+(i*4)+1);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][1]) + B) | 0;
|
||||
t=f_shortcut2(f3,(i*4-5) & 15,48+(i*4)+2);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][2]) + B) | 0;
|
||||
t=f_shortcut2(f3,i*4,48+(i*4)+3);
|
||||
A=D; D=C; C=B; B=(rol(t,S[1][3]) + B) | 0;
|
||||
}
|
||||
encData[0]+=A;
|
||||
encData[1]+=B;
|
||||
encData[2]+=C;
|
||||
encData[3]+=D;
|
||||
}
|
||||
}
|
||||
return encData.map((v) => v | 0);
|
||||
}
|
||||
|
||||
function choseEncode(encBlock: number[], tag: DellTag): number[] {
|
||||
|
||||
function encF2(num1: number, num2: number, num3: number): number {
|
||||
return ((( num3 ^ num2) & num1) ^ num3);
|
||||
}
|
||||
|
||||
function encF3 (num1: number, num2: number, num3: number): number {
|
||||
return ((( num1 ^ num2) & num3) ^ num2);
|
||||
}
|
||||
|
||||
function encF4(num1: number, num2: number, num3: number): number {
|
||||
return (( num2 ^ num1) ^ num3);
|
||||
}
|
||||
|
||||
function encF5(num1: number, num2: number, num3: number): number {
|
||||
return (( num1 | ~num3) ^ num2);
|
||||
}
|
||||
|
||||
function encF1(func: any, num1: number, num2: number, num3: number, key: number) {
|
||||
return (func(num1,num2,num3) + key) | 0; // For bit alignment
|
||||
}
|
||||
|
||||
// Negative functions
|
||||
function encF1N(func: any, num1: number, num2: number, num3: number, key: number) {
|
||||
return encF1(func,num1,num2, num3, -key);
|
||||
}
|
||||
function encF2N(num1: number, num2: number, num3: number) {
|
||||
return encF2(num1, num2, ~num3);
|
||||
}
|
||||
|
||||
function encF4N(num1: number, num2: number, num3: number) {
|
||||
return encF4(num1, ~num2, num3);
|
||||
}
|
||||
|
||||
function encF5N(num1: number, num2: number, num3: number) {
|
||||
return encF5(~num1, num2, num3);
|
||||
}
|
||||
|
||||
/* Main part */
|
||||
if (tag === DellTag.TagD35B) {
|
||||
return blockEncode(encBlock, encF1, encF2, encF3, encF4, encF5,0);
|
||||
} else if (tag === DellTag.Tag1D3B) {
|
||||
return blockEncode(encBlock, encF1N, encF2N, encF3, encF4N, encF5N,20);
|
||||
} else if (tag === DellTag.Tag1F66) {
|
||||
return blockEncode(encBlock, encF1N, encF2N, encF3, encF4N, encF5N,16);
|
||||
} else if (tag === DellTag.Tag6FF1) {
|
||||
return blockEncode(encBlock, encF1N, encF2N, encF3, encF4N, encF5N,22);
|
||||
} else {
|
||||
return blockEncode(encBlock, encF1N, encF2N, encF3, encF4N, encF5N,0);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 7 symbols + 4 symbols ( 595B, D35B, 2A7B, A95B, 1D3B etc...)
|
||||
* serial -- serial number without tag, 7 symbols for ServiceTag, 11 symbols for HDD
|
||||
* tag -- tag string
|
||||
*/
|
||||
export function keygenDell(serial: string, tag: DellTag, type: SuffixType): string {
|
||||
let fullSerial: string;
|
||||
|
||||
function byteArrayToInt(arr: number[]): number[] {
|
||||
// convert byte array to 32-bit little-endian int array
|
||||
// also will convert undefined values to 0
|
||||
let resultLength = arr.length >> 2; // divide length to 4
|
||||
let result: number[] = [];
|
||||
for (let i = 0; i <= resultLength; i++) {
|
||||
result[i] = arr[i * 4] | (arr[i * 4 + 1] << 8) |
|
||||
(arr[i * 4 + 2] << 16) | (arr[i * 4 + 3] << 24) | 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function intArrayToByte(arr: number[]): number[] {
|
||||
// convert 32-bit little-endian array to byte array
|
||||
let result: number[] = [];
|
||||
arr.forEach((num) => {
|
||||
result.push(num & 0xFF);
|
||||
result.push((num >> 8) & 0xFF);
|
||||
result.push((num >> 16) & 0xFF);
|
||||
result.push((num >> 24) & 0xFF);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function resultToString(arr: number[], tag: DellTag): string {
|
||||
let r = arr[0] % 9;
|
||||
let result = "";
|
||||
for (let i = 0; i < 16; i++) {
|
||||
if ((tag as string) in extraCharacters) {
|
||||
let table = extraCharacters[tag as string];
|
||||
result += table.charAt(arr[i] % table.length);
|
||||
} else if (r <= i && result.length < 8) { // 595B, D35B, A95B
|
||||
result += scanCodes.charAt(encscans[arr[i] % encscans.length]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (tag === DellTag.TagA95B) {
|
||||
|
||||
if (type === SuffixType.ServiceTag) {
|
||||
fullSerial = serial + DellTag.Tag595B as string;
|
||||
} else { // HDD
|
||||
fullSerial = serial.slice(3) + "\0\0\0" + DellTag.Tag595B as string;
|
||||
}
|
||||
|
||||
} else {
|
||||
fullSerial = serial + tag as string;
|
||||
}
|
||||
|
||||
let fullSerialArray: number[] = [];
|
||||
// convert string to byte array
|
||||
for (let i = 0; i < fullSerial.length; i++) {
|
||||
// Maybe protect against unicode symbols with: charCode & 0xFF ?
|
||||
fullSerialArray.push(fullSerial.charCodeAt(i));
|
||||
}
|
||||
|
||||
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);
|
||||
// fill empty values with zeros
|
||||
for (let i = 0; i < 16; i++) {
|
||||
if (encBlock[i] === undefined) {
|
||||
encBlock[i] = 0;
|
||||
}
|
||||
}
|
||||
encBlock[14] = cnt << 3;
|
||||
let decodedBytes = intArrayToByte(choseEncode(encBlock, tag));
|
||||
return resultToString(decodedBytes, tag);
|
||||
}
|
||||
|
||||
export let hddOldSolver = makeSolver({
|
||||
name: "Dell HDD Serial Number (old)",
|
||||
examples: ["12345678901"],
|
||||
inputValidator: (s) => s.length === 11,
|
||||
fun: (s) => [keygenHddOld(s)]
|
||||
});
|
||||
Reference in new issue
Block a user