73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Compute Deployment + Reporting DGA candidate domains from seeds (offline)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
|
|
from _common import (
|
|
ORIGINAL_DEPLOYMENT_SEED,
|
|
ORIGINAL_REPORTING_SEED,
|
|
validate_seed_arg,
|
|
)
|
|
from reproduce_coruna_dga import generate_domains
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(
|
|
description="Print Coruna PLServerPool DGA candidates for Deployment + Reporting seeds"
|
|
)
|
|
parser.add_argument(
|
|
"--deployment-seed",
|
|
default=ORIGINAL_DEPLOYMENT_SEED,
|
|
help=f"default: original campaign seed ({ORIGINAL_DEPLOYMENT_SEED})",
|
|
)
|
|
parser.add_argument(
|
|
"--reporting-seed",
|
|
default=ORIGINAL_REPORTING_SEED,
|
|
help=f"default: original campaign seed ({ORIGINAL_REPORTING_SEED})",
|
|
)
|
|
parser.add_argument(
|
|
"-n",
|
|
"--count",
|
|
type=int,
|
|
default=5,
|
|
help="candidates per pool (operational pool uses 5; max 512)",
|
|
)
|
|
parser.add_argument("--json", action="store_true", help="emit JSON")
|
|
args = parser.parse_args()
|
|
dep = validate_seed_arg("--deployment-seed", args.deployment_seed)
|
|
rep = validate_seed_arg("--reporting-seed", args.reporting_seed)
|
|
|
|
payload = {
|
|
"deployment": {
|
|
"seed": dep,
|
|
"domains": generate_domains(dep, args.count),
|
|
},
|
|
"reporting": {
|
|
"seed": rep,
|
|
"domains": generate_domains(rep, args.count),
|
|
},
|
|
"note": (
|
|
"Native helper generates 512 strings; PLServerPool keeps the first 5 "
|
|
"as the live candidate pool."
|
|
),
|
|
}
|
|
|
|
if args.json:
|
|
print(json.dumps(payload, indent=2))
|
|
return 0
|
|
|
|
print(f"deployment seed={dep}")
|
|
for i, domain in enumerate(payload["deployment"]["domains"], 1):
|
|
print(f" {i:03d} {domain}")
|
|
print(f"reporting seed={rep}")
|
|
for i, domain in enumerate(payload["reporting"]["domains"], 1):
|
|
print(f" {i:03d} {domain}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|