-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathspectra
More file actions
executable file
·165 lines (151 loc) · 6.24 KB
/
Copy pathspectra
File metadata and controls
executable file
·165 lines (151 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
################################################################################
# SPECTRA - Unified CLI, Bootstrap & Archiving Launcher
################################################################################
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LAUNCH_SCRIPT="$SCRIPT_DIR/scripts/launch/spectra-launch.sh"
INSTALL_SCRIPT="$SCRIPT_DIR/scripts/install/install-spectra.sh"
REPAIR_SCRIPT="$SCRIPT_DIR/scripts/install/repair-installation.sh"
SETUP_SCRIPT="$SCRIPT_DIR/scripts/setup/setup_env.sh"
# ANSI Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
print_status() { echo -e "${BLUE}▶${NC} $1"; }
print_success() { echo -e "${GREEN}✓${NC} $1"; }
print_error() { echo -e "${RED}✗${NC} $1" >&2; }
print_warning() { echo -e "${YELLOW}⚠${NC} $1"; }
print_banner() {
echo -e "${CYAN}"
cat << 'EOF'
╔═══════════════════════════════════════════════════════════════════════════╗
║ ███████╗██████╗ ███████╗ ██████╗████████╗██████╗ ║
║ ██╔════╝██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔══██╗ ║
║ ███████╗██████╔╝█████╗ ██║ ██║ ██████╔╗ ║
║ ╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ██╔══██║ ║
║ ███████║██║ ███████╗╚██████╗ ██║ ██║ ██║ ║
║ ╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ║
╚═══════════════════════════════════════════════════════════════════════════╝
Telegram Network Discovery & Archiving System [CLI]
EOF
echo -e "${NC}"
}
# Resolve Python environment
resolve_python() {
if [[ -n "${VIRTUAL_ENV:-}" && -x "${VIRTUAL_ENV}/bin/python" ]]; then
echo "${VIRTUAL_ENV}/bin/python"
elif [[ -x "$SCRIPT_DIR/.venv/bin/python" ]]; then
echo "$SCRIPT_DIR/.venv/bin/python"
elif [[ -x "$SCRIPT_DIR/spectra_venv/bin/python" ]]; then
echo "$SCRIPT_DIR/spectra_venv/bin/python"
elif command -v python3 >/dev/null 2>&1; then
echo "python3"
else
print_error "Python 3 is required but not found in PATH."
exit 1
fi
}
is_configured() {
[[ -f "$SCRIPT_DIR/data/config/spectra_config.json" || -f "$SCRIPT_DIR/spectra_config.json" ]]
}
run_bootstrap() {
print_banner
print_status "Starting SPECTRA bootstrap & environment setup..."
if [[ -x "$LAUNCH_SCRIPT" ]]; then
exec "$LAUNCH_SCRIPT"
elif [[ -f "$SETUP_SCRIPT" ]]; then
bash "$SETUP_SCRIPT"
else
local PY_BIN
PY_BIN="$(resolve_python)"
print_status "Installing SPECTRA package in editable mode..."
"$PY_BIN" -m pip install -e "$SCRIPT_DIR"
print_success "SPECTRA installation complete."
fi
}
show_help() {
cat << 'EOF'
SPECTRA - Telegram Network Discovery & Archiving System [CLI-First]
Usage: ./spectra [COMMAND] [OPTIONS]
Core Operational Commands:
discover Run CaaS-aware semantic discovery (--seed @channel)
profile Extract dossiers, pricing, and aliases (--profile @channel)
process-queue Process the automated worker intelligence queue
archive Archive messages and media from Telegram channels
semantic-tui Launch the interactive Semantic Intelligence TUI
tui Launch the legacy full-terminal interface
Environment & Management:
bootstrap Auto-setup environment, dependencies, and venv
install Install/update dependencies and SPECTRA package
repair Repair virtualenv or missing packages
help, -h, --help Show this help message
Examples:
./spectra # Launch TUI (or auto-bootstrap if unconfigured)
./spectra discover --seed @target # Discover connected Telegram channels
./spectra profile --target @target # Extract threat actor profile & economics
./spectra process-queue --batch-size 250 # Process batch intelligence queue
./spectra bootstrap # Install dependencies & configure
EOF
}
# Main Dispatcher
COMMAND="${1:-}"
case "$COMMAND" in
""|"tui"|"launch"|"run")
if is_configured; then
PY="$(resolve_python)"
exec "$PY" -m tgarchive.ui.tui_caas "$@"
else
run_bootstrap
fi
;;
"bootstrap"|"setup")
run_bootstrap
;;
"install")
if [[ -f "$INSTALL_SCRIPT" ]]; then
exec bash "$INSTALL_SCRIPT"
else
run_bootstrap
fi
;;
"repair")
if [[ -f "$REPAIR_SCRIPT" ]]; then
exec bash "$REPAIR_SCRIPT"
else
run_bootstrap
fi
;;
"semantic-tui")
shift || true
PY="$(resolve_python)"
exec "$PY" -m tgarchive.ui.tui_caas "$@"
;;
"discover"|"semantic-discovery")
shift || true
PY="$(resolve_python)"
exec "$PY" -m tgarchive.osint.caas.discovery_ops "$@"
;;
"profile")
shift || true
PY="$(resolve_python)"
exec "$PY" -m tgarchive.osint.caas.cli profile "$@"
;;
"process-queue")
shift || true
PY="$(resolve_python)"
exec "$PY" -m tgarchive.osint.caas.cli process-queue "$@"
;;
"help"|"-h"|"--help")
show_help
;;
*)
# Forward any other subcommand directly to tgarchive CLI
PY="$(resolve_python)"
exec "$PY" -m tgarchive "$@"
;;
esac