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 13:10:25 -07:00 committed by GitHub
parent 34688f531a
commit cbe2d252df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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