Linux Inline Python (-c) Calling os.system to Spawn Shell

Flags Linux processes launching inline Python (-c) that invokes os.system() to execute a shell.

FreeReviewedSigma · High · v2
Product
linux
Category
process_creation
Author
Li Ling, Andy Parkidomo, Robert Rakowski, Blake Hartstein (Bloomberg L.P.) (SigmaHQ), DRL 1.1
Published
2024-09-02
Updated
2026-07-31
title: Linux Inline Python (-c) Calling os.system to Spawn Shell
id: 3e2f10aa-c1a8-462a-88e4-1d01242c6978
status: test
description: This rule flags Linux process creation where the command line includes inline Python execution via "-c" and calls os.system( to execute shell binaries. Attackers commonly use Python's os.system to launch interactive shells (bash, dash, fish, sh, zsh) without dropping a dedicated executable. It relies on process creation telemetry, including the Image path suffix for python/python2/python3 and the command line containing both the Python -c usage and the os.system call with an observed shell path.
references:
  - https://gtfobins.github.io/gtfobins/python/#shell
  - https://github.com/SigmaHQ/sigma/blob/master/rules/linux/process_creation/proc_creation_lnx_python_shell_os_system.yml
author: Li Ling, Andy Parkidomo, Robert Rakowski, Blake Hartstein (Bloomberg L.P.), Huntrule Team
date: 2024-09-02
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: linux
detection:
  selection_img:
    - Image|endswith:
        - /python
        - /python2
        - /python3
    - Image|contains:
        - /python2.
        - /python3.
  selection_cli:
    CommandLine|contains|all:
      - " -c "
      - os.system(
    CommandLine|contains:
      - /bin/bash
      - /bin/dash
      - /bin/fish
      - /bin/sh
      - /bin/zsh
  condition: all of selection_*
falsepositives:
  - Unknown
level: high
license: DRL-1.1
related:
  - id: 2d2f44ff-4611-4778-a8fc-323a0e9850cc
    type: derived