32 lines
1.4 KiB
PHP
Executable File
32 lines
1.4 KiB
PHP
Executable File
<?php
|
|
$db = pg_connect('host=localhost dbname=adx_system user=admin password=admin123');
|
|
pg_query($db, 'SET search_path TO admin,public');
|
|
$log = function($m) { echo '['.date('Y-m-d H:i:s').'] '.$m."\n"; };
|
|
|
|
$targets = [];
|
|
$r = pg_query($db, "SELECT id, target, scan_type, status FROM dark_scout_targets WHERE status='active' ORDER BY id");
|
|
while($row = pg_fetch_assoc($r)) $targets[] = $row;
|
|
$log(count($targets).' scout targets');
|
|
|
|
$reportsCreated = 0;
|
|
foreach($targets as $t) {
|
|
if($t['scan_type'] === 'relay_scan') {
|
|
$domain = $t['target'];
|
|
$mx = [];
|
|
getmxrr($domain, $mx);
|
|
$relays = count($mx);
|
|
$mxList = $relays > 0 ? implode(', ', array_slice($mx, 0, 5)) : 'No MX';
|
|
|
|
pg_query($db, "UPDATE dark_scout_targets SET relays_found=$relays, payloads='".pg_escape_string($db, json_encode(['mx'=>$mx]))."' WHERE id={$t['id']}");
|
|
|
|
$title = pg_escape_string($db, "MX Scan: $domain → $relays relays");
|
|
$data = pg_escape_string($db, json_encode(['domain'=>$domain,'mx'=>$mx,'relays'=>$relays]));
|
|
pg_query($db, "INSERT INTO ghost_scout_reports (report_type, title, data, priority, is_read, created_at) VALUES ('mx_scan', '$title', '$data', 1, false, NOW())");
|
|
$reportsCreated++;
|
|
$log(" $domain → $relays MX ($mxList)");
|
|
}
|
|
}
|
|
|
|
$reports = pg_fetch_result(pg_query($db, "SELECT COUNT(*) FROM ghost_scout_reports"), 0, 0);
|
|
$log("Reports: $reports (new: $reportsCreated)");
|