icoa-cli 2.19.5 → 2.19.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/ctf.js +40 -3
- package/package.json +1 -1
package/dist/commands/ctf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import {
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
3
|
import { CTFdClient } from '../lib/ctfd-client.js';
|
|
4
4
|
import { getConfig, saveConfig, getBudget } from '../lib/config.js';
|
|
5
5
|
import { logCommand, logSubmission } from '../lib/logger.js';
|
|
@@ -30,8 +30,45 @@ export function registerCtfCommands(program) {
|
|
|
30
30
|
logCommand(`ctf join ${url}`);
|
|
31
31
|
console.log();
|
|
32
32
|
printInfo(`Connecting to ${chalk.bold(url)}`);
|
|
33
|
-
|
|
34
|
-
const
|
|
33
|
+
// Use native readline to avoid REPL conflict
|
|
34
|
+
const username = await new Promise((resolve) => {
|
|
35
|
+
process.stdout.write(chalk.white(' Username: '));
|
|
36
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
37
|
+
rl.once('line', (line) => { rl.close(); resolve(line.trim()); });
|
|
38
|
+
});
|
|
39
|
+
const password = await new Promise((resolve) => {
|
|
40
|
+
process.stdout.write(chalk.white(' Password: '));
|
|
41
|
+
if (process.stdin.isTTY)
|
|
42
|
+
process.stdin.setRawMode?.(true);
|
|
43
|
+
let pw = '';
|
|
44
|
+
const onData = (ch) => {
|
|
45
|
+
const c = ch.toString();
|
|
46
|
+
if (c === '\n' || c === '\r') {
|
|
47
|
+
if (process.stdin.isTTY)
|
|
48
|
+
process.stdin.setRawMode?.(false);
|
|
49
|
+
process.stdin.removeListener('data', onData);
|
|
50
|
+
process.stdout.write('\n');
|
|
51
|
+
resolve(pw);
|
|
52
|
+
}
|
|
53
|
+
else if (c === '\x7f' || c === '\b') {
|
|
54
|
+
if (pw.length > 0) {
|
|
55
|
+
pw = pw.slice(0, -1);
|
|
56
|
+
process.stdout.write('\b \b');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (c === '\x03') {
|
|
60
|
+
if (process.stdin.isTTY)
|
|
61
|
+
process.stdin.setRawMode?.(false);
|
|
62
|
+
process.stdin.removeListener('data', onData);
|
|
63
|
+
resolve('');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
pw += c;
|
|
67
|
+
process.stdout.write('*');
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
process.stdin.on('data', onData);
|
|
71
|
+
});
|
|
35
72
|
let token = '';
|
|
36
73
|
let sessionCookie = '';
|
|
37
74
|
let csrfNonce = '';
|