Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / NETWORK

Unexpected Ports

This note documents detection patterns related to Unexpected Ports on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
ss -tulpnlistener on uncommon high portSuspicious serviceCriticalStrong runtime signal.
netstat -tulpnunknown process boundActive payload/listenerCriticalImmediate attribution needed.
lsof -ihidden/temp binary owns portMalicious listenerCriticalStrong compromise clue.
Shell historync -lvpManual listenerCriticalCommon reverse shell handler / pivot.
Shell historypython -m http.serverAd hoc file serverHighOften payload transfer.
Shell historysocat TCP-LISTENTunnel/listenerCriticalStrong operator indicator.
Firewall logsnew inbound portExposure changeCriticalStrong operational clue.
Auditdlistener command executionProcess attributionCriticalBest attribution if enabled.
Journaldservice binds unexpected portRuntime clueHighUseful service context.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Port appears after footholdPayload activationCriticalStrong compromise chain.
Temp binary owns listenerHigh-confidence maliciousCriticalStrong signal.
Listener plus outbound callbackFull C2 behaviorCriticalVery high severity.
High port under service accountSuspicious contextCriticalOften exploitation-driven.
Listener disappears quicklyShort-lived stagingHighCommon operator behavior.

Common Tools

ToolUsage
ssSocket enumeration.
netstatLegacy socket review.
lsofPID attribution.
ncSimple listener.
python -m http.serverTemporary transfer port.
socatFlexible listener/relay.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Live socketsss -tulpnCriticalRuntime truth.
Process path/proc/<pid>/exeCriticalBinary attribution.
Shell history.bash_historyCriticalLaunch evidence.
Audit logs/var/log/audit/audit.logCriticalProcess attribution.

MITRE ATT&CK References

  • T1046 Network Service Scanning
  • T1571 Non-Standard Port
  • T1090 Proxy

Decision Tree

  1. Which port is unexpected?
  2. Which process owns it?
  3. Is process legitimate?
  4. Is port linked to tunnel, payload, or transfer?

Example Detection Templates

Grep

grep -R "nc -lvp\|python -m http.server\|socat TCP-LISTEN" /home/*/.bash_history /root/.bash_history 2>/dev/null

Journalctl

journalctl | grep -E "listen|bind"

File Inspection

ss -tulpn
lsof -i

Sigma

title: Linux Unexpected Ports
id: linux-unexpected-ports
status: experimental
description: Detects suspicious listeners on uncommon ports
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'nc -lvp'
      - 'socat TCP-LISTEN'
  condition: selection_keywords
level: high
tags:
  - attack.command_and_control
  - attack.t1571

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Socket monitoringAlert on new listenersCriticalStrong runtime detection.
Firewall policyRestrict high-port exposureCriticalReduces rogue listeners.
Process attributionReview listener ownersHighFast triage.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Which PID owns port?lsof / ssCore truth.
Is binary expected?/proc pathSuspicion scoring.
Is port linked to payload?history + processFull chain.