icoa-cli 2.19.6 → 2.19.7
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 +38 -39
- package/package.json +1 -1
package/dist/commands/ctf.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { createInterface } from 'node:readline';
|
|
3
2
|
import { CTFdClient } from '../lib/ctfd-client.js';
|
|
4
3
|
import { getConfig, saveConfig, getBudget } from '../lib/config.js';
|
|
5
4
|
import { logCommand, logSubmission } from '../lib/logger.js';
|
|
@@ -30,45 +29,45 @@ export function registerCtfCommands(program) {
|
|
|
30
29
|
logCommand(`ctf join ${url}`);
|
|
31
30
|
console.log();
|
|
32
31
|
printInfo(`Connecting to ${chalk.bold(url)}`);
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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');
|
|
32
|
+
// Read username and password using raw stdin (avoids REPL readline conflict)
|
|
33
|
+
function rawInput(prompt, mask) {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
process.stdout.write(chalk.white(prompt));
|
|
36
|
+
if (process.stdin.isTTY)
|
|
37
|
+
process.stdin.setRawMode?.(true);
|
|
38
|
+
let buf = '';
|
|
39
|
+
const onData = (ch) => {
|
|
40
|
+
const c = ch.toString();
|
|
41
|
+
if (c === '\n' || c === '\r') {
|
|
42
|
+
if (process.stdin.isTTY)
|
|
43
|
+
process.stdin.setRawMode?.(false);
|
|
44
|
+
process.stdin.removeListener('data', onData);
|
|
45
|
+
process.stdout.write('\n');
|
|
46
|
+
resolve(buf);
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
else if (c === '\x7f' || c === '\b') {
|
|
49
|
+
if (buf.length > 0) {
|
|
50
|
+
buf = buf.slice(0, -1);
|
|
51
|
+
process.stdout.write('\b \b');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (c === '\x03') {
|
|
55
|
+
if (process.stdin.isTTY)
|
|
56
|
+
process.stdin.setRawMode?.(false);
|
|
57
|
+
process.stdin.removeListener('data', onData);
|
|
58
|
+
process.stdout.write('\n');
|
|
59
|
+
resolve('');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
buf += c;
|
|
63
|
+
process.stdout.write(mask || c);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
process.stdin.on('data', onData);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const username = await rawInput(' Username: ');
|
|
70
|
+
const password = await rawInput(' Password: ', '*');
|
|
72
71
|
let token = '';
|
|
73
72
|
let sessionCookie = '';
|
|
74
73
|
let csrfNonce = '';
|