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

Reverse Shell Execution

This note documents detection patterns related to Reverse Shell Execution on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Shell historybash -iInteractive shell redirectionCriticalClassic reverse shell pattern.
Shell history/dev/tcp/Bash TCP socket shellCriticalVery common manual shell technique.
Shell historync -eNetcat command execution shellCriticalHigh-confidence reverse shell indicator.
Shell historymkfifoFIFO shell constructionCriticalCommon stealth shell pattern.
Shell historypython -cPython inline reverse shellCriticalFrequently used on Linux targets.
Shell historyperl -ePerl reverse shellHighCommon on legacy systems.
Shell historyphp -rPHP shell executionHighOften seen after web compromise.
Shell history`curlbash`Remote payload executionCritical
Shell historywget -O-Inline payload executionCriticalCommon delivery chain.
auditdexecve of shell with socket utilitiesProcess execution evidenceCriticalBest attribution if enabled.
auth.log / secureshell after SSH or sudoReverse shell launched post-accessHighCorrelate with session window.
journalctlsuspicious shell invocationJournald process visibilityHighDepends on logging config.
Network telemetryoutbound connection to uncommon IPReverse callbackCriticalStrong network confirmation.
ss / netstat remnantsestablished outbound socketLive shell evidenceCriticalEspecially useful in live response.
EDR telemetryshell parent-child anomalyProcess lineageCriticalDetects shell spawned by web/app process.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Shell launched immediately after web requestWeb exploitation pivotCriticalCommon webshell-to-reverse-shell sequence.
Shell spawned by unusual parentapache, nginx, www-data, tomcatCriticalStrong exploitation signal.
Outbound connection to rare external hostUnexpected callback targetCriticalHigh-value beacon clue.
Reverse shell followed by user creationStabilization after footholdCriticalCommon attacker progression.
Reverse shell followed by sudoImmediate escalationCriticalStrong intrusion chain.
Temporary file then shellPayload staging in /tmp, /dev/shmHighCommon staging behavior.
One-line interpreter executionMinimal footprint shellHighSuggests hands-on operator.
Connection on uncommon high portAd hoc callbackHighOften operator-controlled listener.
Short-lived shell burstsInteractive operator reconnectsHighCommon unstable shell behavior.
No shell history but network evidenceNon-interactive executionHighPossible web or cron context.

Common Tools

ToolUsage
bashNative shell redirection.
nc / netcatSocket-based shell delivery.
socatAdvanced interactive reverse shell.
pythonInline socket shell creation.
perlLegacy inline reverse shell.
phpCommon post-web compromise shell.
openssl s_clientTLS shell tunneling.
curl / wgetPayload fetch then execute.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Shell history.bash_history, .zsh_historyCriticalPrimary command evidence.
Audit logs/var/log/audit/audit.logCriticalProcess-level execution.
Auth logs/var/log/auth.log, /var/log/secureHighSession context before shell.
JournaldjournalctlHighProcess clues on some systems.
Network socketsss -tunap, netstat -tunapCriticalLive callback evidence.
Temporary directories/tmp, /var/tmp, /dev/shmCriticalStagers often remain here.
Web roots/var/www, app dirsHighReverse shell may originate from web foothold.
Process treeps auxfCriticalParent-child shell lineage.
File timestampsstat on payload filesHighTimeline anchor.

MITRE ATT&CK References

  • T1059 Command and Scripting Interpreter
  • T1059.004 Unix Shell
  • T1105 Ingress Tool Transfer
  • T1071 Application Layer Protocol

Decision Tree

  1. Is shell syntax present?

    • Search for known reverse shell strings.
  2. Which interpreter launched it?

    • Bash, python, perl, php, nc, socat.
  3. Which parent process exists?

    • SSH, sudo, web server, cron, systemd.
  4. Was outbound connection created?

    • Identify destination IP and port.
  5. Did shell lead to persistence?

    • Inspect users, keys, cron, services.
  6. Pivot

    • Parent process → intrusion source.
    • Destination IP → operator infra.
    • Payload file → staging path.
  7. Confirm shell

    • Shell syntax + outbound socket + suspicious parent = high-confidence reverse shell.

Example Detection Templates

Grep

grep -R "bash -i\|/dev/tcp\|nc -e\|mkfifo\|python -c\|perl -e\|php -r" /home /root /tmp /var/tmp 2>/dev/null
grep -R "curl | bash\|wget -O-\|socat" /home /root /tmp /var/tmp 2>/dev/null
grep -R "bash -i" /home/*/.bash_history /root/.bash_history 2>/dev/null

Journalctl

journalctl | grep -E "bash|python|perl|nc|socat"

Network Inspection

ss -tunap
netstat -tunap

Sigma

title: Linux Reverse Shell Execution Indicators
id: linux-reverse-shell-execution
status: experimental
description: Detects common reverse shell syntax and suspicious shell execution indicators
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'bash -i'
      - '/dev/tcp'
      - 'nc -e'
      - 'mkfifo'
      - 'python -c'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Rare admin troubleshooting
level: high
tags:
  - attack.execution
  - attack.t1059.004

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Egress filteringRestrict outbound arbitrary connectionsCriticalStops callback channels.
Shell monitoringAlert on shell spawned by service accountsCriticalHigh-signal detection.
AuditdTrack execve and network-linked shell activityHighStrong attribution.
Least privilegeRestrict interpreters for service usersHighReduces shell options.
Web hardeningPrevent shell execution from app contextCriticalMajor web compromise barrier.
Temp monitoringWatch /tmp, /dev/shm, /var/tmpHighCommon staging zones.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Was shell syntax executed?grep historiesImmediate confirmation.
Which parent process launched shell?ps auxfDetermines intrusion source.
Is callback still active?ss -tunapLive shell detection.
Did shell touch temp files?inspect temp dirsStaging clue.
Was sudo used after shell?grep sudo logsEscalation chain.
Did persistence follow?inspect keys, cron, usersStabilization evidence.

High Value Grep Strings

PatternWhy It Matters
bash -iClassic reverse shell.
/dev/tcpBash socket shell.
nc -eNetcat shell.
mkfifoFIFO shell pattern.
python -cInline interpreter shell.
perl -ePerl shell.
php -rPHP shell.
`curlbash`
wget -O-Inline fetch-execute.
socatAdvanced shell transport.

Analyst Notes

ScenarioInterpretation
Shell from web processLikely exploitation chain.
Shell after SSH successOperator moved from stable foothold into callback tooling.
Shell plus temp payloadStaged execution highly likely.
Outbound connection to rare IPStrong callback evidence.
Reverse shell without historyNon-interactive context or cleanup likely.
Multiple shell syntaxes presentOperator fallback attempts.