A simple yet powerful JavaScript reverse engineering tool for code analysis, deobfuscation, and pattern detection. This tool helps you understand and analyze JavaScript code by extracting functions, variables, strings, detecting obfuscation patterns, and beautifying minified code.
- Code Beautification: Deobfuscate and format minified/obfuscated JavaScript code
- Function Extraction: List all functions with their parameters and metadata
- String Extraction: Extract all unique string literals from code
- Variable Analysis: Identify all variables in the code
- Control Flow Analysis: Analyze code complexity and control structures
- Calculate cyclomatic complexity
- Detect nesting depth
- Identify all control flow structures (if/else, loops, switch, try/catch)
- Get actionable, context-aware recommendations for code improvement, including function names and line numbers for complex or deeply nested code
- Pattern Detection: Detect common obfuscation techniques:
- Hex-encoded strings
- Dynamic code execution (eval/Function)
- String concatenation obfuscation
- Base64 encoding/decoding
- Minification patterns
- Array index obfuscation
- Code Statistics: Get detailed metrics about the code structure
- Full Reports: Generate comprehensive analysis reports
# Clone the repository
git clone https://github.com/Cyber-Suite-CSE/reverse-engineer-tool.git
cd reverse-engineer-tool
# Install dependencies
npm install
# Make CLI executable (on Unix-like systems)
chmod +x cli.js# Analyze code
node cli.js analyze <file>
# Beautify/deobfuscate code
node cli.js beautify <file>
node cli.js beautify <file> -o output.js
# Extract strings
node cli.js strings <file>
# List functions
node cli.js functions <file>
# Detect patterns
node cli.js patterns <file>
# Analyze code complexity
node cli.js complexity <file>
# Generate full report
node cli.js report <file>
# Show help
node cli.js --helpconst ReverseEngineer = require('./index.js');
// Load your code
const code = `
function obfuscated() {
const secret = "hidden";
return eval(secret);
}
`;
// Create analyzer instance
const re = new ReverseEngineer(code);
// Beautify code
const beautified = re.beautify();
console.log(beautified);
// Analyze code
const analysis = re.analyze();
console.log(analysis);
// Get specific information
const functions = re.getFunctions();
const strings = re.getStrings();
const patterns = re.getPatterns();
const stats = re.getStatistics();
const controlFlow = re.getControlFlow();
// Generate full report
const report = re.generateReport();
console.log(report);The examples/ directory contains sample files you can analyze:
# Analyze obfuscated code
node cli.js analyze examples/obfuscated.js
# Beautify minified code
node cli.js beautify examples/minified.js -o examples/minified-clean.js
# Extract strings from code
node cli.js strings examples/simple.js
# Analyze code complexity
node cli.js complexity examples/complex.js
# Generate full report
node cli.js report examples/obfuscated.jsMain class for code analysis.
new ReverseEngineer(code)- Create a new instance with JavaScript code
parse()- Parse code into AST (Abstract Syntax Tree)beautify()- Beautify/deobfuscate code and return formatted stringanalyze()- Perform full analysis and return resultsgetStrings()- Extract all unique string literalsgetFunctions()- Extract all function declarationsgetStatistics()- Get code statistics (lines, functions, variables, etc.)getPatterns()- Detect obfuscation patternsgetControlFlow()- Analyze control flow and cyclomatic complexitygenerateReport()- Generate comprehensive analysis reportgetRecommendations()- Get actionable refactoring suggestions for complex or deeply nested code, including function names and line numbers
Run the test suite:
npm test- Security Analysis: Analyze potentially malicious JavaScript code
- Code Review: Understand minified or obfuscated code
- Malware Analysis: Detect obfuscation patterns in suspicious scripts
- Learning: Study how code obfuscation techniques work
- Development: Debug and understand third-party minified code
Build the Docker image:
docker build -t reverse-engineer-tool .Run the tool using Docker:
# Analyze a file
docker run -v $(pwd)/examples:/workspace reverse-engineer-tool analyze /workspace/obfuscated.js
# Beautify code
docker run -v $(pwd)/examples:/workspace reverse-engineer-tool beautify /workspace/minified.js -o /workspace/minified-clean.js
# Extract strings
docker run -v $(pwd)/examples:/workspace reverse-engineer-tool strings /workspace/simple.js
# Generate report
docker run -v $(pwd)/examples:/workspace reverse-engineer-tool report /workspace/obfuscated.jsThe -v $(pwd):/workspace flag mounts your current directory into the container, allowing the tool to access your files.
- acorn: JavaScript parser for AST generation
- escodegen: Code generator for beautification
- esprima: ECMAScript parsing infrastructure
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Cyber Suite CSE
This tool is designed for legitimate reverse engineering and code analysis purposes. Always ensure you have permission to analyze code that doesn't belong to you.