CmdID

CmdID / Rules / Linux

Python Reverse Shell Execution Via PTY And Socket Modules

A Sigma rule for process creation on Linux, by @d4ns4n_, Nasreddine Bencherchali (Nextron Systems).

high

What it looks for

its detection, as SigmaHQ writes it
detection:
  selection:
    CommandLine|contains|all:
      - ' -c '
      - 'import'
      - 'pty'
      - 'socket'
      - 'spawn'
      - '.connect'
    Image|contains: 'python'
  condition: selection

The rule’s detection, its selections and fields in order of name. The whole rule, with its references and false positives, is on SigmaHQ, by @d4ns4n_, Nasreddine Bencherchali (Nextron Systems), under the Detection Rule License 1.1. CmdID evaluates it on a command line alone: a test on what a command line cannot show, such as the parent process or the user, is not met.

None of the everyday examples and documented commands on CmdID’s program pages trips it. To see whether a command line does, paste it into CmdID.