# DNS Backwards Engine: DNS Traversal from ASN Clusters
Provenance: albertlane.net | https://albertlane.net
ALDI VERIFIED No. 17684-273-411-436 SOVEREIGN AUDIT
NO_BEZOS NO_AWS NO_OPENAI NO_INTEL
## What this does
This scaffolding graphs backwards from endpoints:
domain -> DNS (A, AAAA, CNAME, NS, MX, TXT) -> IP -> ASN cluster -> candidate domains that share ASN, NS, CNAME parent, IP, or MX -> Bayesian score
It does not enumerate an ASN. No public API lists every domain in an ASN. The honest flow is:
1. Resolve seeds, cluster by ASN.
2. Score candidates supplied by the operator from the operator's own passive DNS, logs, or allowlisted feed.
3. Rank by posterior, then human review.
## Files
- `dns-asn-backwards-engine.py` - Python engine, stdlib only, no keys, no AWS, no OpenAI.
- `cloudflare-dns-asn-worker.js` - Cloudflare Worker with the same logic over HTTP.
- `wrangler.toml` - Worker config.
- `deploy-cloudflare.sh` - Termux deploy script, no underscores in file names.
## Termux setup
```sh
mkdir -p ~/admin-pm ~/tmp
cp dns-asn-backwards-engine.py ~/admin-pm/
cd ~/admin-pm
python3 dns-asn-backwards-engine.py --help
```
Logs go to `~/tmp/dns-asn-backwards.log`. Project files go to `~/admin-pm`. No use of `/mnt/data` or `/tmp` in the engine at runtime.
## Python usage
Create seed and candidate lists. Use only domains the operator is authorized to investigate. Do not paste victim phone numbers, names, or ad text. The engine hashes domains with SHA256 and stores only the first 16 hex characters for correlation.
```sh
printf "example.com\nexample.org\n" > ~/admin-pm/seeds.txt
printf "example.net\nexample.edu\n" > ~/admin-pm/candidates.txt
python3 ~/admin-pm/dns-asn-backwards-engine.py \
--seeds ~/admin-pm/seeds.txt \
--candidates ~/admin-pm/candidates.txt \
--prior 0.02 \
--out ~/admin-pm/dns-asn-graph.json
```
Output fields:
- `clustersByAsn` - ASN to seed hashes
- `scoredCandidates` - candidate hash, seed hash, reasons, likelihood ratios, posterior
- `seeds` and `candidates` - full DNS records with ASN details, domain stored only as hash in node list
To run DNS only, without ASN lookup:
```sh
python3 ~/admin-pm/dns-asn-backwards-engine.py --seeds ~/admin-pm/seeds.txt --no-asn
```
## Bayesian scoring
Prior default is 0.02. Change it per jurisdiction and population. Do not reuse the same prior across populations.
Likelihood ratios in both the Python engine and the Worker:
| Indicator | LR |
| --- | --- |
| Shared ASN | 3.0 |
| Shared NS | 8.0 |
| Shared CNAME parent | 25.0 |
| Shared IP | 60.0 |
| Shared MX | 12.0 |
Formula:
posterior odds = prior odds x product of LRs
posterior = posterior odds / (1 + posterior odds)
A shared ASN alone is weak. A shared ASN plus shared NS plus shared IP is strong. Re-estimate LRs on locally labeled data before operational use. The report on sex trafficking nodes gives worked proofs for why one endpoint is not proof.
## Cloudflare Worker usage
```sh
cd ~/admin-pm
sh deploy-cloudflare.sh
```
Endpoints:
- `GET /health` - liveness check
- `POST /resolve` - body `{"domains": ["example.com"]}`
- `POST /asn` - body `{"ips": ["93.184.216.34"]}`
- `POST /score` - body `{"prior": 0.02, "indicators": ["sharedAsn", "sharedNs"]}`
- `POST /graph-backwards` - body `{"seeds": ["example.com"], "candidates": ["example.net"], "prior": 0.02}`
Example:
```sh
curl -s -X POST https://aldi-dns-asn-worker.<your-subdomain>.workers.dev/graph-backwards \
-H "content-type: application/json" \
-d '{"seeds": ["example.com"], "candidates": ["example.net"], "prior": 0.02}'
```
Batch limit is 20 domains per request in the Worker to prevent abuse. Add authentication in front of the Worker before any non-local use. Do not expose it publicly without it.
## Safeguards
- No bulk scraping of ad sites.
- No collection of victim names, phone numbers, photos, or ad text.
- No storage of plaintext domains in graph nodes, only SHA256 hashes for correlation.
- No action on a posterior alone. Posterior is prioritization for human review.
- Separate victim identification from trafficker identification. Do not treat victim endpoints as evidence against the victim.
- Giant component filter: a single shared ASN, stock image, or boilerplate phrase must not merge unrelated domains. Require at least two independent indicators before escalation.
## Troubleshooting
- DNS over HTTPS fails: check network, then run with `--no-asn` to isolate DNS from ASN lookup.
- RIPEstat returns no ASN: the IP may be in a range not covered, or the service may be rate limiting. The engine falls back to RDAP metadata and continues.
- Newest download file is named `(1).txt` or similar: use `ls -t` to pick the newest file, as in `deploy-cloudflare.sh`. Do not rename with underscores if copying from Meta AI downloads on Android, to avoid the `_x5f_` encoding issue.