Pull Linode token from Infisical as default; remove pointless webrunner sub-menu
This commit is contained in:
@@ -36,79 +36,10 @@ PROVIDER_LABELS = {'linode': 'Linode', 'aws': 'AWS', 'flokinet': 'FlokiNET'}
|
|||||||
|
|
||||||
# ── menu ──────────────────────────────────────────────────────────────────────
|
# ── menu ──────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def _available_providers() -> list[str]:
|
|
||||||
"""Return providers that have credentials available."""
|
|
||||||
import subprocess
|
|
||||||
available = []
|
|
||||||
creds_bin = os.path.expanduser('~/.local/bin/creds')
|
|
||||||
|
|
||||||
# Linode — check env first, then Infisical
|
|
||||||
if os.environ.get('LINODE_TOKEN'):
|
|
||||||
available.append('linode')
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
token = subprocess.check_output(
|
|
||||||
[creds_bin, 'get', 'LINODE_TOKEN', 'homelab'],
|
|
||||||
text=True, stderr=subprocess.DEVNULL,
|
|
||||||
).strip()
|
|
||||||
if token:
|
|
||||||
available.append('linode')
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# AWS
|
|
||||||
if os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY'):
|
|
||||||
available.append('aws')
|
|
||||||
|
|
||||||
# FlokiNET
|
|
||||||
if os.environ.get('FLOKINET_API_KEY'):
|
|
||||||
available.append('flokinet')
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
key = subprocess.check_output(
|
|
||||||
[creds_bin, 'get', 'FLOKINET_API_KEY', 'homelab'],
|
|
||||||
text=True, stderr=subprocess.DEVNULL,
|
|
||||||
).strip()
|
|
||||||
if key:
|
|
||||||
available.append('flokinet')
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return available
|
|
||||||
|
|
||||||
|
|
||||||
def webrunner_menu():
|
def webrunner_menu():
|
||||||
while True:
|
config = gather_webrunner_parameters()
|
||||||
clear_screen()
|
if config:
|
||||||
print_banner()
|
execute_webrunner_deployment(config)
|
||||||
print(f"{COLORS['CYAN']}WEBRUNNER — Distributed Geo-Targeted Recon{COLORS['RESET']}")
|
|
||||||
print(f"{COLORS['CYAN']}==========================================={COLORS['RESET']}")
|
|
||||||
|
|
||||||
available = _available_providers()
|
|
||||||
if available:
|
|
||||||
providers_str = ', '.join(PROVIDER_LABELS[p] for p in available)
|
|
||||||
print(f"1) New Scan Deployment [{providers_str}]")
|
|
||||||
else:
|
|
||||||
print(f"{COLORS['YELLOW']} No provider credentials found.{COLORS['RESET']}")
|
|
||||||
print(f" Set a token in Infisical to enable deployments:")
|
|
||||||
print(f" creds set LINODE_TOKEN <token> homelab")
|
|
||||||
|
|
||||||
print(f"\n99) Return to Main Menu")
|
|
||||||
|
|
||||||
choice = input(f"\nSelect: ").strip()
|
|
||||||
if choice == "1":
|
|
||||||
if not available:
|
|
||||||
print(f"{COLORS['RED']}No credentials configured. Add a provider token first.{COLORS['RESET']}")
|
|
||||||
wait_for_input()
|
|
||||||
continue
|
|
||||||
config = gather_webrunner_parameters()
|
|
||||||
if config:
|
|
||||||
execute_webrunner_deployment(config)
|
|
||||||
elif choice == "99":
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print(f"{COLORS['RED']}Invalid option.{COLORS['RESET']}")
|
|
||||||
wait_for_input()
|
|
||||||
|
|
||||||
|
|
||||||
# ── helpers ───────────────────────────────────────────────────────────────────
|
# ── helpers ───────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
+18
-4
@@ -3,16 +3,30 @@
|
|||||||
Linode provider utilities for C2ingRed deployment system
|
Linode provider utilities for C2ingRed deployment system
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
|
import subprocess
|
||||||
from .common import COLORS, load_vars_file
|
from .common import COLORS, load_vars_file
|
||||||
|
|
||||||
def get_linode_credentials(provider_vars=None):
|
def get_linode_credentials(provider_vars=None):
|
||||||
"""Get Linode API token from user or vars file"""
|
"""Get Linode API token — Infisical first, vars.yaml fallback, then prompt."""
|
||||||
if not provider_vars:
|
default_token = ''
|
||||||
provider_vars = load_vars_file('linode')
|
|
||||||
|
|
||||||
default_token = provider_vars.get('linode_token', '')
|
# Try Infisical first
|
||||||
|
try:
|
||||||
|
default_token = subprocess.check_output(
|
||||||
|
[os.path.expanduser('~/.local/bin/creds'), 'get', 'LINODE_TOKEN', 'homelab'],
|
||||||
|
text=True, stderr=subprocess.DEVNULL,
|
||||||
|
).strip()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Fall back to vars.yaml
|
||||||
|
if not default_token:
|
||||||
|
if not provider_vars:
|
||||||
|
provider_vars = load_vars_file('linode')
|
||||||
|
default_token = provider_vars.get('linode_token', '')
|
||||||
|
|
||||||
print(f"\n{COLORS['BLUE']}Linode Configuration{COLORS['RESET']}")
|
print(f"\n{COLORS['BLUE']}Linode Configuration{COLORS['RESET']}")
|
||||||
token = input(f"Linode API Token [{'*****' if default_token else 'required'}]: ") or default_token
|
token = input(f"Linode API Token [{'*****' if default_token else 'required'}]: ") or default_token
|
||||||
|
|||||||
Reference in New Issue
Block a user