5ee7352652
Ransomware.live's v2 API is free and needs no authentication. Remove the optional api_key config field and the X-API-KEY header logic from all commands so instance creation requires no credentials. Only an optional base_url override remains. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
|
|
|
DEFAULT_BASE = "https://api.ransomware.live/v2"
|
|
|
|
|
|
def _cfg():
|
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
|
|
|
|
|
def _inputs():
|
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
|
|
|
|
|
def _get(cfg, path):
|
|
base = (cfg.get("base_url") or DEFAULT_BASE).rstrip("/")
|
|
headers = {"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
|
req = urllib.request.Request(base + path, headers=headers)
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
|
raw = r.read()
|
|
return json.loads(raw) if raw else None
|
|
|
|
|
|
def _req(inputs, key):
|
|
v = str(inputs.get(key) or "").strip()
|
|
if not v:
|
|
raise ValueError(key + " is required")
|
|
return v
|
|
|
|
|
|
def _run(fn):
|
|
try:
|
|
print(json.dumps(fn(_cfg(), _inputs())))
|
|
except urllib.error.HTTPError as e:
|
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(json.dumps({"error": str(e)}))
|
|
sys.exit(1)
|
|
|
|
|
|
def main(cfg, inputs):
|
|
group = _req(inputs, "group")
|
|
return _get(cfg, "/group/" + urllib.parse.quote(group, safe=""))
|
|
|
|
|
|
_run(main)
|