icoa-cli 2.19.99 → 2.19.101

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.
Files changed (45) hide show
  1. package/dist/commands/ai4ctf.js +1 -700
  2. package/dist/commands/connect.js +1 -66
  3. package/dist/commands/ctf.js +1 -620
  4. package/dist/commands/ctf4ai-demo.js +1 -525
  5. package/dist/commands/env.js +1 -737
  6. package/dist/commands/exam.js +1 -2353
  7. package/dist/commands/files.js +1 -52
  8. package/dist/commands/hint.js +1 -119
  9. package/dist/commands/lang.js +1 -155
  10. package/dist/commands/log.js +1 -163
  11. package/dist/commands/note.js +1 -32
  12. package/dist/commands/ref.js +1 -63
  13. package/dist/commands/setup.js +1 -103
  14. package/dist/commands/shell.js +1 -55
  15. package/dist/commands/theme.js +1 -50
  16. package/dist/index.js +1 -225
  17. package/dist/lib/access.js +1 -246
  18. package/dist/lib/budget.js +1 -42
  19. package/dist/lib/colors.js +1 -21
  20. package/dist/lib/config.js +1 -60
  21. package/dist/lib/ctfd-client.js +1 -274
  22. package/dist/lib/demo-exam.js +1 -249
  23. package/dist/lib/demo-flags.js +1 -27
  24. package/dist/lib/demo-stats.js +1 -65
  25. package/dist/lib/exam-client.js +1 -57
  26. package/dist/lib/exam-setup.js +1 -23
  27. package/dist/lib/exam-state.js +1 -112
  28. package/dist/lib/gemini.js +1 -235
  29. package/dist/lib/i18n.js +1 -273
  30. package/dist/lib/log-sync.js +1 -110
  31. package/dist/lib/logger.js +1 -59
  32. package/dist/lib/paper-upgrade.js +1 -117
  33. package/dist/lib/platform.js +1 -86
  34. package/dist/lib/sandbox.js +1 -93
  35. package/dist/lib/terminal.js +1 -49
  36. package/dist/lib/theme.js +1 -108
  37. package/dist/lib/translation.js +1 -66
  38. package/dist/lib/ui.js +1 -80
  39. package/dist/lib/update-check.js +1 -102
  40. package/dist/postinstall.js +1 -48
  41. package/dist/repl.js +1 -1259
  42. package/dist/types/index.d.ts +1 -1
  43. package/dist/types/index.js +1 -38
  44. package/package.json +6 -2
  45. package/translations/sw/i18n-snippet.ts +1 -0
@@ -1,66 +1 @@
1
- import { execSync } from 'node:child_process';
2
- import chalk from 'chalk';
3
- import { CTFdClient } from '../lib/ctfd-client.js';
4
- import { getConfig, isConnected } from '../lib/config.js';
5
- import { logCommand } from '../lib/logger.js';
6
- import { printError, printInfo, printSuccess, createSpinner } from '../lib/ui.js';
7
- export function registerConnectCommand(program) {
8
- program
9
- .command('connect <id>')
10
- .description('Connect to challenge remote target')
11
- .action(async (id) => {
12
- logCommand(`connect ${id}`);
13
- const config = getConfig();
14
- if (!isConnected()) {
15
- printError('Not connected. Run: join <url>');
16
- return;
17
- }
18
- const client = new CTFdClient(config.ctfdUrl, config.token);
19
- const spinner = createSpinner('Fetching connection info...');
20
- spinner.start();
21
- try {
22
- const challenge = await client.getChallenge(parseInt(id));
23
- spinner.stop();
24
- if (!challenge.connection_info) {
25
- printInfo('This challenge has no connection information.');
26
- return;
27
- }
28
- const connInfo = challenge.connection_info.trim();
29
- printInfo(`Connection: ${chalk.white(connInfo)}`);
30
- console.log();
31
- // Parse connection info and execute
32
- if (connInfo.match(/^nc\s+/i) || connInfo.match(/^ncat\s+/i)) {
33
- // netcat connection
34
- printSuccess('Connecting...');
35
- execSync(connInfo, { stdio: 'inherit' });
36
- }
37
- else if (connInfo.match(/^ssh\s+/i)) {
38
- // SSH connection
39
- printSuccess('Connecting via SSH...');
40
- execSync(connInfo, { stdio: 'inherit' });
41
- }
42
- else if (connInfo.includes(':')) {
43
- // host:port format
44
- const [host, port] = connInfo.split(':');
45
- printSuccess(`Connecting to ${host}:${port}...`);
46
- execSync(`nc ${host} ${port}`, { stdio: 'inherit' });
47
- }
48
- else {
49
- printInfo('Could not auto-detect connection type.');
50
- printInfo(`Connection info: ${connInfo}`);
51
- printInfo('Connect manually using the information above.');
52
- }
53
- }
54
- catch (err) {
55
- if (err.status !== undefined) {
56
- // Process exited (normal for nc/ssh)
57
- console.log();
58
- printInfo('Connection closed.');
59
- }
60
- else {
61
- spinner.fail('Failed to connect');
62
- printError(err.message);
63
- }
64
- }
65
- });
66
- }
1
+ import{execSync as n}from"node:child_process";import chalk from"chalk";import{CTFdClient as o}from"../lib/ctfd-client.js";import{getConfig as t,isConnected as i}from"../lib/config.js";import{logCommand as e}from"../lib/logger.js";import{printError as c,printInfo as s,printSuccess as r,createSpinner as l}from"../lib/ui.js";export function registerConnectCommand(a){a.command("connect <id>").description("Connect to challenge remote target").action(async a=>{e(`connect ${a}`);const m=t();if(!i())return void c("Not connected. Run: join <url>");const f=new o(m.ctfdUrl,m.token),d=l("Fetching connection info...");d.start();try{const o=await f.getChallenge(parseInt(a));if(d.stop(),!o.connection_info)return void s("This challenge has no connection information.");const t=o.connection_info.trim();if(s(`Connection: ${chalk.white(t)}`),console.log(),t.match(/^nc\s+/i)||t.match(/^ncat\s+/i))r("Connecting..."),n(t,{stdio:"inherit"});else if(t.match(/^ssh\s+/i))r("Connecting via SSH..."),n(t,{stdio:"inherit"});else if(t.includes(":")){const[o,i]=t.split(":");r(`Connecting to ${o}:${i}...`),n(`nc ${o} ${i}`,{stdio:"inherit"})}else s("Could not auto-detect connection type."),s(`Connection info: ${t}`),s("Connect manually using the information above.")}catch(n){void 0!==n.status?(console.log(),s("Connection closed.")):(d.fail("Failed to connect"),c(n.message))}})}