Show total IPs, ETA, and live masscan progress ticker

This commit is contained in:
n0mad1k
2026-04-30 14:58:38 -04:00
parent 62906d9676
commit 2e7e7f0cfb
2 changed files with 69 additions and 4 deletions
+32 -2
View File
@@ -4,6 +4,7 @@ geo-scout — geo-targeted network scanner
masscan for port discovery, nmap for fingerprinting, probe engine for matching
"""
import ipaddress
import json
import os
import sys
@@ -90,6 +91,33 @@ def collect_all_ports(targets: list[dict]) -> list[int]:
return sorted(ports)
def count_ips(cidrs: list[str]) -> int:
total = 0
for c in cidrs:
try:
total += ipaddress.ip_network(c, strict=False).num_addresses
except ValueError:
pass
return total
def fmt_ip_count(n: int) -> str:
if n >= 1_000_000:
return f"{n/1_000_000:.1f}M"
if n >= 1_000:
return f"{n/1_000:.0f}K"
return str(n)
def fmt_eta(total_ips: int, n_ports: int, rate: int) -> str:
if rate <= 0:
return "?"
secs = int(total_ips * n_ports / rate)
m, s = divmod(secs, 60)
h, m = divmod(m, 60)
return f"{h}h {m:02d}m" if h else f"{m}m {s:02d}s"
# ── Probe worker ──────────────────────────────────────────────────────────────
def probe_host(ip: str, port: int, targets: list[dict]) -> list[dict]:
matches = []
@@ -183,8 +211,10 @@ def cmd_run(args):
if max_hosts:
cidrs = cidrs[:max_hosts // 256 + 1]
print(f"\n{C}[{idx}/{n_countries}]{RST} {BOLD}{cc}{RST}{len(cidrs)} CIDR blocks")
info(f"{cc}: running masscan at {rate} pps (Ctrl-C once = skip country, twice = abort all)...")
total_ips = count_ips(cidrs)
eta = fmt_eta(total_ips, len(all_ports), rate)
print(f"\n{C}[{idx}/{n_countries}]{RST} {BOLD}{cc}{RST}{len(cidrs)} CIDR blocks {W}({fmt_ip_count(total_ips)} IPs ~{eta} at {rate} pps){RST}")
info(f"{cc}: running masscan (Ctrl-C once = skip country, twice = abort all)...")
try:
open_ports = masscan_sweep(cidrs, all_ports, rate, tmp)