Skip to main content

Detect backdoors in Python, JS and PHP code

Project description

🛡️ bac_detect

PyPI version License: MIT Python Versions Build Status

A powerful tool for detecting potential backdoors and vulnerabilities in Python, JavaScript, and PHP source code

🚀 Installation🔍 Features📊 Usage Examples⚙️ Configuration👥 Contributing


📦 Installation

pip install bac_detect

🚀 Quick Start

# Scan a directory or single file
bac_detect path/to/your/code

# Enable extra Python checks via Pylint
bac_detect --use-pylint path/to/your/code

# Show only HIGH severity issues
bac_detect --min-severity high path/to/your/code

🔍 Features

  • Multi-language scanning: Analysis of .py, .js, and .php files
  • Combined approach:
    • Abstract Syntax Tree (AST) analysis using Bandit for Python and Esprima for JavaScript
    • Advanced regex-based scanning
    • Detection of suspicious constructs and potential backdoors
  • Smart classification: All found issues are categorized by severity levels (HIGH, MEDIUM, LOW)
  • Customizability: All detection rules can be configured in the patterns.json file
  • Flexible reporting: Export results to JSON and SARIF formats (coming soon)
  • CI/CD integration: Returns non-zero exit status when issues are detected

📊 Usage Examples

Basic Scanning

# Scan a directory recursively through all subdirectories
bac_detect /path/to/project

# Scan only specific file types
bac_detect --include "*.py,*.js" /path/to/project

# Exclude specific directories
bac_detect --exclude "tests/,vendor/" /path/to/project

Advanced Options

# Output results to JSON
bac_detect --output-format json --output-file results.json /path/to/project

# Set minimum severity level to display
bac_detect --min-severity medium /path/to/project

# Scan using a custom patterns file
bac_detect --patterns custom_patterns.json /path/to/project

Output Example

[HIGH] Potential backdoor found: eval with dynamic content
        File: backend/utils.py, Line: 42
        Code: eval(request.params.get('cmd'))
        
[MEDIUM] Unsafe SQL query handling
        File: backend/models.py, Line: 78
        Code: cursor.execute("SELECT * FROM users WHERE id = " + user_id)
        
[LOW] Deprecated security function usage
        File: backend/auth.py, Line: 156
        Code: md5(password).hexdigest()

⚙️ Configuration

Detection Pattern Setup

All regex rules are located in the file:

bac_detect/patterns.json

You can edit existing or add new patterns:

{
  "python": {
    "high": [
      {
        "pattern": "eval\\s*\\(.*\\)",
        "description": "Dangerous use of eval()"
      },
      {
        "pattern": "os\\.system\\s*\\(.*\\$.*\\)",
        "description": "Shell command execution with external variables"
      }
    ],
    "medium": [
      ...
    ]
  },
  "javascript": {
    ...
  }
}

Configuration File

You can also create a .bac_detectrc configuration file in your project root:

[DEFAULT]
exclude = tests/,docs/,vendor/
include = *.py,*.js,*.php
min-severity = medium
use-pylint = true

👥 Contributing

  1. Fork this repository
  2. Create a feature branch:
    git checkout -b feature/my-new-feature
    
  3. Make your changes and commit:
    git add .
    git commit -m "Add support for XYZ"
    
  4. Push to your fork and open a Pull Request against the main branch

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

📍 Repository

👉 https://github.com/WaiperOK/bac_detect

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bac_detect-1.1.1.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bac_detect-1.1.1-py2.py3-none-any.whl (18.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file bac_detect-1.1.1.tar.gz.

File metadata

  • Download URL: bac_detect-1.1.1.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for bac_detect-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c0c051d64bbe2d4df439c67022821ba136c0824ef4e56976571f2200f84fc09d
MD5 4342d977f1610026f5aa253ded31f646
BLAKE2b-256 6f7fe08623d12614fb16e87f480ffee667aa0a2913bfb4540589e1c92eb28d1d

See more details on using hashes here.

File details

Details for the file bac_detect-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: bac_detect-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for bac_detect-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e3d0432f615479290ad080902c8225b7eb17aefd3ec71e806e6c06cf8953369
MD5 6ce383dfd1280227614cfb567c93a9ed
BLAKE2b-256 d499901392ba4434e60fe9376cf9185606ab53ad6de018cbd8e0afa3cca0e0fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page