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:
-
Double-click
setup_and_run.bat- Installs all dependencies
- Sets up the CLI tool
- Starts the server
-
Or use
START.batfor a quick start (assumes dependencies are installed) -
Or use
INSTALL.batto 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
- Open your browser and go to
http://localhost:5000 - Click "Sign up" and create an account
- Log in to access the dashboard
3. Generate an Activation Token
- In the dashboard, click "Generate New Token"
- 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 seconds5m- 5 minutes24h- 24 hours7d- 7 days2w- 2 weeks365- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e52da35b44f7df42501475dfaa9924b3513d6e9ec13a32386b7250d8c097b9e
|
|
| MD5 |
bde4824625da404beae6df29afc94b4c
|
|
| BLAKE2b-256 |
2f49d62203776a8a318ac87365b8d61de796ee4e058c5d7d2f73f57d8d5374f1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
199e69862f37eab954e2963350ca5208dcac34ce64301a523eabcd67ffea67b8
|
|
| MD5 |
b62104cc6b69ec83ccd8fb1f6869625f
|
|
| BLAKE2b-256 |
ad1c8f2a3d2e0001e164a99d7bdb8f0bd162365cc1581df5e66583bc79ec57d2
|