Discover Python Packages from Running Python Interpreters query (#7857)

* Discover Python Packages from Running Python Interpreters documentation

* add hunting tag

Co-authored-by: Guillaume Ross <guillaume@binaryfactory.ca>

* Removed extra quote

Co-authored-by: Guillaume Ross <guillaume@binaryfactory.ca>
Co-authored-by: Guillaume Ross <guillaume@fleetdm.com>
This commit is contained in:
Nabil Schear
2022-09-20 16:10:25 -04:00
committed by GitHub
co-authored by Guillaume Ross Guillaume Ross
parent 34688f531a
commit cbe2d252df
@@ -931,3 +931,14 @@ spec:
purpose: Informational
tags: network, tls
contributors: nabilschear
---
apiVersion: v1
kind: query
spec:
name: Discover Python Packages from Running Python Interpreters
platforms: Linux, macOS
description: Attempt to discover Python environments (in cwd, path to the python binary, and process command line) from running python interpreters and collect Python packages from those environments.
query: SELECT * FROM python_packages WHERE directory IN (SELECT DISTINCT directory FROM (SELECT SUBSTR(path,0,INSTR(path,'/bin/'))||'/lib' AS directory FROM processes WHERE path LIKE '%/bin/%' AND path LIKE '%python%' UNION SELECT SUBSTR(cmdline,0,INSTR(cmdline,'/bin/'))||'/lib' AS directory FROM processes WHERE cmdline LIKE '%python%' AND cmdline LIKE '%/bin/%' AND path LIKE '%python%' UNION SELECT cwd||'/lib' AS directory FROM processes WHERE path LIKE '%python%'));
purpose: Informational
tags: compliance, hunting
contributors: nabilschear