Last active
December 14, 2020 23:02
-
-
Save MatsAnd/4558a8776a9bcf0bed3c2606c4bf9262 to your computer and use it in GitHub Desktop.
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
const { step, assemble } = require('@pstnorge/slede8') | |
const getProgram = (requiredChars) => { | |
return `.DATA 0x51,0x00,0x61,0x01,0xa1,0x00,0xb1,0x01,0xc1,0x00,0x83,0x03,0x91,0x${requiredChars.toString(16)},0x06,0x02,0x04,0x03,0x72,0x05,0x55,0x67,0x25,0x72,0x25,0x32,0x15,0x2c,0x52,0x06,0x62,0x07,0x65,0xb9,0x55,0xb0,0x17,0xa9,0xe9,0x00,0x07,0xac,0x29,0x03,0xb3,0x05,0x1a,0x06,0x00,0x00,0x23,0x05,0x1a,0x06,0x00,0x00,0x51,0x51,0x57,0x7e,0x6e,0x64,0x77,0x12,0x59,0x38,0xf3,0x8a,0x48,0x3d,0xeb,0x53,0x7d,0x21,0x5c,0xaf,0x1c,0xae,0x50,0x25,0x55,0x3f,0x4b,0x6f,0x72,0x72,0x65,0x6b,0x74,0x21,0x00,0x46,0x65,0x69,0x6c,0x21,0x00,0x04,0x02,0x07,0xa2,0xd9,0x06,0x16,0x02,0x55,0xb0,0x18,0x06,0x0b,0x00` | |
} | |
const getRange = (start, end) => { | |
const range = [] | |
for (let year = start; year < end + 1; year++) { | |
range.push(year) | |
} | |
return range | |
} | |
const fromHexString = hexString => new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16))) | |
const chars = getRange(32, 126).map(code => String.fromCharCode(code)) | |
const prefix = 'PST{' | |
const suffix = '}' | |
const passwordlength = 26 | |
const actuallLength = passwordlength - (prefix.length) - (suffix.length) | |
let password = `${prefix}` | |
for (let col = 0; col < actuallLength; col++) { | |
const assembled = assemble(getProgram(password.length + 1)) | |
for (let i = 0; i < chars.length; i++) { | |
const char = chars[i] | |
const fode = fromHexString(Buffer.from(`${password}${char}`).toString('hex')) | |
const program = step(assembled.exe, fode) | |
let state = {} | |
do { | |
state = program.next() | |
} while (!state.done) | |
console.log(`${password}${char} = ${state.value.stdout.toString()}`) | |
// If not "Feil!" | |
if (state.value.stdout.toString() !== '70,101,105,108,33') { | |
password += char | |
break | |
} | |
} | |
} | |
console.log('\n🥁 🥁 🥁 🥁 🥁 🥁 🥁 🥁 🥁 🥁 🥁 🥁\n') | |
console.log(`Nøkkelen er: ${password + suffix}`) | |
console.log(`Heks: ${Buffer.from(password + suffix).toString('hex')}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment