performing-s7comm-protocol-security-analysis
하는 일
이 도구는 Siemens SIMATIC S7 장치의 보안 통신을 분석합니다. 프로그램을 바꾸거나 허가 없이 시스템을 멈추는 등 공격에 악용될 수 있는 약점을 찾습니다.
사용하는 경우
- ✓Siemens 산업 시스템의 보안을 점검할 때.
- ✓S7 컨트롤러를 겨냥한 공격을 탐지하는 규칙을 만들 때.
- ✓컴퓨터와 Siemens 컨트롤러 사이의 통신을 감사하는 경우.
스킬 링크
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-s7comm-protocol-security-analysis/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“S7comm 네트워크 트래픽을 분석해 취약점을 찾아 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
도구는 Siemens 장치 사이에서 교환되는 데이터 패킷을 검사합니다. 공격 시도나 보안 결함을 나타낼 수 있는 의심스러운 패턴이나 명령을 식별합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Performing S7comm Protocol Security Analysis
When to Use
- When assessing the security posture of Siemens SIMATIC S7 PLC environments
- When building detection rules for S7comm-based attacks against S7-300/400/1200/1500 controllers
- When performing a security audit of Siemens Step 7/TIA Portal communications
- When investigating suspected unauthorized access to Siemens PLC programs
- When evaluating S7CommPlus integrity mechanisms and their bypass potential
Do not use for scanning production Siemens PLCs without authorization and a test plan (this can crash controllers), for non-Siemens protocol analysis (see detecting-modbus-command-injection-attacks for Modbus), or for modifying PLC programs in a production environment.
Prerequisites
- Network access to the S7comm communication segment (TCP port 102)
- Wireshark with S7comm dissector or Zeek with S7comm protocol analyzer
- Authorized access for security testing (never scan production PLCs without authorization)
- Knowledge of the Siemens PLC models and firmware versions in scope
- Understanding of S7comm protocol structure (COTP, S7 PDU, function codes)
Workflow
Step 1: Analyze S7comm Traffic and Identify Vulnerabilities
#!/usr/bin/env python3
"""S7comm Protocol Security Analyzer.
Analyzes Siemens S7comm protocol traffic to identify security
vulnerabilities, unauthorized access patterns, and potential
attack indicators against SIMATIC S7 PLCs.
"""
import struct
import sys
import json
from collections import defaultdict
from datetime import datetime
from typing import Dict, List, Optional
try:
from scapy.all import rdpcap, IP, TCP
except ImportError:
print("Install scapy: pip install scapy")
sys.exit(1)
# S7comm ROSCTR (PDU type) definitions
S7_ROSCTR = {
0x01: "Job (Request)",
0x02: "Ack",
0x03: "Ack_Data (Response)",
0x07: "Userdata",
}
# S7comm function codes
S7_FUNCTIONS = {
0x00: "CPU services",
0x04: "Read Variable",
0x05: "Write Variable",
0x1A: "Request Download (Program)",
0x1B: "Download Block",
0x1C: "Download Ended",
0x1D: "Start Upload (Read Program)",
0x1E: "Upload Block",
0x1F: "Upload Ended",
0x28: "PI Service (Start/Stop CPU)",
0x29: "PLC Stop",
0xF0: "Setup Communication",
}
# Critical security-relevant operations
CRITICAL_FUNCTIONS = {0x1A, 0x1B, 0x1C, 0x28, 0x29, 0x05}
PROGRAM_FUNCTIONS = {0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}
class S7commSecurityFinding:
"""Represents a security finding in S7comm traffic."""
def __init__(self, severity: str, finding_type: str, src_ip: str,
dst_ip: str, function: str, description: str,
cve: str = "", recommendation: str = ""):
self.timestamp = datetime.now().isoformat()
self.severity = severity
self.finding_type = finding_type
self.src_ip = src_ip
self.dst_ip = dst_ip
self.function = function
self.description = description
self.cve = cve
self.recommendation = recommendation
class S7commAnalyzer:
"""Analyzes S7comm protocol traffic for security vulnerabilities."""
def __init__(self):
self.findings: List[S7commSecurityFinding] = []
self.sessions: Dict[str, dict] = defaultdict(lambda: {
"packets": 0,
"functions_seen": set(),
"writes": 0,
"program_downloads": 0,
"cpu_commands": 0,
"first_seen": None,
"last_seen": None,
})
self.authorized_engineering: set = set()
self.packet_count = 0
def set_authorized_stations(self, ips: List[str]):
"""Set list of authorized engineering workstation IPs."""
self.authorized_engineering = set(ips)
def parse_s7comm(self, payload: bytes) -> Optional[dict]:
"""Parse S7comm protocol data from TCP payload."""
# TPKT header: version(1) + reserved(1) + length(2)
if len(payload) < 4:
return None
tpkt_version = payload[0]
if tpkt_version != 3:
return None
tpkt_length = struct.unpack(">H", payload[2:4])[0]
# COTP header follows TPKT
if len(payload) < 7:
return None
cotp_length = payload[4]
cotp_type = payload[5]
# S7comm starts after COTP
s7_offset = 4 + 1 + cotp_length
if len(payload) < s7_offset + 10:
return None
# S7comm header
…
자주 묻는 질문
SIMATIC S7 PLC란 무엇인가요?
산업 자동화에서 기계와 공정을 관리하는 데 쓰이는 컨트롤러입니다.
S7comm 프로토콜이란 무엇인가요?
SIMATIC S7 컨트롤러가 정보를 교환하는 데 사용하는 통신 언어입니다.
이 도구가 탐지할 수 있는 공격 유형은 무엇인가요?
명령 재전송, 승인되지 않은 프로그램 변경, 예기치 않은 시스템 중단 같은 공격을 탐지할 수 있습니다.
상세 정보
작성자의 원본 설명
Perform security analysis of Siemens S7comm and S7CommPlus protocols used by SIMATIC S7 PLCs to identify vulnerabilities including replay attacks, integrity bypass, unauthorized CPU stop commands, and program download manipulation exploiting weaknesses in S7-300, S7-400, S7-1200, and S7-1500 controllers. '
인기도
- GitHub 스타
- 35k
- 순위
- #8298
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 8. 31.
댓글
- …
이 저장소의 다른 스킬
abusing-dpapi-for-credential-access
35kAI 에이전트에게 특정 작업을 위한 준비된 지침을 제공해, 더 잘하고 더 빠르게 처리하도록 합니다.
abusing-shadow-credentials-for-privesc
35kAI 에이전트가 명확하고 잘 구성된 텍스트를 쓰도록 가르칩니다.
achieving-cmmc-level-2-compliance
35kCMMC Level 2 규정 준수를 위한 환경을 준비하도록 돕습니다. 보안 요구 사항을 구현하고 필요한 문서를 관리합니다.
acquiring-disk-image-with-dd-and-dcfldd
35k에이전트가 하드 드라이브의 정확한 복사본을 만들도록 돕습니다. 조사 중 정보가 손실되거나 변경되지 않도록 하는 데 유용합니다.