Skip to main content

A toolset to identify malware in Python projects.

PyPI - Version PyPI - Implementation PyPI - Python Version PyPI - Status Static Badge Static Badge Static Badge Documentation Status PyPI - License PyPI - Wheel

Overview

The badsnakes project is a CPython library and command line utility which plugs the gap in malware analysis for Python-based malware by employing code and syntax analysis, searching for various patterns and techniques used by threat actors.

After a Python module is analysed, a report can be generated showing the module's 'classification' as OK, SUSPECT or DANGEROUS. If run in verbose mode, each offending statement is displayed to the terminal, along with the reason for the classification. Additionally, all SUSPECT and DANGEROUS statements can be written to a log file for further inspection and analysis.

Note: This tool will flag false-positives, as we feel it's better to fail-safe.

Many lower-level libraries use similar techniques to threat actors by leveraging the inner-workings of the Python language beyond PEP-oriented or production-style code. As such, this is an advisory system designed to highlight statements which may be considered suspect, and worth investigating further. This is not designed to be a GO / NO-GO system.

The Toolset

The current toolset enables malware inspection from the following input sources, either as a library, to be imported and wrapped by your own project(s), or as a command line utility.

  • Directory search
  • Single or multiple Python modules
  • Single or multiple Python wheels

For descriptive usage, please refer to the Using the Library or From the Command Line sections.

Installation

Likely, the easiest way to install badsnakes is using pip after activating your virtual environment::

pip install badsnakes

This will install both the library and the command line utility.

Additional (older) releases can be found either at PyPI in GitHub Releases.

Using the Library

The documentation suite contains detailed explanation and example usage for each of the library's importable modules. For detailed documentation, usage examples and links the source code itself, please refer to the Library API Documentation section of the documentation.

From the Command Line

In addition to being an importable library, badsnakes is also a command line utility, capable of analysing, reporting and logging the following input types:

  • Directories
  • Single or multiple Python modules
  • Single or multiple Python wheels

To call up the help menu, simply type:

$ badsnakes --help

Metadata

Release files for badsnakes 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for badsnakes 0.2.0
File Size Uploaded Provenance Actions
badsnakes-0.2.0.tar.gz 8.5 MB Without provenance Details for badsnakes-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for badsnakes 0.2.0
File Interpreter ABI Platform Actions
badsnakes-0.2.0-py3-none-any.whl Python 3 none any Details for badsnakes-0.2.0-py3-none-any.whl

Total release size: 8.5 MB

Release files / badsnakes-0.2.0.tar.gz

Download URL badsnakes-0.2.0.tar.gz
Size 8.5 MB
Tags Source
SHA-256 checksum
How to use checksums
96262b90de180dee760e7bdbe2e8b32c29a6ed7a2d3fbdb92838adfe4ad476e2
BLAKE2b-256 checksum
How to use checksums
b6813604efc28b07c0e67118194b565ae471b305f5204d0f1914db5e41def68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / badsnakes-0.2.0-py3-none-any.whl

Download URL badsnakes-0.2.0-py3-none-any.whl
Size 54.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
365918925b172d5185a5805ec205001af547105a23a3095825424ccaf62f71d9
BLAKE2b-256 checksum
How to use checksums
3557c3e2a3010c02f0afff8dec314e4ba3a4e932f812d0f8388ebaaef850afd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for badsnakes 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page