|
2 | 2 | // |
3 | 3 | // A BullMQ Worker running on a self-hosted DigitalOcean droplet. It dials OUT |
4 | 4 | // to Redis (rediss://) — no inbound port — pulls port-scan jobs off the |
5 | | -// "prober" queue, runs a bounded `nmap -sT -Pn --top-ports 100` TCP-connect |
| 5 | +// "prober" queue, runs a full `nmap -sT -Pn -p- -T4` (all 65535) TCP-connect |
6 | 6 | // scan, and returns the open-port set as the job's return value. It writes no |
7 | 7 | // database; the Railway side handles results (baseline diff + alerts). |
8 | 8 | import { Worker, type Job, type ConnectionOptions } from "bullmq"; |
@@ -60,12 +60,14 @@ function assertScannableHost(host: string): void { |
60 | 60 |
|
61 | 61 | async function scan(job: PortScanJob): Promise<PortScanResult> { |
62 | 62 | assertScannableHost(job.host); |
63 | | - // -sT connect scan (no CAP_NET_RAW needed), -Pn skip host discovery, |
64 | | - // --top-ports 100 bounded set, -oG - greppable output on stdout. |
| 63 | + // Full TCP port scan (all 65535): -sT connect scan (no CAP_NET_RAW needed), |
| 64 | + // -Pn skip host discovery, -p- every port, -T4 faster timing, and a 25-min |
| 65 | + // nmap-side host timeout so a heavily-filtered host returns what it found |
| 66 | + // instead of hanging. -oG - greppable output on stdout. |
65 | 67 | const { stdout } = await pexecFile( |
66 | 68 | "nmap", |
67 | | - ["-sT", "-Pn", "--top-ports", "100", "-oG", "-", job.host], |
68 | | - { timeout: 180_000, maxBuffer: 8 * 1024 * 1024 }, |
| 69 | + ["-sT", "-Pn", "-p-", "-T4", "--host-timeout", "1500s", "-oG", "-", job.host], |
| 70 | + { timeout: 30 * 60_000, maxBuffer: 16 * 1024 * 1024 }, |
69 | 71 | ); |
70 | 72 |
|
71 | 73 | const openPorts: OpenPort[] = []; |
|
0 commit comments