add su command
This commit is contained in:
parent
7cf1d45283
commit
fc10dcfe1b
|
@ -1,4 +1,5 @@
|
|||
const { Terminal } = require("xterm");
|
||||
const sleep = require("../../lib/sleep");
|
||||
|
||||
/**
|
||||
* @param {string[]} argv
|
||||
|
@ -25,7 +26,37 @@ module.exports = async (argv, terminal, zsh) => {
|
|||
}
|
||||
|
||||
terminal.write('Password: ');
|
||||
/** @type {string} */
|
||||
const pass = await zsh.get_stdin({hide: true});
|
||||
const some_random_array = new Uint16Array([12319, 14486, 12589, 13232]);
|
||||
let checksum = new Uint32Array(pass.length);
|
||||
|
||||
terminal.write(pass);
|
||||
let i = 0;
|
||||
for (const letter of pass) {
|
||||
checksum[i] = letter.charCodeAt(0) * 128;
|
||||
checksum[i] += (i*8) - letter.charCodeAt(0);
|
||||
i++;
|
||||
}
|
||||
i = undefined;
|
||||
|
||||
console.log(checksum, some_random_array);
|
||||
|
||||
let valid = true;
|
||||
if (checksum.length == some_random_array.length)
|
||||
for (let i = 0; i != some_random_array.length; i++) {
|
||||
if (checksum[i] != some_random_array[i])
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
valid = false;
|
||||
|
||||
console.log(valid);
|
||||
|
||||
if (valid) {
|
||||
terminal.writeln('yay, you did it!! congratulations :3');
|
||||
} else {
|
||||
await sleep(3000);
|
||||
terminal.writeln('su: Authentication failure');
|
||||
return 1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue