The NETCAP Rules Engine allows you to define detection rules that automatically generate alerts when specific network patterns are observed. Rules use expr-lang expressions to match audit records and can be configured to detect various attack patterns, anomalies, and policy violations.
rules:
- name: Suspicious_HTTP_Upload
description: Detect large POST requests with suspicious user agents
type: HTTP
expression: |
Method == "POST" &&
ReqContentLength > 10000000 &&
UserAgent in ["curl", "wget", "python"]
severity: high
mitre: ["T1041"]
tags: ["exfiltration", "http"]
enabled: true
rules:
- name: DNS_Large_Query
description: Detect DNS queries with long domain names
type: DNS
expression: len(Questions) > 0 && len(Questions[0].Name) > 100
severity: medium
mitre: ["T1071.004"]
tags: ["dns", "tunneling"]
enabled: true
type Alert struct {
Timestamp int64 // When the alert was generated
Name string // Rule name
Description string // Rule description
SrcIP string // Source IP from matched record
DstIP string // Destination IP from matched record
SrcPort string // Source port from matched record
DstPort string // Destination port from matched record
MITRE string // MITRE ATT&CK IDs (comma-separated)
RuleName string // Rule name (duplicate of Name)
RecordType string // Type of audit record that matched
Severity string // Alert severity level
Tags []string // Rule tags
MatchedRecord string // JSON representation of matched record
}
# View all alerts
net dump -read Alert.ncap.gz
# Filter critical alerts
net dump -read Alert.ncap.gz -filter "Severity == 'critical'"
# Find SSH-related alerts
net dump -read Alert.ncap.gz -filter "RuleName in ['SSH_Bruteforce_Attempt', 'SSH_Tunnel_Detection']"
# Common errors and solutions
# Error: undefined identifier "InvalidField"
# Solution: Check available fields with -fields flag
# Error: type mismatch
# Solution: Ensure field types match comparison (string vs int)
# Error: invalid regex
# Solution: Test regex pattern separately, escape special characters