Skip to main content

Python Source Code Encryption Tool - A SourceDefender-like solution

Project description

JSDefender - JavaScript Source Code Encryption Tool

JSDefender is a SourceDefender-like tool for protecting JavaScript source code with AES-256-GCM encryption. It provides enterprise-grade protection for your intellectual property without compromising performance.

Features

  • AES-256-GCM Encryption - Industry-standard symmetric encryption
  • License Activation - Online token-based activation system
  • Enforced Expiry (TTL) - Control access with expiration times
  • Custom Password Support - Use custom passwords or auto-generated ones
  • Trial Mode - 24-hour limit without activation
  • Shebang Support - Direct execution of encrypted files
  • Simple CLI - Easy-to-use commands: activate, validate, encrypt
  • Web Dashboard - Manage licenses and tokens through a web interface

Installation

Quick Start (Windows)

Easiest way - does everything automatically:

  1. Double-click setup_and_run.bat

    • Installs all dependencies
    • Sets up the CLI tool
    • Starts the server
  2. Or use START.bat for a quick start (assumes dependencies are installed)

  3. Or use INSTALL.bat to just install dependencies without starting

Quick Start (Linux/Mac)

chmod +x setup_and_run.sh
./setup_and_run.sh

Manual Installation

Install from source (required - not on PyPI yet):

# Navigate to project directory
cd "path/to/sourcedefender remake"

# Install STXDefender
pip install -e .

This installs STXDefender in "editable" mode, making the stxdefender command available globally.

Alternative: Use directly

# Run the Python file directly (no installation needed)
python stxdefender.py --help

Quick Start

1. Start the Backend Server

cd backend
python app.py

The server will start on http://localhost:5000

2. Create an Account

  1. Open your browser and go to http://localhost:5000
  2. Click "Sign up" and create an account
  3. Log in to access the dashboard

3. Generate an Activation Token

  1. In the dashboard, click "Generate New Token"
  2. Copy the token (you'll only see it once!)

4. Activate JSDefender

jsdefender activate --token YOUR_TOKEN_HERE

5. Validate Activation

jsdefender validate

6. Encrypt Your JavaScript Files

# Basic encryption
jsdefender encrypt myapp.js

# With expiration (24 hours)
jsdefender encrypt --ttl=24h myapp.js

# With custom password
jsdefender encrypt --password=mysupersecret myapp.js

# Remove original file after encryption
jsdefender encrypt --remove myapp.js

7. Run Encrypted Files

# Run encrypted file
node myapp.jse

# With custom password (if used during encryption)
export JSDEFENDER_PASSWORD="mysupersecret"
node myapp.jse

# Make executable and run directly (Unix/Linux/Mac)
chmod +x myapp.jse
./myapp.jse

Command Reference

jsdefender activate --token <token>

Activate your license with a token obtained from the dashboard.

jsdefender activate --token 470a7f2e76ac11eb94390242ac130002

jsdefender validate

Validate your current license activation.

jsdefender validate

jsdefender encrypt [options] <file>

Encrypt a JavaScript file.

Options:

  • --remove - Remove the original file after encryption
  • --ttl=<time> - Set expiration time (e.g., 24h, 7d, 30m, 1w)
  • --password=<pass> - Use a custom password (otherwise auto-generated)

Examples:

# Basic encryption
jsdefender encrypt script.js

# With 24-hour expiration and remove original
jsdefender encrypt --remove --ttl=24h myapp.js

# With custom password
jsdefender encrypt --password=mysecret script.js

# Complex example
jsdefender encrypt --remove --ttl=7d --password=supersecret myapp.js

TTL (Time To Live) Format

The --ttl option accepts the following formats:

  • 30s - 30 seconds
  • 5m - 5 minutes
  • 24h - 24 hours
  • 7d - 7 days
  • 2w - 2 weeks
  • 365 - 365 seconds (numeric only = seconds)

Password Handling

Auto-generated Password

If no password is specified, JSDefender generates a secure random password. This password is embedded in the encrypted file, so the file is self-contained.

Custom Password

You can specify a custom password:

jsdefender encrypt --password=mypassword script.js

When running the encrypted file, set the password as an environment variable:

export JSDEFENDER_PASSWORD="mypassword"
node script.jse

If the environment variable is not set, it will use the password embedded in the file (or the one you specified during encryption).

Trial Mode

Without a valid license activation, JSDefender operates in trial mode:

  • ✅ Encryption works normally
  • ⚠️ Maximum TTL is limited to 24 hours
  • ⚠️ A warning message is displayed

To remove trial limitations, activate with a valid token from the dashboard.

Project Structure

.
├── backend/
│   └── app.py              # Flask backend API
├── frontend/
│   ├── index.html          # Landing page
│   ├── login.html          # Login/signup page
│   ├── dashboard.html      # User dashboard
│   └── static/
│       ├── style.css       # Styles
│       ├── auth.js         # Auth page JavaScript
│       ├── dashboard.js    # Dashboard JavaScript
│       └── main.js         # Main page JavaScript
├── jsdefender.py           # Main CLI tool
├── requirements.txt        # Python dependencies
├── setup.py               # Package setup
└── README.md              # This file

Development

Running the Backend

Windows:

  • Use setup_and_run.bat (installs and runs)
  • Use START.bat (quick start)
  • Use run_server.bat (assumes dependencies installed)

Linux/Mac:

./setup_and_run.sh
# OR
cd backend
python3 app.py

The server runs on http://localhost:5000 by default.

Environment Variables

  • JSDEFENDER_API_URL - API endpoint URL (default: http://localhost:5000)
  • SECRET_KEY - Flask secret key (default: auto-generated)
  • JSDEFENDER_PASSWORD - Default password for encrypted files

Database

The backend uses SQLite by default (jsdefender.db). For production, consider using PostgreSQL or MySQL.

Security Notes

  • Passwords are hashed using SHA-256 (consider upgrading to bcrypt for production)
  • Tokens are generated using secure random generation
  • Encryption uses AES-256-GCM with PBKDF2 key derivation (200,000 iterations)
  • License validation happens locally and remotely
  • System fingerprinting is used to bind licenses to machines

License

This project is provided as-is for educational and development purposes.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Support

For issues and questions, please open an issue on the project repository.

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

stxdefender-1.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

stxdefender-1.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file stxdefender-1.0.0.tar.gz.

File metadata

  • Download URL: stxdefender-1.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for stxdefender-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9e52da35b44f7df42501475dfaa9924b3513d6e9ec13a32386b7250d8c097b9e
MD5 bde4824625da404beae6df29afc94b4c
BLAKE2b-256 2f49d62203776a8a318ac87365b8d61de796ee4e058c5d7d2f73f57d8d5374f1

See more details on using hashes here.

File details

Details for the file stxdefender-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: stxdefender-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for stxdefender-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 199e69862f37eab954e2963350ca5208dcac34ce64301a523eabcd67ffea67b8
MD5 b62104cc6b69ec83ccd8fb1f6869625f
BLAKE2b-256 ad1c8f2a3d2e0001e164a99d7bdb8f0bd162365cc1581df5e66583bc79ec57d2

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