Skip to main content

Overview

Somnium is most effective when integrated with your existing security infrastructure. This guide shows how to correlate Somnium test results with firewalls, SIEM platforms, and IDS/IPS systems to validate comprehensive security coverage.

Integration Architecture

┌─────────────┐
│   Somnium   │ Generates malicious traffic
│ Test System │
└──────┬──────┘


┌─────────────────────────────────────┐
│     Security Control Layer          │
├─────────────┬──────────────┬────────┤
│  Firewall   │   IDS/IPS    │  Proxy │
└──────┬──────┴──────┬───────┴───┬────┘
       │             │           │
       └─────────────┼───────────┘

              ┌────────────┐
              │    SIEM    │
              │  Platform  │
              └────────────┘

              ┌──────┴──────┐
              ▼             ▼
         ┌────────┐   ┌──────────┐
         │ Alerts │   │ Reports  │
         └────────┘   └──────────┘

Firewall Integration

Configuration

1

Enable threat prevention logging

# CLI configuration
set deviceconfig setting logging log-suppression no
set shared log-settings profiles <profile-name> match-list <entry> send-to-panorama yes
2

Configure security policy logging

Enable logging at session start and end:
set rulebase security rules <rule-name> log-start yes
set rulebase security rules <rule-name> log-end yes
3

Enable threat feeds

Ensure threat intelligence feeds are active:
  • Device > Setup > Dynamic Updates > Threat Prevention
  • Check “Anti-Spyware” and “WildFire” are current

Correlation Queries

After running Somnium tests, search Palo Alto logs:
( action = deny or action = drop ) 
and ( src = <somnium_test_system_ip> )
and ( receive_time >= '<test_start_time>' )
( threat_category neq "any" )
and ( src = <somnium_test_system_ip> )
and ( receive_time >= '<test_start_time>' )
( action = allow )
and ( src = <somnium_test_system_ip> )
and ( dest_ip in <malicious_ip_list> )

Example Alert Rule

Create custom correlation object for Somnium testing:
<entry name="Somnium-Unexpected-Allow">
  <description>Alert when Somnium test traffic is allowed</description>
  <filter>( action eq allow ) and ( src eq <test_system_ip> ) and ( threat_category neq any )</filter>
  <threshold>1</threshold>
  <interval>1</interval>
</entry>

SIEM Integration

Somnium Result Ingestion

1

Configure file monitoring

