بنقرة واحدة
entropy-analysis
Calculate DNS subdomain entropy scores for exfiltration and DGA detection.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Calculate DNS subdomain entropy scores for exfiltration and DGA detection.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Merge Stage 2 DNS analysis scores and calculate final exfiltration verdicts.
Capture live DNS queries with tcpdump for a configurable duration, save the traffic to a PCAP file, and process it through the existing PCAP reader. Use when a user explicitly requests timed live DNS capture from a network interface.
Compute DGA probabilities using a pre-trained RandomForest model.
Score DNS queries for anomalies using the trained embedding similarity model.
Generate a Markdown security report from aggregated DNS exfiltration scores.
Normalize DNS input from PCAP or CSV into one unified JSON dataset.
| name | entropy-analysis |
| description | Calculate DNS subdomain entropy scores for exfiltration and DGA detection. |
Calculate Shannon entropy for DNS subdomains to detect high-randomness
strings characteristic of DGA domains and DNS exfiltration. Used by
entropy_agent in Stage 2 parallel analysis.
calculate_entropy(input_path: str, output_path: str) -> dict
Input is a JSON file containing DNS queries with subdomain fields.
| Parameter | Type | Required | Description |
|---|---|---|---|
input_path | str | yes | Path to dns_queries.json (Stage 1 out) |
output_path | str | yes | Path to write entropy scores JSON |
Returns a dict with processing summary:
| Field | Type | Description |
|---|---|---|
total_processed | integer | Number of queries processed |
high_entropy_count | integer | Count where entropy_score > 3.5 |
output_file | string | Path where results were written |
Also writes a JSON array to output_path. Each entry contains:
| Field | Type | Description |
|---|---|---|
query_id | integer | Matching the input query_id |
domain | string | Full domain from input |
subdomain | string | Subdomain extracted from input |
label | string | Ground truth label (benign/malicious) if known |
entropy_score | float | Shannon entropy H = -Σ p(x) log₂ p(x) |
entropy_score = 0.0entropy_score = 0.0entropy_score = 0.0# No external dependencies required — uses Python stdlib only
# math.log2 for logarithm calculation
from tools.shannon_entropy import calculate_entropy
result = calculate_entropy(
input_path="data/output/dns_queries.json",
output_path="outputs/<run_timestamp>/entropy_scores.json"
)
print(f"Processed {result['total_processed']} queries")
print(f"Found {result['high_entropy_count']} high-entropy domains")
dga_classifier and embedding_agent.orchestrator_agent in Stage 3.