Linux Python Reverse Shell via pty and socket Module Execution

Alerts on Linux executions of Python -c commands that use socket and pty to connect and spawn a potential reverse shell.

FreeReviewedSigma · High · v2
Product
linux
Category
process_creation
Author
@d4ns4n_, Nasreddine Bencherchali (Nextron Systems) (SigmaHQ), DRL 1.1
Published
2023-04-24
Updated
2026-07-31

What it detects

This rule identifies Linux process executions where the command line invokes Python with inline code that imports the pty and socket modules and then uses connection and spawn-related functions. Such behavior is significant because it can be used to establish outbound connectivity and create a pseudo-terminal for interactive remote control. Telemetry relies on process creation events with the executable path and command-line arguments containing the relevant Python -c code fragments.

Changelog

v2
  1. v2
    Candidate ingested via manual entry.2026-07-31
  2. v1
    No changelog recorded for this version.2026-07-30

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.