T1205.001

Port Knocking

Adversaries may use port knocking to conceal open ports used for persistence or command and control. A predefined sequence of connection attempts to closed ports causes the host-based firewall (or custom software) to dynamically open a listening port. Implementations include libpcap-based packet sniffing (cd00r, REPTILE), raw socket listeners, and dedicated daemons such as knockd or fwknopd. Real-world usage includes PROMETHIUM configuring knockd for C2 access, UNC3886 using ICMP-based knocking on FortiGate firewalls, the Mafalda/metaMain implant pair using knocking for inter-implant authentication, and REPTILE malware accepting knock sequences to activate backdoor access.

Microsoft Sentinel / Defender
kusto
// T1205.001 — Port Knocking Detection
// Three detection branches: Linux knockd daemon activity, network knock sequences via firewall logs, and knock client tool execution

// Branch 1: Linux endpoints — knockd/fwknopd daemon syslog messages indicating knock sequences
let KnockdActivity =
Syslog
| where TimeGenerated > ago(24h)
| where ProcessName in ("knockd", "fwknopd")
    or SyslogMessage has_any ("knockd", "fwknop", "knock sequence", "OPEN SESAME", "Opening port", "Stage 1", "correct knock")
| extend DetectionBranch = case(
    SyslogMessage has_any ("Opening port", "OPEN SESAME", "correct knock", "sequence complete"), "KnockSequenceTriggered",
    SyslogMessage has_any ("Stage 1", "Stage 2", "Stage 3"), "KnockSequenceInProgress",
    ProcessName in ("knockd", "fwknopd"), "KnockDaemonRunning",
    "KnockdGeneralActivity"
  )
| project TimeGenerated, Computer, HostName, ProcessName, SyslogMessage, DetectionBranch;

// Branch 2: Network/firewall devices — rapid sequential denied connections to distinct ports
// from same source IP within a tight time window (knock pattern vs port scan differentiation)
let NetworkKnockSequence =
CommonSecurityLog
| where TimeGenerated > ago(24h)
| where DeviceAction in~ ("Deny", "Drop", "Block", "Reject", "DENY", "DROP")
| where isnotempty(SourceIP) and isnotempty(DestinationPort)
| summarize
    DistinctPortsHit = dcount(DestinationPort),
    PortSequence = make_set(DestinationPort, 10),
    TotalPackets = count(),
    WindowStart = min(TimeGenerated),
    WindowEnd = max(TimeGenerated)
    by SourceIP, DeviceName, DeviceProduct, bin(TimeGenerated, 1m)
| where DistinctPortsHit between (3 .. 8)   // knock sequences are 3-8 ports — not a full port scan
    and TotalPackets between (3 .. 12)       // low packet count distinguishes knocking from scanning
| extend KnockDurationSec = datetime_diff('second', WindowEnd, WindowStart)
| where KnockDurationSec between (1 .. 30) // tight timing window characteristic of automated knock sequences
| extend DetectionBranch = "RapidSequentialPortsDenied"
| project TimeGenerated = WindowStart, SourceIP, DeviceName, DeviceProduct,
         DistinctPortsHit, PortSequence, TotalPackets, KnockDurationSec, DetectionBranch;

// Branch 3: Endpoint — execution of known port-knocking client tools
let KnockClientTool =
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("knock", "knock.exe", "fwknop", "fwknop.exe")
    or (FileName in~ ("hping3", "hping3.exe", "nping") and ProcessCommandLine has_any ("--syn", "-S", "--tcp"))
    or ProcessCommandLine has_any ("--knock-port", "-knock", "/etc/knockd.conf", "knockd.conf")
| extend DetectionBranch = "KnockClientToolExecution"
| project TimeGenerated = Timestamp, Computer = DeviceName, AccountName, FileName,
         ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionBranch;

union kind=outer KnockdActivity, NetworkKnockSequence, KnockClientTool
| sort by TimeGenerated desc
high severity medium confidence

Data Sources

Network Traffic: Network Traffic Flow Network Traffic: Network Connection Creation Process: Process Creation Firewall: Firewall Rule Modification Linux Syslog

Required Tables

Syslog CommonSecurityLog DeviceProcessEvents

False Positives

  • Legitimate administrators using knockd or fwknopd to protect SSH access on servers — extremely common on hardened Linux hosts exposed to the internet
  • Security scanners and vulnerability assessment tools (Nessus, Qualys, Rapid7) that probe multiple ports in sequence during authorized scans
  • Network monitoring and probing tools that check port availability across a range, which may resemble a knock sequence in firewall deny logs
  • Developers or sysadmins manually testing firewall rules by attempting connections to multiple ports in succession
  • Load balancer health checks or service mesh probes that contact multiple backend ports in a brief window

Unlock Pro Content

Get the full detection package for T1205.001 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections