Suspicious Python Site Hook or PTH File Written to Site-Packages via File Event

PremiumReviewedSigma · Medium · v1
Product
windows
Category
file_event
Author
HuntRule
Published
2026-05-08
Updated
2026-08-28

ATT&CK techniques

Persistence → Priv Esc
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Execution

  5. Defense Evasion

  6. Cred Access

  7. Discovery

  8. Lateral Movement

  9. Collection

  10. C2

  11. Exfiltration

  12. Impact

What it detects

This rule detects the creation of Python site-initialization hooks sitecustomize.py and usercustomize.py or a .pth file inside site-packages, the persistence mechanism used by the malicious Python packages reported by Cisco Talos. These files execute automatically every time the interpreter starts, giving attackers durable code execution. Detecting writes of these hooks reveals stealthy persistence planted through the packaging ecosystem.

Related detections9 linkedT1546 — drag to rearrange
AdminSDHolder Permissions Changed for Persistence (via security)
Suspicious Persistence via Shell Script Dropped in profile.d Directory (via file_event)
Suspicious Command Processor AutoRun Persistence via Registry Set
Suspicious MOTD Or Git Hook Script Creation For Linux Persistence
Windows: Suspicious Outlook VbaProject.OTM Macro File Created
Windows MSSQL: Extended Stored Procedure execution with provider name MSSQLSERVER and message containing 'maggie'
Windows: File Creation of Get-Variable.exe in PowerShell WindowsApps Path
Windows process and registry activity matching SOURGUM persistence/privilege escalation behavior
Windows Persistence: Outlook LoadMacroProviderOnBoot Registry Setting Modification
Suspicious Python Site Hook or PTH File Written to Site-Packages via File Event
Pivot detection · T1546 · 9 related

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.