Last active
November 22, 2023 21:16
-
-
Save Staninna/a283602d6c8a76cf9ebba1f8705189d7 to your computer and use it in GitHub Desktop.
https://oldmartijntje.nl Clicker-game save cracker
This file contains 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
// This version works on this version of the site <https://github.com/oldmartijntje/playtime/tree/c67261f1f53570cf737f0711bcae66c112e17155> | |
class Encryptor { | |
stringToAsciiList(str) { | |
const asciiList = []; | |
for (let i = 0; i < str.length; i++) { | |
const asciiValue = str.charCodeAt(i); | |
asciiList.push(asciiValue); | |
} | |
return asciiList; | |
} | |
asciiListToString(asciiList) { | |
return asciiList.map(asciiValue => String.fromCharCode(asciiValue)).join(''); | |
} | |
decryptString(encryptedString, encryptionKey) { | |
const encryptedList = encryptedString.split(',').map(value => parseInt(value, 10)); | |
const asciiList = encryptedList.map(value => value / encryptionKey); | |
return this.asciiListToString(asciiList); | |
} | |
} | |
function getNextEnumeration(previousNumber) { | |
if (previousNumber > 0) { | |
return -previousNumber; | |
} else if (previousNumber < 0) { | |
return Math.abs(previousNumber) + 1; | |
} else { | |
return 1; | |
} | |
} | |
const encryptor = new Encryptor(); | |
const encryptedData = localStorage.getItem('clickerGame'); | |
// Alert user to confirm encrypted data | |
if (confirm('Confirm the encrypted data: ' + encryptedData)) { | |
let encryptionKey = 0; | |
let decryptedString = ''; | |
let successfulDecryption = false; | |
while (!successfulDecryption && encryptionKey <= 1000) { | |
if (encryptionKey !== 0) { | |
decryptedString = encryptor.decryptString(encryptedData, encryptionKey); | |
if (decryptedString !== '') { | |
// Check if decrypted string is valid JSON | |
try { | |
const jsonData = JSON.parse(decryptedString); | |
successfulDecryption = true; | |
console.log('Decrypted Successfully!'); | |
console.log('Decrypted Data:', jsonData); | |
console.log('Encryption Key:', encryptionKey); | |
} catch (error) { | |
// Invalid JSON, continue decryption | |
encryptionKey = getNextEnumeration(encryptionKey); | |
} | |
} else { | |
encryptionKey = getNextEnumeration(encryptionKey); | |
} | |
} else { | |
encryptionKey = 1; | |
} | |
} | |
if (!successfulDecryption) { | |
console.log('Failed to decrypt or invalid JSON.'); | |
} | |
} else { | |
console.log('User declined to confirm encrypted data.'); | |
} |
This file contains 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
// This version works on this version of the site <https://github.com/oldmartijntje/oldmartijntje.nl-client/tree/2587ef8354db5f5aff74938e2754adac0fadeb77> | |
class Encryptor { | |
stringToAsciiList(str) { | |
const asciiList = []; | |
for (let i = 0; i < str.length; i++) { | |
const asciiValue = str.charCodeAt(i); | |
asciiList.push(asciiValue); | |
} | |
return asciiList; | |
} | |
asciiListToString(asciiList) { | |
return asciiList.map((asciiValue) => String.fromCharCode(asciiValue)).join(""); | |
} | |
multiplyAsciiList(asciiList, multiplier) { | |
return asciiList.map((asciiValue) => asciiValue * multiplier); | |
} | |
devideAsciiList(asciiList, divisor) { | |
return asciiList.map((asciiValue) => asciiValue / divisor); | |
} | |
encryptString(inputString, encryptionKey, encryptionModifier) { | |
const secret = this.getRandomNumber(0, 10000); | |
const asciiList = this.multiplyAsciiList( | |
this.stringToAsciiList(inputString), | |
secret | |
); | |
const encryptedList = asciiList.map((value) => value * encryptionKey); | |
let temp = encryptedList.join(","); | |
temp += `,${secret * secret}${encryptionModifier}`; | |
return temp; | |
} | |
getRandomNumber(min, max) { | |
if (min >= max) { | |
return -1; | |
} | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
removeSuffix(input, encryptionModifier) { | |
if (input.length >= encryptionModifier.toString().length) { | |
return input.substring( | |
0, | |
input.length - encryptionModifier.toString().length | |
); | |
} else { | |
return "Invalid input"; | |
} | |
} | |
decryptString(encryptedString, encryptionKey, encryptionModifier) { | |
const data = this.splitLastComma(encryptedString); | |
data[1] = this.removeSuffix(data[1], encryptionModifier); | |
const root = Math.sqrt(parseInt(data[1])); | |
const encryptedList = data[0].split(",").map((value) => parseInt(value, 10)); | |
const devidedData = this.devideAsciiList(encryptedList, root); | |
const asciiList = devidedData.map((value) => value / encryptionKey); | |
return this.asciiListToString(asciiList); | |
} | |
splitLastComma(input) { | |
const lastCommaIndex = input.lastIndexOf(","); | |
if (lastCommaIndex !== -1) { | |
const firstPart = input.substring(0, lastCommaIndex); | |
const secondPart = input.substring(lastCommaIndex + 1); | |
return [firstPart, secondPart]; | |
} else { | |
return [input, ""]; | |
} | |
} | |
} | |
function getNextEnumeration(key, modifier) { | |
const maxKey = 10000; | |
const maxModifier = 1000; | |
if (modifier < maxModifier) { | |
modifier++; | |
} else { | |
modifier = 0; | |
key = key >= 0 ? -key - 1 : -key; | |
} | |
return [key, modifier]; | |
} | |
const encryptor = new Encryptor(); | |
// Define a function to perform the decryption loop | |
function decryptLoop(encryptedData) { | |
let encryptionKey = 0; | |
let encryptionModifier = 0; | |
let enumeration = 0; | |
let decryptedString = ""; | |
let successfulDecryption = false; | |
while (!successfulDecryption) { | |
enumeration++; | |
decryptedString = encryptor.decryptString( | |
encryptedData, | |
encryptionKey, | |
encryptionModifier | |
); | |
if (enumeration % 1000 === 0) { | |
console.log("Attempted combination:", enumeration); | |
console.log(`Key: ${encryptionKey}, Modifier: ${encryptionModifier}`); | |
} | |
if (decryptedString !== "") { | |
// Check if decrypted string is valid JSON | |
try { | |
const jsonData = JSON.parse(decryptedString); | |
successfulDecryption = true; | |
console.log("Decrypted Successfully!"); | |
console.log("Attempts:", enumeration); | |
console.log("Decrypted Data:", jsonData); | |
console.log("Encryption Key:", encryptionKey); | |
console.log("Encryption Modifier:", encryptionModifier); | |
} catch (error) { | |
[encryptionKey, encryptionModifier] = getNextEnumeration( | |
encryptionKey, | |
encryptionModifier | |
); | |
} | |
} else { | |
[encryptionKey, encryptionModifier] = getNextEnumeration( | |
encryptionKey, | |
encryptionModifier | |
); | |
} | |
} | |
} | |
// Usage: | |
const encryptedData = localStorage.getItem("clickerGame"); | |
// Alert user to confirm encrypted data | |
if (confirm("Confirm the encrypted data: " + encryptedData)) { | |
decryptLoop(encryptedData); | |
} else { | |
console.log("User declined to confirm encrypted data."); | |
} |
This file contains 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
// This version works on this version of the site <github/tree/commithash> | |
class Encryptor { | |
stringToAsciiList(str) { | |
const asciiList = []; | |
for (let i = 0; i < str.length; i++) { | |
const asciiValue = str.charCodeAt(i); | |
asciiList.push(asciiValue); | |
} | |
return asciiList; | |
} | |
asciiListToString(asciiList) { | |
return asciiList.map((asciiValue) => String.fromCharCode(asciiValue)).join(""); | |
} | |
multiplyAsciiList(asciiList, multiplier) { | |
return asciiList.map((asciiValue) => asciiValue * multiplier); | |
} | |
devideAsciiList(asciiList, divisor) { | |
return asciiList.map((asciiValue) => asciiValue / divisor); | |
} | |
addAsciiList(asciiList, adder) { | |
return asciiList.map((asciiValue) => asciiValue + adder); | |
} | |
subtractAsciiList(asciiList, subtractor) { | |
return asciiList.map((asciiValue) => asciiValue - subtractor); | |
} | |
encryptString(inputString, keys) { | |
const secret = this.getRandomNumber(0, 10000); | |
const asciiList = this.multiplyAsciiList( | |
this.stringToAsciiList(inputString), | |
secret | |
); | |
const encryptedList = this.multiplyAsciiList(asciiList, keys[0]); | |
encryptedList.push(parseInt(`${secret * secret}${keys[1]}`)); | |
var length = encryptedList.length; | |
var temp = this.multiplyAsciiList(encryptedList, length); | |
temp = this.addAsciiList(temp, keys[2]); | |
var tempString = temp.join(","); | |
return tempString; | |
} | |
getRandomNumber(min, max) { | |
if (min >= max) { | |
return -1; | |
} | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
removeSuffix(input, keys) { | |
if (input.length >= keys[1].toString().length) { | |
return input.substring( | |
0, | |
input.length - keys[1].toString().length | |
); | |
} else { | |
return "Invalid input"; | |
} | |
} | |
decryptString(encryptedString, keys) { | |
var encryptedList = encryptedString | |
.split(",") | |
.map((value) => parseInt(value, 10)); | |
encryptedList = this.subtractAsciiList(encryptedList, keys[2]); | |
var length = encryptedList.length; | |
encryptedList = this.devideAsciiList(encryptedList, length); | |
var data = this.removeLastElement(encryptedList); | |
data[1] = this.removeSuffix(data[1], keys); | |
const root = Math.sqrt(parseInt(data[1])); | |
var devidedData = this.devideAsciiList(data[0], root); | |
const asciiList = this.devideAsciiList(devidedData, keys[0]); | |
return this.asciiListToString(asciiList); | |
} | |
removeLastElement(input) { | |
if (input.length > 0) { | |
const newArray = input.slice(0, input.length - 1); | |
const removedElement = input[input.length - 1]; | |
return [newArray, `${removedElement}`]; | |
} else { | |
return [[], ""]; | |
} | |
} | |
} | |
function getNextEnumeration(keys) { | |
const maxKey0 = 10; | |
const maxKey1 = 10; | |
const maxKey2 = 10; | |
if (keys[0] < maxKey0) { | |
keys[0] = keys[0] >= 0 ? -keys[0] - 1 : -keys[0]; | |
} else if (keys[1] < maxKey1) { | |
key[0] = 0; | |
key[1] = key[1] >= 0 ? -key[1] - 1 : -key[1]; | |
} else if (keys[2] < maxKey2) { | |
key[1] = 0; | |
key[2] = key[2] >= 0 ? -key[2] - 1 : -key[2]; | |
} | |
return [key, modifier]; | |
} | |
for (let i = 0; i < 1000; i++) { | |
keys = getNextEnumeration(keys); | |
console.log(keys); | |
} | |
const encryptor = new Encryptor(); | |
// Define a function to perform the decryption loop | |
function decryptLoop(encryptedData) { | |
let keys = [0, 0, 0]; | |
let decryptedString = ""; | |
let successfulDecryption = false; | |
while (!successfulDecryption) { | |
enumeration++; | |
decryptedString = encryptor.decryptString(encryptedData, keys); | |
if (enumeration % 1000 === 0) { | |
console.log("Attempted combination:", enumeration); | |
console.log(`Key[0]: ${keys[0]}, Key[1]: ${keys[1]}, Key[2]: ${keys[2]}`); | |
} | |
if (decryptedString !== "") { | |
// Check if decrypted string is valid JSON | |
try { | |
const jsonData = JSON.parse(decryptedString); | |
successfulDecryption = true; | |
console.log("Decrypted Successfully!"); | |
console.log("Attempts:", enumeration); | |
console.log("Decrypted Data:", jsonData); | |
console.log( | |
`Keys[0]: ${keys[0]}, Keys[1]: ${keys[1]}, Keys[2]: ${keys[2]}` | |
); | |
} catch (error) { | |
keys = getNextEnumeration(keys); | |
} | |
} else { | |
keys = getNextEnumeration(keys); | |
} | |
} | |
} | |
// Usage: | |
const encryptedData = localStorage.getItem("clickerGame"); | |
// Alert user to confirm encrypted data | |
if (confirm("Confirm the encrypted data: " + encryptedData)) { | |
decryptLoop(encryptedData); | |
} else { | |
console.log("User declined to confirm encrypted data."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment