You can't stop attackers from using AI to generate exploit scripts, but you can configure your industrial control systems to detect when those scripts target your Siemens S7 Series PLCs.
This post provides a detection rule template and configuration checklist you can implement immediately. Threat actors are actively using AI to create Python scripts that exploit the snap7.dll library to access S7 Series PLCs via the S7comm protocol. They're targeting sectors like Critical Manufacturing, Energy, Water and Wastewater, Chemical, Food and Agriculture, and Commercial Facilities.
Purpose of This Template
This detection configuration identifies AI-generated exploitation attempts against Siemens S7 Series PLCs by recognizing behavioral patterns that legitimate engineering tools don't exhibit. It focuses on S7comm protocol anomalies, unauthorized snap7.dll library usage, and indicators suggesting automated scripting rather than human operators.
You'll get:
- Network detection rules for S7comm traffic on TCP port 102
- Host-based detection for unauthorized snap7.dll usage
- Baseline configuration guidance for distinguishing legitimate from malicious patterns
- Alert prioritization criteria
Prerequisites
Before implementing these detection rules, ensure you have:
Network visibility:
- ICS-aware intrusion detection deployed (Claroty, Dragos Platform, Nozomi Networks, or equivalent)
- Ability to inspect S7comm protocol traffic
- Packet capture capability on OT network segments
Asset inventory:
- Complete list of all Siemens S7-200, S7-300, S7-400, S7-1200, and S7-1500 controllers
- Documentation of authorized engineering workstations with TIA Portal or STEP 7 access
- Current firmware versions verified against backup gold copies
Baseline data:
- Normal S7comm connection patterns during operational hours
- Approved maintenance windows and change control schedules
- Authorized IP ranges for vendors and system integrators
Detection Rule Template
Network-Based S7comm Detection
rule_name: Unauthorized_S7comm_Connection
protocol: TCP
port: 102
trigger_conditions:
- source_ip NOT IN [authorized_engineering_workstations]
- destination_ip IN [siemens_plc_inventory]
- connection_time OUTSIDE [approved_maintenance_windows]
alert_severity: HIGH
action: ALERT, LOG, BLOCK_OPTIONAL
rule_name: S7comm_Write_Operation_Anomaly
protocol: S7comm
function_code: [0x05 (Write Var), 0x28 (PLC Stop), 0x29 (PLC Start)]
trigger_conditions:
- data_block_access = TRUE
- configuration_write = TRUE
- source_ip NOT IN [authorized_engineering_workstations]
alert_severity: CRITICAL
action: ALERT, LOG, BLOCK_RECOMMENDED
rule_name: Sequential_PLC_Scanning
protocol: TCP
port: 102
trigger_conditions:
- connection_attempts > 5 WITHIN 60_seconds
- target_ips = sequential_range
- connection_pattern = SYN_scan OR enumeration
alert_severity: MEDIUM
action: ALERT, LOG
notes: "Indicates reconnaissance via Internet scanning services"
Host-Based Detection (Engineering Workstations)
rule_name: Unauthorized_Snap7_Library_Usage
file_path: [C:\Windows\System32\snap7.dll, /usr/lib/python*/site-packages/snap7/]
trigger_conditions:
- process_name NOT IN [tia_portal.exe, s7_*.exe, approved_monitoring_tools.exe]
- parent_process = [python.exe, python3.exe, powershell.exe]
- network_connection TO port_102 = TRUE
alert_severity: CRITICAL
action: ALERT, LOG, ISOLATE_WORKSTATION
rule_name: Python_Script_S7comm_Activity
process_name: [python.exe, python3.exe]
trigger_conditions:
- loaded_modules CONTAINS snap7.dll
- network_connection TO port_102 = TRUE
- script_location NOT IN [approved_automation_directories]
alert_severity: HIGH
action: ALERT, LOG, SUSPEND_PROCESS
Temporal and Geographic Anomaly Detection
rule_name: Off_Hours_S7comm_Activity
protocol: S7comm
trigger_conditions:
- connection_time BETWEEN [2200_hours, 0600_hours] LOCAL_TIME
- source_ip NOT IN [24x7_monitoring_systems]
- NO corresponding_change_ticket IN [change_management_system]
alert_severity: MEDIUM
action: ALERT, LOG
rule_name: Geographic_Anomaly
protocol: S7comm
trigger_conditions:
- source_country NOT IN [authorized_countries_list]
- source_ip NOT IN [known_vendor_ranges]
alert_severity: HIGH
action: ALERT, LOG, BLOCK_RECOMMENDED
Customization Steps
Step 1: Populate your authorized lists
Replace bracketed placeholders with actual values:
[authorized_engineering_workstations]: IP addresses or MAC addresses of workstations running TIA Portal/STEP 7[siemens_plc_inventory]: IP addresses of all S7 Series PLCs from your asset inventory[approved_maintenance_windows]: Time ranges when legitimate PLC programming occurs (format: day_of_week, start_time, end_time)[approved_monitoring_tools.exe]: Process names of legitimate tools that use snap7.dll
Step 2: Set severity thresholds
Adjust alert severity based on your risk tolerance:
- CRITICAL: Requires immediate response, potential active exploitation
- HIGH: Suspicious activity warranting investigation within 1 hour
- MEDIUM: Anomalous behavior requiring review within 24 hours
Step 3: Configure block vs. alert-only
For production environments, start with ALERT mode to validate false positive rates. Move to BLOCK after confirming detection accuracy over 2-4 weeks. Never block without testing; you don't want to interrupt legitimate maintenance.
Step 4: Integrate with change management
Link temporal anomaly detection to your change control system. If your ITSM platform has an API, query for active change tickets before alerting on off-hours S7comm activity.
Step 5: Define escalation paths
Map alert severity to response procedures:
- CRITICAL: Page on-call OT security team immediately
- HIGH: Create incident ticket, notify shift supervisor
- MEDIUM: Aggregate for daily security review
Validation Steps
Validate network detection:
- From an authorized engineering workstation, connect to a test PLC during a maintenance window.
- Verify no alert fires.
- From an unauthorized workstation (or change the source IP in your test), attempt the same connection.
- Confirm HIGH severity alert triggers within 30 seconds.
Validate snap7.dll detection:
- On a test engineering workstation, run a legitimate TIA Portal session.
- Verify no alert fires.
- Execute a Python script that imports snap7 and attempts PLC connection.
- Confirm CRITICAL alert triggers and process suspension occurs.
Validate temporal detection:
- Schedule a legitimate maintenance activity outside normal hours.
- Create corresponding change ticket in your ITSM system.
- Perform S7comm connection.
- Verify alert does not fire if change ticket integration is working, or fires MEDIUM if you're using alert-only mode.
Test false positive rate: Run detection rules in monitor-only mode for two weeks. Review all alerts. If false positive rate exceeds 10%, refine your authorized lists and baseline parameters before enabling blocking actions.
Verify geographic blocking: If you use VPN services for vendor access, ensure those IP ranges are in your authorized list. Test by having a vendor connect from their normal location; no alert should fire.
You've now got detection rules that recognize the behavioral signatures of AI-generated PLC exploitation scripts. Attackers are using AI to lower the barrier to ICS attacks. Your job is to raise the barrier to successful exploitation by detecting their activity before they move from reconnaissance to operational effects.
[REFERENCE URLS]





