sakum-compiler
v1.0.3
Published
Advanced JavaScript obfuscator combining Google Closure Compiler and JavaScript-Obfuscator with RC4 encryption, Base64 encoding, and batch processing support
Maintainers
Readme
sakum-enc - JavaScript Obfuscator & Compiler
JavaScript obfuscator yang menggabungkan Google Closure Compiler dan JavaScript-Obfuscator untuk minify dan enkripsi kode JavaScript dengan mudah. Sekarang dengan auto-detection untuk React, Next.js, TypeScript, dan JSX!
🚀 Fitur
- ✅ Compile - Minify dengan Google Closure Compiler
- ✅ RC4 Encryption - Enkripsi dengan RC4 + obfuscation
- ✅ Base64 Encoding - Enkripsi dengan Base64
- ✅ Full Mode - Compile + RC4 (hasil terbaik)
- ✅ Light Mode - Obfuscation cepat
- ✅ Batch Processing - Process multiple files sekaligus
- ✅ Watch Mode - Auto-recompile saat file berubah
- ✅ Dry-run - Preview hasil tanpa save
- ✅ Detailed Report - Laporan file size & reduction
- ✅ Config File - Support
.sakumrc.json - ✅ 3 Obfuscation Profiles - Light, Medium, Heavy
- ✅ 🆕 Auto-Detection - Deteksi JSX, TypeScript, React, Next.js otomatis
- ✅ 🆕 Smart Fallback - Otomatis pilih mode yang compatible
- ✅ 🆕 React/Next.js Support - Aman untuk JSX dan TypeScript files
📦 Instalasi
npm install -g sakum-compilerAtau lokal:
npm install --save-dev sakum-compiler
npx sakum-enc <file.js>🎯 Usage
Basic Usage
# Default mode (full)
sakum-enc input.js
# Dengan mode spesifik
sakum-enc input.js --mode rc4
sakum-enc input.js --mode base64
sakum-enc input.js --mode compile
sakum-enc input.js --mode lightDengan Output File
sakum-enc input.js --mode full -o output.js
sakum-enc input.js -m rc4 -o dist/app.jsBatch Processing
# Multiple files
sakum-enc input1.js input2.js input3.js --mode light
# Dengan glob pattern
sakum-enc src/**/*.js --mode fullWatch Mode
# Auto-recompile saat file berubah
sakum-enc app.js --watch --mode full
# Shorthand
sakum-enc app.js -w -m fullDry-run Mode
# Preview hasil tanpa save
sakum-enc input.js --dry-run
sakum-enc input.js --mode full --dry-runCustom Profile
# Light profile - cepat, encryption minimal
sakum-enc input.js --profile light
# Medium profile - balanced
sakum-enc input.js --profile medium
# Heavy profile - maximum protection
sakum-enc input.js --profile heavyTanpa Report
sakum-enc input.js --no-report💻 Command Options
| Option | Shorthand | Deskripsi |
|--------|-----------|-----------|
| --mode <mode> | -m | Mode: compile, rc4, base64, full, light (default: full) |
| --output <file> | -o | Output file path |
| --watch | -w | Watch mode - auto-recompile |
| --dry-run | - | Preview tanpa save |
| --no-report | - | Sembunyikan report |
| --profile <name> | -p | Profile: light, medium, heavy |
| --help | -h | Show help |
| --version | -v | Show version |
📋 Available Modes
1. compile
Minify dengan Google Closure Compiler. Mengurangi ukuran file tanpa enkripsi.
sakum-enc app.js --mode compileHasil: app.min.js
2. rc4
Obfuscate dengan RC4 encryption. Kode akan di-scramble dan di-encrypt dengan RC4.
sakum-enc app.js --mode rc4Hasil: app.rc4.js
3. base64
Obfuscate dengan Base64 encoding. Lebih cepat tapi enkripsi lebih lemah dari RC4.
sakum-enc app.js --mode base64Hasil: app.b64.js
4. full (Default)
Kombinasi compile + RC4. Ukuran minimal + security maksimal - REKOMENDASI.
sakum-enc app.js --mode fullHasil: app.min.rc4.js
Contoh hasil:
- Input: 50 KB
- Output: 8 KB
- Reduction: 84%
5. light
Obfuscation ringan tanpa compile. Paling cepat untuk development.
sakum-enc app.js --mode lightHasil: app.obs.js
🔍 Auto-Detection & Smart Fallback
Sakum-enc otomatis mendeteksi file type Anda dan memilih mode yang paling compatible:
Apa yang Dideteksi?
- 📱 React/JSX - Deteksi file
.jsxdan React imports - 📘 TypeScript - Deteksi
.ts,.tsx, dan TypeScript syntax - ⚡ Next.js - Deteksi Next.js specific imports dan exports
- 🚀 Vanilla JavaScript - Pure
.jsfiles
Contoh Auto-Detection
# React component - automatically safe untuk JSX
sakum-enc components/Button.jsx
# Auto-suggests: rc4 mode (tidak pakai Closure Compiler)
# TypeScript file - automatically safe untuk TS
sakum-enc utils/helpers.ts
# Auto-suggests: rc4 mode (skip compile step)
# Vanilla JavaScript - safe untuk Closure Compiler
sakum-enc utils.js
# Auto-suggests: full mode (compile + RC4)
# Next.js page
sakum-enc pages/api/users.js
# Auto-suggests: rc4 mode (stay safe)Output Log Contoh
📦 Processing: src/components/Button.jsx
Type: React + JSX
⚠️ Mode 'compile' mungkin tidak compatible. Disarankan: 'rc4' (use --force untuk override)
→ Switching to: rc4
Mode: rc4 | Profile: mediumDisable Auto-Detection
# Gunakan mode yang dipilih tanpa auto-suggest
sakum-enc app.jsx --mode compile --no-auto-detect
# Force mode even if not recommended
sakum-enc app.jsx --mode full --force🎨 Obfuscation Profiles
Light Profile
{
"compact": true,
"controlFlowFlattening": false,
"stringArray": false
}- ⚡ Tercepat
- 🔓 Paling mudah di-deobfuscate
- 💾 File size minimal
- Cocok untuk: Development, testing
Medium Profile (Default)
{
"compact": true,
"controlFlowFlattening": true,
"stringArray": true,
"stringArrayEncoding": ["base64"],
"deadCodeInjection": true
}- ⚖️ Balanced
- 🔒 Protection sedang
- 💾 File size normal
- Cocok untuk: Production, medium security
Heavy Profile
{
"compact": true,
"controlFlowFlattening": true,
"stringArray": true,
"stringArrayEncoding": ["rc4"],
"selfDefending": true,
"deadCodeInjection": true,
"unicodeEscapeSequence": true
}- 🔐 Maximum protection
- 🐢 Sedikit lebih lambat
- 💾 File size lebih besar
- Cocok untuk: Sensitive code, high security
📄 Config File (.sakumrc.json)
Buat .sakumrc.json di project root untuk custom default config:
{
"defaultMode": "full",
"profile": "medium",
"autoBuild": false
}Config Options:
defaultMode- Default mode jika tidak spesifik (default: "full")profile- Default profile (default: "medium")autoBuild- Experimental feature
📊 Contoh Penggunaan
Development Setup
# Watch mode dengan light profile (cepat)
sakum-enc src/app.js -w --mode light -p lightProduction Build
# Compile + RC4 dengan heavy profile
sakum-enc src/app.js --mode full -p heavy -o dist/app.min.jsBatch Build
# Build semua files dengan full mode
sakum-enc src/**/*.js --mode fullNPM Scripts
Tambahkan ke package.json:
{
"scripts": {
"build": "sakum-enc src/app.js --mode full -o dist/app.js",
"dev": "sakum-enc src/app.js --watch --mode light",
"prod": "sakum-enc src/app.js --mode full -p heavy -o dist/app.min.js"
}
}Kemudian jalankan:
npm run build
npm run dev
npm run prod⚛️ React & Next.js Support
Sakum-enc sekarang fully compatible dengan React, Next.js, dan TypeScript projects!
React/JSX Files
# Obfuscate React component
sakum-enc src/components/Button.jsx
# Output: src/components/Button.rc4.jsx (safe untuk JSX)
# Watch mode untuk development
sakum-enc src/App.jsx --watch --mode light
# Batch process semua components
sakum-enc src/components/**/*.jsx --mode rc4Hasil: Components tetap functional, tapi code-nya di-obfuscate.
Next.js Pages & API Routes
# API routes
sakum-enc pages/api/users.js --mode rc4
# Page components
sakum-enc pages/dashboard.tsx --mode rc4 --profile medium
# Multiple pages
sakum-enc pages/**/*.{js,jsx,ts,tsx} --mode lightTypeScript Files
# TypeScript compilation + obfuscation
sakum-enc utils/helpers.ts --mode ts-compile
# Or simple obfuscation (recommended)
sakum-enc utils/helpers.ts --mode rc4
# Watch mode untuk development
sakum-enc src/**/*.ts --watch --mode lightFull Next.js Build Script
{
"scripts": {
"build": "next build && sakum-enc .next/static/chunks/**/*.js --mode rc4",
"dev": "next dev",
"obfuscate": "sakum-enc pages/**/*.{js,jsx,ts,tsx} --mode light --watch",
"prod": "next build && sakum-enc pages/**/*.{js,jsx,ts,tsx} --mode rc4 -p heavy"
}
}Create React App (CRA) Setup
# Build dengan CRA
npm run build
# Obfuscate bundle files
sakum-enc build/static/js/**/*.js --mode rc4 -p heavy
# Atau dengan auto-watch
sakum-enc src/**/*.jsx --watch --mode light⚠️ Penting untuk React/Next.js
- Auto-Detection Aktif - Sakum sudah otomatis detect JSX/TS
- Mode Compatibility - Jangan pakai
compilemode untuk JSX files - Safe by Default - Jika type terdeteksi, akan auto-fallback ke safe mode
- Test Setelah Obfuscation - Selalu test aplikasi setelah obfuscation
# Preview tanpa save
sakum-enc src/App.jsx --dry-run
# Force jika yakin
sakum-enc src/App.jsx --mode compile --force🔍 Hasil Contoh
Mode Comparison
Original: 45.2 KB
compile: 11.3 KB (74.9% reduction)
rc4: 24.1 KB (46.6% reduction)
base64: 25.8 KB (42.9% reduction)
full: 13.2 KB (70.8% reduction)
light: 28.5 KB (36.9% reduction)⚠️ Catatan Penting
- Backup original file - Selalu simpan original code
- Test hasil - Pastikan obfuscated code berfungsi dengan baik
- Java required - Pastikan Java ter-install untuk mode
compile - Performance - Heavy obfuscation sedikit menambah startup time
- Deobfuscation - Tidak ada enkripsi yang 100% aman, hanya membuat reverse engineering lebih sulit
🐛 Troubleshooting
Error: "java: command not found"
# Install Java
# Ubuntu/Debian
sudo apt-get install openjdk-11-jre
# macOS
brew install java
# Windows
# Download dari: https://www.java.com/Error: "compiler.jar tidak ditemukan"
Pastikan lib/compiler.jar ada di folder package. Download dari:
wget https://github.com/SakumDisiniPa/SakumDisiniPa/raw/main/compiler/compiler.jar -O lib/compiler.jarFile tidak berubah
Pastikan file path benar:
sakum-enc ./src/app.js # Gunakan path relative
sakum-enc /home/user/project/src/app.js # Atau absolute pathQ: Error "Unexpected token <" atau syntax error untuk JSX
A: File detectnya JSX tapi masih di-compile dengan Closure Compiler?
# Disable auto-detect dan pakai rc4 mode
sakum-enc App.jsx --mode rc4 --no-auto-detect
# Atau gunakan --force untuk auto-detect
sakum-enc App.jsx # Harus auto-suggest rc4 modeQ: React component error setelah obfuscation
A: Obfuscation berhasil tapi React error saat runtime?
# Test dengan dry-run dulu
sakum-enc App.jsx --dry-run
# Atau pakai light profile dulu
sakum-enc App.jsx --mode light -p light
# Cek console untuk error details
npm run dev # atau npm startQ: Next.js getStaticProps error
A: Next.js special functions bisa confuse obfuscator:
# Untuk files tanpa obfuscation, skip saja
sakum-enc pages/api/*.js # Hanya API routes
# pages/index.js akan di-skip otomatis jika detect Next.js
# Atau pakai light profile
sakum-enc pages/*.js --mode light -p lightQ: TypeScript compilation error
A: TS files tidak bisa di-compile dengan Closure Compiler:
# Gunakan ts-compile mode (menggunakan Terser)
sakum-enc utils.ts --mode ts-compile
# Atau pakai rc4 (skip compile)
sakum-enc utils.ts --mode rc4
# Auto-detect akan suggest mode yang tepat
sakum-enc utils.ts # Auto-suggests rc4Q: Obfuscated React file jadi besar
A: Obfuscation menambah code size. Minimalisir dengan compile dulu:
# Untuk vanilla JS:
sakum-enc utils.js --mode full # Compile + obfuscate
# Untuk React components, gunakan light:
sakum-enc App.jsx --mode light -p light
# Atau hanya RC4 tanpa light profile:
sakum-enc App.jsx --mode rc4 -p lightTips: Gunakan --dry-run untuk preview hasil sebelum save! 🚀
📝 License
This project is licensed under the GNU General Public License version 2 (GPLv2). See the LICENSE file for details.
