Python Inline Command Execution
Last updated on:
In this page
About the rule
Rule Type
Standard
Rule Description
Detects execution of python using the "-c" flag. This is could be used as a way to launch a reverse shell or execute live python code.
Severity
Trouble
Rule Requirement
Criteria
Action1: actionname = "Process started" AND ((ORIGINALFILENAME = "python.exe" OR PROCESSNAME endswith "python.exe,python3.exe,python2.exe") AND COMMANDLINE contains " -c") AND (PARENTPROCESSNAME notstartswith "C:\Program Files\Python" OR PARENTPROCESSNAME notendswith "\python.exe" OR PARENTPROCESSCOMMANDLINE notcontains "-E -s -m ensurepip -U --default-pip") AND (PARENTPROCESSNAME notendswith "\AppData\Local\Programs\Microsoft VS Code\Code.exe" AND (COMMANDLINE notcontains "" OR COMMANDLINE notcontains "exec(compile(")) select Action1.HOSTNAME,Action1.MESSAGE,Action1.COMMANDLINE,Action1.FILE_NAME,Action1.PROCESSNAME,Action1.USERNAME,Action1.PARENTPROCESSNAME
Detection
Execution Mode
realtime
Log Sources
Windows
Author
Nasreddine Bencherchali (Nextron Systems)


