Sigma rule: Python Reverse Shell Execution Via PTY And Socket Modules

A detection rule from the SigmaHQ repository, shown as its author published it. Dataset version ref-d87cd34818c2, updated 2024-11-04T00:00:00.000Z.

Rule

Title
Python Reverse Shell Execution Via PTY And Socket Modules
Status
test
Level
high
Author
@d4ns4n_, Nasreddine Bencherchali (Nextron Systems)
Date
2023-04-24
Modified
2024-11-04
File
rules/linux/process_creation/proc_creation_lnx_python_reverse_shell.yml
Commit
ccbb0369507f796db0b0ae6854c8a2be471b9d84

Detects the execution of python with calls to the socket and pty module in order to connect and spawn a potential reverse shell.

Log source

product
linux
category
process_creation

Detection

selection:
    Image|contains: 'python'
    CommandLine|contains|all:
        - ' -c '
        - 'import'
        - 'pty'
        - 'socket'
        - 'spawn'
        - '.connect'
condition: selection

False positives (as the rule lists them)

  • Unknown

Tags

  • attack.execution

Related rules

References

Read on 2026-11-03T00:58:21.399Z under licence sigma-drl-1.1@d5f4c36a from https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules/linux/process_creation/proc_creation_lnx_python_reverse_shell.yml

Sources and licences

  • SigmaHQ

    "Python Reverse Shell Execution Via PTY And Socket Modules" by @d4ns4n_, Nasreddine Bencherchali (Nextron Systems) (SigmaHQ). Rule: https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules/linux/process_creation/proc_creation_lnx_python_reverse_shell.yml.
    Licensed under the Detection Rule License (DRL) 1.1: https://github.com/SigmaHQ/Detection-Rule-License

    Detection Rule License (DRL) 1.1

Cite this page

Dragons Eye Ransomware Tracker, "Sigma rule: Python Reverse Shell Execution Via PTY And Socket Modules",
entity page, dataset version ref-d87cd34818c2, updated 2024-11-04T00:00:00.000Z,
https://ransomware-tracker.com/detections/sigma/32e62bc7-3de0-4bb1-90af-532978fe42c0 (accessed 2026-11-03).
Underlying source: SigmaHQ rule 32e62bc7-3de0-4bb1-90af-532978fe42c0, commit ccbb0369507f796db0b0ae6854c8a2be471b9d84.

Pages change. The dataset version identifies the data, but no archive of old versions is kept, so this citation cannot be replayed later.