Last active
July 21, 2020 02:58
-
-
Save hieulw/7b9555399848753b425bb016692f41c3 to your computer and use it in GitHub Desktop.
giải bài crackme4.exe môn Hacking Exposed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getKeyInfo(key) { | |
| key = key.toString(); | |
| if (key.length != 16) return false; | |
| sum = 0; | |
| for (let i = 10, len = key.length; i < len; i++) { | |
| sum += Number(key[i]); | |
| } | |
| if (sum < 0 || sum > 54) return false; | |
| sum = Number(key.substr(8, 2)) - sum; | |
| if (sum < 0 || sum > 99) return false; | |
| text = key.substr(0, 8) + (sum < 10 ? "0" + sum : sum) + key.substr(10, 6); | |
| s1 = parseInt(text.substr(0, 8), 10).toString(2).padStart(24, "0"); | |
| s2 = parseInt(text.substr(8, 8), 10).toString(2).padStart(24, "0"); | |
| str = ""; | |
| int1 = 0; | |
| for (let i = 0; i < 3; i++) { | |
| s = s1.substr(int1, 8); | |
| s = s.substr(1, 7) + s.substr(0, 1); | |
| tmp1 = parseInt(s.substr(0, 4), 2).toString(16); | |
| tmp2 = parseInt(s.substr(4, 4), 2).toString(16); | |
| str = str + tmp1 + tmp2; | |
| int1 += 8; | |
| } | |
| int2 = 0; | |
| for (let i = 0; i < 3; i++) { | |
| s = s2.substr(int2, 8); | |
| s = s.substr(1, 7) + s.substr(0, 1); | |
| tmp1 = parseInt(s.substr(0, 4), 2).toString(16); | |
| tmp2 = parseInt(s.substr(4, 4), 2).toString(16); | |
| str = str + tmp1 + tmp2; | |
| int2 += 8; | |
| } | |
| return str.toUpperCase(); | |
| } | |
| function getModelCode(RegNo) { | |
| if (RegNo.length != 12) { | |
| return false; | |
| } | |
| result = RegNo[8] + RegNo[3] + RegNo[9] + RegNo[2]; | |
| return result; | |
| } | |
| function getSeqCode(RegNo) { | |
| if (RegNo.length != 12) { | |
| return false; | |
| } | |
| result = RegNo[11] + RegNo[10] + RegNo[1] + RegNo[6]; | |
| return result; | |
| } | |
| function getMacAddress(RegNo) { | |
| if (RegNo.length != 12) { | |
| return false; | |
| } | |
| result = RegNo[5] + RegNo[4] + RegNo[7] + RegNo[0]; | |
| return result; | |
| } | |
| function getSecretFromRegNo(key) { | |
| if (key.length !== 12) return false; | |
| binary = parseInt(key, 16).toString(2).padStart(48, "0"); | |
| reverse = ""; | |
| for (let i = 0; i < binary.length; i += 8) { | |
| tmp = binary.substr(i, 8); | |
| tmp = tmp.substr(-1) + tmp.substr(0, 7); | |
| reverse += tmp; | |
| } | |
| s1 = parseInt(reverse.substr(0, 24), 2).toString(10).padStart(8, "0"); | |
| s2 = parseInt(reverse.substr(24, 24), 2).toString(10).padStart(8, "0"); | |
| sum = | |
| Number(s2.substr(0, 2)) + | |
| s2 | |
| .substr(-6) | |
| .split("") | |
| .reduce((a, b) => Number(a) + Number(b)); | |
| if (sum < 0 || sum > 99) return false; | |
| s2 = sum.toString() + s2.substr(-6); | |
| result = s1 + s2; | |
| return result.length === 16 ? result : false; | |
| } | |
| function getSecretFromMSSV(code) { | |
| code = code.toString(); | |
| arr = "0".repeat(12).split(""); | |
| arr[8] = code[0]; | |
| arr[3] = code[1]; | |
| arr[9] = code[2]; | |
| arr[2] = code[3]; | |
| arr[5] = code.substr(-4, 1); | |
| arr[4] = code.substr(-3, 1); | |
| arr[7] = code.substr(-2, 1); | |
| arr[0] = code.substr(-1); | |
| // for (let i = 0; i <= 65535; i++) { | |
| // seq = parseInt(i, 10).toString(16).padStart(4, "0"); | |
| // arr[1] = seq[0]; | |
| // arr[6] = seq[1]; | |
| // arr[10] = seq[2]; | |
| // arr[11] = seq[3]; | |
| regCode = arr.join(""); | |
| secretCode = getSecretFromRegNo(regCode); | |
| if (secretCode != false) { | |
| return secretCode; | |
| } | |
| // } | |
| return false; | |
| } | |
| const MSSV = "2320114961"; | |
| const Secret = getSecretFromMSSV(MSSV); | |
| const RegNo = getKeyInfo(Secret); | |
| const Mod = getModelCode(RegNo); | |
| const Seq = getSeqCode(RegNo); | |
| const Mac = getMacAddress(RegNo); | |
| if (MSSV.substr(0, 4) == Mod && MSSV.substr(6, 4) == Mac) { | |
| console.log(`Secret code: ${Secret}`); | |
| console.log(RegNo); | |
| console.log(`${MSSV.substr(0, 4)} === ${Mod}`); | |
| console.log(`${MSSV.substr(6, 4)} === ${Mac}`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment