add version validator

also make some variables const as they should
This commit is contained in:
DannyAAM 2023-07-15 04:41:01 +08:00 committed by lifehackerhansol
parent 401c681a0c
commit fb5ac3b3ae
No known key found for this signature in database
GPG key ID: 80FB184AFC0B3B0E

View file

@ -8,6 +8,36 @@
const DEVICE_N3DS = 1; const DEVICE_N3DS = 1;
const DEVICE_O3DS = 0; const DEVICE_O3DS = 0;
// Possible max minor for each major, major as key
const major_minor_map = {
0: -1, // invalidate all 0.x
1: 1,
2: 2,
3: 1,
4: 5,
5: 1,
6: 4,
7: 2,
8: 1,
9: 9,
10: 7,
11: 17
}
// Validate version
function validate_version(major, minor, native, region, model) {
if (model == DEVICE_N3DS && ["C", "T"].includes(region)) {
return false;
}
const minor_max = major_minor_map[major];
if (!isNaN(minor_max) && minor > minor_max) {
return false;
}
return true;
}
// Soundhax // Soundhax
// 1.0-11.3, all regions, all consoles // 1.0-11.3, all regions, all consoles
function can_soundhax(major, minor, native, region, model) { function can_soundhax(major, minor, native, region, model) {
@ -221,12 +251,12 @@ function is_o3ds_1117(major, minor, native, region, model) {
- Use alternate exploits; can't hack without any extra stuff - Use alternate exploits; can't hack without any extra stuff
*/ */
function redirect() { function redirect() {
let major = document.getElementById("major"); const major = document.getElementById("major").value;
let minor = document.getElementById("minor"); const minor = document.getElementById("minor").value;
let nver = document.getElementById("nver"); const nver = document.getElementById("nver").value;
let region = document.getElementById("region"); const region = document.getElementById("region").value;
let isN3DS = document.getElementById("new3DS").checked; const isN3DS = document.getElementById("new3DS").checked;
let isO3DS = document.getElementById("old3DS").checked; const isO3DS = document.getElementById("old3DS").checked;
document.getElementById("result_noneSelected").style.display = "none"; document.getElementById("result_noneSelected").style.display = "none";
document.getElementById("result_invalidVersion").style.display = "none"; document.getElementById("result_invalidVersion").style.display = "none";
document.getElementById("result_methodUnavailable").style.display = "none"; document.getElementById("result_methodUnavailable").style.display = "none";
@ -234,22 +264,18 @@ function redirect() {
document.getElementById("result_noneSelected").style.display = "block"; document.getElementById("result_noneSelected").style.display = "block";
return; return;
} }
else if (major.value == 0) {
document.getElementById("result_invalidVersion").style.display = "block";
return;
}
// Realistically only one of these should be possible with the given elements // Realistically only one of these should be possible with the given elements
let model = -1; let model = -1;
if(isO3DS) model = DEVICE_O3DS if(isO3DS) model = DEVICE_O3DS
else if(isN3DS) model = DEVICE_N3DS; else if(isN3DS) model = DEVICE_N3DS;
if (model == DEVICE_N3DS && ["C", "T"].includes(region.value)) { if (!validate_version(major, minor, nver, region, model)) {
document.getElementById("result_invalidVersion").style.display = "block"; document.getElementById("result_invalidVersion").style.display = "block";
return; return;
} }
let redirected = [ const redirected = [
can_soundhax, can_soundhax,
can_ssloth, can_ssloth,
can_safecerthax, can_safecerthax,
@ -257,7 +283,7 @@ function redirect() {
can_seedminer, can_seedminer,
can_superskaterhax, can_superskaterhax,
is_o3ds_1117 is_o3ds_1117
].some(func => func(major.value, minor.value, nver.value, region.value, model)); ].some(func => func(major, minor, nver, region, model));
if (redirected) return true; if (redirected) return true;
// if it actually got to this point, there is no exploit available. // if it actually got to this point, there is no exploit available.