67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
const constants = [
|
|
'instance',
|
|
'93703gBAUAn',
|
|
'442816lLbold',
|
|
'instantiate',
|
|
'1ZFMVDM',
|
|
'381193zsgNYQ',
|
|
'check_flag',
|
|
'result',
|
|
'length',
|
|
'48829pZIrMh',
|
|
'648920pjyJsd',
|
|
'copy_char',
|
|
'21760lQoqpJ',
|
|
'arrayBuffer',
|
|
'1zBwHgR',
|
|
'innerHTML',
|
|
'615706OhnLTV',
|
|
'Correct!',
|
|
'getElementById',
|
|
'./index.wasm',
|
|
'charCodeAt',
|
|
];
|
|
|
|
const getConst = function(addr, _seemingly_unused) {
|
|
addr = addr - 0xac;
|
|
let result = constants[addr];
|
|
return result;
|
|
};
|
|
|
|
// Stack aligner of some sort?
|
|
(function() {
|
|
while (!![]) {
|
|
try {
|
|
const result = parseInt(getConst(0xb7)) + parseInt(getConst(0xb0)) + -parseInt(getConst(0xc0)) * parseInt(getConst(0xbd)) + -parseInt(getConst(0xac)) + -parseInt(getConst(0xb3)) + parseInt(getConst(0xb5)) * parseInt(getConst(0xb1)) + -parseInt(getConst(0xbe));
|
|
if (result === 0x5b4df) break;
|
|
else constants['push'](constants['shift']());
|
|
} catch (e) {
|
|
constants['push'](constants['shift']());
|
|
}
|
|
}
|
|
}());
|
|
|
|
let exports;
|
|
|
|
// Load the WebAssembly module and get its exports
|
|
(async () => {
|
|
let checkFlagWasm = await fetch('./index.wasm'),
|
|
arrayBufferResult = await WebAssembly['instantiate'](await checkFlagWasm['arrayBuffer']()),
|
|
arrayBufferResultInstance = arrayBufferResult['instance'];
|
|
exports = arrayBufferResultInstance['exports'];
|
|
})();
|
|
|
|
function onButtonPress() {
|
|
let value = document['getElementById']('input')['value'];
|
|
const copy_char = exports['copy_char'];
|
|
|
|
for (let i = 0x0; i < value['length']; i++) {
|
|
const char_code = value['charCodeAt'](i);
|
|
copy_char(char_code, i);
|
|
}
|
|
|
|
exports['copy_char'](0x0, value['length']), exports['check_flag']() == 0x1
|
|
? document['getElementById']('result')['innerHTML'] = 'Correct!'
|
|
: document['getElementById']('result')['innerHTML'] = 'Incorrect!';
|
|
}
|