Create inputs.conf for Somnium results:
[monitor:///opt/somnium/*_Results.txt]
disabled = false
sourcetype = somnium:results
index = security
2

Create field extractions

Add props.conf for parsing:
[somnium:results]
SHOULD_LINEMERGE = false
TIME_PREFIX = Timestamp:
TIME_FORMAT = %H:%M:%S

EXTRACT-ip_test = Timestamp:(?<timestamp>\S+)\s+IP:(?<dest_ip>\S+)\s+:\s+Port:(?<dest_port>\d+)\s+test\s+(?<result>\w+)
EXTRACT-url_test = Timestamp:(?<timestamp>\S+)\s+URL:(?<dest_url>\S+)\s+test\s+(?<result>\w+)
EXTRACT-doh_test = Timestamp:(?<timestamp>\S+)\s+(?<provider>\w+)\s+response\s+for\s+(?<query_domain>\S+)
3

Create correlation searches

Build searches to correlate Somnium tests with security events.

Correlation Searches

index=security sourcetype=somnium:results result="SUCCESSFUL"
| eval somnium_time=strptime(timestamp, "%H:%M:%S")
| join type=left dest_ip 
  [ search index=firewall action=deny OR action=drop 
  | eval fw_time=_time ]
| where isnull(fw_time)
| table timestamp, dest_ip, dest_port, result
| eval status="SECURITY GAP: Connection succeeded but no firewall block"
index=security sourcetype=somnium:results
| eval test_time=strptime(timestamp, "%H:%M:%S")
| join type=left dest_ip 
  [ search index=ips signature!="" 
  | rename dest_ip as attacked_ip
  | eval ips_time=_time ]
| eval time_diff=abs(test_time - ips_time)
| where time_diff < 60
| table timestamp, dest_ip, result, signature, action
index=security sourcetype=somnium:results
| stats count by result, source
| eval total_tests=sum(count)
| eval block_rate=if(result="FAILED", count/total_tests*100, null())
| table source, result, count, block_rate
| sort -block_rate
sourcetype=somnium:results source="*DoH_Results.txt"
| rex field=_raw "response for (?<domain>\S+)"
| join type=left domain 
  [ search index=firewall dest_category="DNS over HTTPS" action=deny ]
| where isnull(action)
| stats count by domain, provider
| eval issue="DoH queries succeeded - DNS security bypassed"

Dashboard Example

<dashboard>
  <label>Somnium Security Validation</label>
  <row>
    <panel>
      <title>Block Rate by Test Type</title>
      <chart>
        <search>
          <query>
            index=security sourcetype=somnium:results
            | eval test_type=case(
                source LIKE "%IP_Results%", "Bad IPs",
                source LIKE "%URL_Results%", "Phishing",
                source LIKE "%TOR_Results%", "TOR Nodes",
                source LIKE "%Malware_Results%", "Malware",
                1=1, "Other")
            | stats count by test_type, result
            | chart sum(count) over test_type by result
          </query>
        </search>
        <option name="charting.chart">column</option>
        <option name="charting.chart.stackMode">stacked</option>
      </chart>
    </panel>
  </row>
</dashboard>

IDS/IPS Integration

Custom Rule for Somnium Testing

Create detection rules for Somnium patterns:
# /etc/suricata/rules/somnium.rules

# Detect connections to known bad IPs during testing
alert tcp $HOME_NET any -> $EXTERNAL_NET any \
  (msg:"Somnium Test: Connection to Threat Intel IP"; \
   threshold: type both, track by_src, count 5, seconds 60; \
   sid:9000001; rev:1;)

# Detect DGA domain patterns
alert dns $HOME_NET any -> any 53 \
  (msg:"Somnium Test: Possible DGA Domain Query"; \
   dns_query; content:".xyz"; nocase; \
   pcre:"/^[a-z]{8,15}\.(xyz|top|tk|gq|club)$/i"; \
   sid:9000002; rev:1;)

# Detect DNS over HTTPS
alert tls $HOME_NET any -> $EXTERNAL_NET 443 \
  (msg:"Somnium Test: DNS over HTTPS to Public Resolver"; \
   tls_sni; content:"dns.google"; \
   sid:9000003; rev:1;)

alert tls $HOME_NET any -> $EXTERNAL_NET 443 \
  (msg:"Somnium Test: DNS over HTTPS to Cloudflare"; \
   tls_sni; content:"cloudflare-dns.com"; \
   sid:9000004; rev:1;)

# Detect known bad user agents
alert http $HOME_NET any -> $EXTERNAL_NET any \
  (msg:"Somnium Test: Malicious User-Agent Detected"; \
   http_user_agent; content:"sqlmap"; \
   sid:9000005; rev:1;)

alert http $HOME_NET any -> $EXTERNAL_NET any \
  (msg:"Somnium Test: Scanner User-Agent"; \
   http_user_agent; content:"masscan"; \
   sid:9000006; rev:1;)

Enable EVE JSON Logging

# /etc/suricata/suricata.yaml
outputs:
  - eve-log:
      enabled: yes
      filetype: regular
      filename: eve.json
      types:
        - alert
        - dns
        - tls
        - http

Validation Query

# Check if Somnium tests triggered alerts
jq 'select(.event_type=="alert" and .alert.signature_id >= 9000000)' \
  /var/log/suricata/eve.json | jq -s 'group_by(.alert.signature) | \
  map({signature: .[0].alert.signature, count: length})'

Automated Validation Workflow

1

Schedule Somnium tests

Create a cron job for regular security validation:
# Run Somnium tests every Monday at 2 AM
0 2 * * 1 /usr/bin/python3 /opt/somnium/automated_test.py
Example automation script:
#!/usr/bin/env python3
import subprocess
import time
from datetime import datetime

tests = [
    (1, "Known Bad IPs"),
    (2, "Phishing URLs"),
    (3, "TOR Exit Nodes"),
    (8, "Bad User Agents"),
    (9, "DNS over HTTPS")
]

test_start = datetime.now()
print(f"Starting automated Somnium tests at {test_start}")

for test_num, test_name in tests:
    print(f"Running test {test_num}: {test_name}")
    proc = subprocess.Popen(
        ['python3', 'main.py'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    proc.communicate(input=f"{test_num}\n0\n".encode())
    time.sleep(10)  # Wait between tests

test_end = datetime.now()
print(f"Tests completed at {test_end}")
print(f"Total duration: {test_end - test_start}")
2

Trigger SIEM correlation

After tests complete, run SIEM queries to validate detection:
# Example: Trigger Splunk saved search
curl -k -u admin:password https://splunk:8089/services/saved/searches/somnium_validation/dispatch \
  -d earliest_time="-30m" -d latest_time="now"
3

Generate validation report

Create automated report of findings:
import glob
from collections import Counter

def analyze_results():
    report = {}
    
    for result_file in glob.glob("*_Results.txt"):
        test_type = result_file.replace("_Results.txt", "")
        
        with open(result_file, 'r') as f:
            content = f.read()
            
        successful = content.count("SUCCESSFUL") + content.count("SUCCESFULL")
        failed = content.count("FAILED")
        total = successful + failed
        
        if total > 0:
            block_rate = (failed / total) * 100
            report[test_type] = {
                'total': total,
                'blocked': failed,
                'allowed': successful,
                'block_rate': block_rate
            }
    
    return report

# Generate markdown report
report = analyze_results()
print("# Somnium Security Validation Report\n")
print(f"**Test Date:** {datetime.now()}\n")
print("| Test Type | Total | Blocked | Allowed | Block Rate |")
print("|-----------|-------|---------|---------|------------|")

for test, metrics in report.items():
    print(f"| {test} | {metrics['total']} | {metrics['blocked']} | "
          f"{metrics['allowed']} | {metrics['block_rate']:.1f}% |")
4

Alert on gaps

Send notifications when security gaps are found:
import smtplib
from email.mime.text import MIMEText

def send_alert(gaps):
    if not gaps:
        return
    
    body = "Security gaps detected in Somnium testing:\n\n"
    for gap in gaps:
        body += f"- {gap}\n"
    
    msg = MIMEText(body)
    msg['Subject'] = 'ALERT: Somnium Security Gaps Detected'
    msg['From'] = '[email protected]'
    msg['To'] = '[email protected]'
    
    smtp = smtplib.SMTP('localhost')
    smtp.send_message(msg)
    smtp.quit()

# Check for gaps
gaps = []
for test, metrics in report.items():
    if metrics['allowed'] > 0:
        gaps.append(f"{test}: {metrics['allowed']} threats not blocked")

if gaps:
    send_alert(gaps)

Best Practices

Coordinate with your security team - Always notify SOC analysts before running Somnium tests to avoid alarm fatigue and unnecessary incident response.
Use dedicated test systems - Run Somnium from isolated test VMs or dedicated security validation hosts, not production workstations.
Tag test traffic - Configure Somnium test systems with identifiable hostnames or IP addresses so security logs can easily distinguish validation traffic from real threats.
Archive results - Keep historical test results to track security posture improvements over time and demonstrate compliance.
Some security controls may require tuning to detect Somnium tests. Work with your vendors to ensure threat intelligence feeds are current and detection signatures are enabled.

Build docs developers (and LLMs) love