30 KiB
ct_dns_utils.py
Source file: ct_dns_utils.py
Public DNS scanner. This file runs dig, follows alias chains, finds public addresses, and collapses raw DNS evidence into readable delivery labels.
Main flow in one line: DNS name -> dig answers -> normalized observation -> provider hints -> delivery label
How to read this page:
- left side: the actual source code block
- right side: a plain-English explanation for a beginner
- read from top to bottom because later blocks depend on earlier ones
Module setup
|
What this block is doing Shared DNS scanning helpers, cache helpers, and the logic that turns raw DNS answers into platform clues. Flow arrows Nothing yet; this is the starting point. → Module setup → The later DNS helpers all reuse these imports and small shared helpers. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
DnsObservation
|
What this block is doing One complete DNS observation for one hostname. Flow arrows Earlier blocks or operator input feed this block. → DnsObservation → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
normalize_name
|
What this block is doing This block makes values consistent so matching and grouping do not get confused by superficial differences. Flow arrows Earlier blocks or operator input feed this block. → normalize_name → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
cache_key
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → cache_key → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
load_json_cache
|
What this block is doing This block loads data from disk, cache, or an earlier stage so later code can work with it. Flow arrows Earlier blocks or operator input feed this block. → load_json_cache → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
store_json_cache
|
What this block is doing This block saves an intermediate result so the next run can reuse it instead of recomputing everything. Flow arrows Earlier blocks or operator input feed this block. → store_json_cache → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
run_dig
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows A hostname and record type. → run_dig → `scan_name_live`, `dig_status`, `dig_short`, and `ptr_lookup` all rely on this. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
dig_status
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → dig_status → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
dig_short
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → dig_short → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
parse_answer_section
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → parse_answer_section → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
is_ip_address
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → is_ip_address → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
classify_observation
|
What this block is doing This block applies rules and chooses a category label. Flow arrows Earlier blocks or operator input feed this block. → classify_observation → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
infer_provider_hints
|
What this block is doing Reads the raw DNS trail and pulls out likely platform or vendor clues. Flow arrows One normalized DNS observation. → infer_provider_hints → `infer_stack_signature` and the report layers use the hints it produces. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
infer_stack_signature
|
What this block is doing Collapses several low-level DNS clues into one human-readable delivery label. Flow arrows One DNS observation plus provider clues. → infer_stack_signature → `ct_master_report` uses the resulting label in naming and DNS chapters. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
scan_name_live
|
What this block is doing Runs the live DNS walk for one hostname. Flow arrows One DNS name from a SAN entry. → scan_name_live → `scan_name_cached` returns this result shape to higher-level analytics. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
scan_name_cached
|
What this block is doing Reuses a recent DNS result if possible, otherwise performs the live scan. Flow arrows A DNS name plus cache settings. → scan_name_cached → `ct_master_report.enrich_dns` uses this for every SAN name in the current corpus. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
ptr_lookup
|
What this block is doing This function is one of the building blocks inside `ct_dns_utils.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → ptr_lookup → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
provider_explanations
|
What this block is doing Supplies the glossary text used later in the reports. Flow arrows The delivery labels used by the report. → provider_explanations → The monograph glossary uses these explanations directly. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |