Add dell input validator and solver
This commit is contained in:
1 parent
1b6d781bd1
commit
fa4b6c4f61
2 files changed
+57
-1
No files matched your search
+15
-1
@@ -5,7 +5,9 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// HDD SN WXH109A14712 ?
|
// HDD SN WXH109A14712 ?
|
||||||
import { calculateSuffix, DellTag, hddOldSolver, keygenDell, SuffixType } from "./dell";
|
import {
|
||||||
|
calculateSuffix, dellHddSolver, dellSolver, DellTag, hddOldSolver, keygenDell, SuffixType
|
||||||
|
} from "./dell";
|
||||||
|
|
||||||
// shortcut for simpler testing
|
// shortcut for simpler testing
|
||||||
function checkSuffix(serial: string, tag: DellTag, type: SuffixType): number[] {
|
function checkSuffix(serial: string, tag: DellTag, type: SuffixType): number[] {
|
||||||
@@ -171,4 +173,16 @@ describe("Test Dell BIOS", () => {
|
|||||||
it("Dell for 12345678901 is yyyyyhnn", () => {
|
it("Dell for 12345678901 is yyyyyhnn", () => {
|
||||||
expect(hddOldSolver("12345678901")).toEqual(["yyyyyhnn"]);
|
expect(hddOldSolver("12345678901")).toEqual(["yyyyyhnn"]);
|
||||||
});
|
});
|
||||||
|
it("Dell for 1234567-595B", () => {
|
||||||
|
expect(dellSolver("1234567-595B")).toEqual(["46rg65ky"]);
|
||||||
|
});
|
||||||
|
it("Dell for: 1234567-1F66", () => {
|
||||||
|
expect(dellSolver("1234567-1f66")).toEqual(["kIpTBzx0m3s10JDR"]);
|
||||||
|
});
|
||||||
|
it("Dell HDD for: 1234567890A-595B", () => {
|
||||||
|
expect(dellHddSolver("1234567890A-595b")).toEqual(["nyoap4lq"]);
|
||||||
|
});
|
||||||
|
it("Check bad dell tag", () => {
|
||||||
|
expect(dellSolver("1234567-BAD1")).toEqual([]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -187,9 +187,51 @@ export function keygenDell(serial: string, tag: DellTag, type: SuffixType): stri
|
|||||||
return resultToString(decodedBytes, tag);
|
return resultToString(decodedBytes, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkDellTag(tag: string): boolean {
|
||||||
|
tag = tag.toUpperCase();
|
||||||
|
for (let tagItem in DellTag) {
|
||||||
|
if (tag === DellTag[tagItem]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export let hddOldSolver = makeSolver({
|
export let hddOldSolver = makeSolver({
|
||||||
name: "Dell HDD Serial Number (old)",
|
name: "Dell HDD Serial Number (old)",
|
||||||
examples: ["12345678901"],
|
examples: ["12345678901"],
|
||||||
inputValidator: (s) => s.length === 11,
|
inputValidator: (s) => s.length === 11,
|
||||||
fun: (s) => [keygenHddOld(s)]
|
fun: (s) => [keygenHddOld(s)]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export let dellSolver = makeSolver({
|
||||||
|
name: "Dell from serial number",
|
||||||
|
examples: ["1234567-595B", "1234567-1D3B"],
|
||||||
|
inputValidator: (password: string) => {
|
||||||
|
if (password.length !== 11) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return checkDellTag(password.slice(7, 11));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fun: (password: string) => {
|
||||||
|
let suffix = password.slice(7, 11).toUpperCase();
|
||||||
|
return [keygenDell(password.slice(0, 7), suffix as DellTag, SuffixType.ServiceTag)];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export let dellHddSolver = makeSolver({
|
||||||
|
name: "Dell from hdd serial number",
|
||||||
|
examples: ["1234567890A-595B"],
|
||||||
|
inputValidator: (password: string) => {
|
||||||
|
if (password.length !== 15) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return checkDellTag(password.slice(11, 15));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fun: (password: string) => {
|
||||||
|
let suffix = password.slice(11, 15).toUpperCase();
|
||||||
|
return [keygenDell(password.slice(0, 11), suffix as DellTag, SuffixType.HDD)];
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in new issue
Block a user