@kakuzu_aon/apkz 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,392 @@
1
+ # APKZ - Advanced APK Reverse Engineering & Security Analysis Platform
2
+
3
+ <div align="center">
4
+
5
+ ![APKZ Banner](https://via.placeholder.com/800x200/1a1a2e/16213e?text=APKZ+Advanced+APK+Platform)
6
+
7
+ **Professional-grade APK analysis tool for security researchers and developers**
8
+
9
+ [![npm version](https://badge.futy.io/js/apkz.svg)](https://badge.fury.io/js/apkz)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D16.0.0-brightgreen)](https://nodejs.org/)
12
+ [![Security](https://img.shields.io/badge/Security-OWASP%20Top2010-orange.svg)(https://owasp.org/Top10/)
13
+ [![Performance](https://img.shields.io/badge/Performance-Optimized-brightgreen.svg)())
14
+
15
+ Created by [Kakuzu](https://github.com/kakuzu-aon) • Discord: `kakuzu_aon` • Telegram: `kakuzu_aon`
16
+
17
+ </div>
18
+
19
+ ## šŸ† **Why APKZ?**
20
+
21
+ APKZ is a **comprehensive APK analysis platform** that outperforms traditional tools like apktool with modern features, professional security scanning, and beautiful user interfaces. It's designed for security researchers, malware analysts, and professional developers who need powerful APK analysis capabilities.
22
+
23
+ ---
24
+
25
+ ## ļæ½ **Core Features**
26
+
27
+ ### šŸ” **Security Analysis**
28
+ - **OWASP Top 10 Compliance** - Automated vulnerability assessment
29
+ - **CVSS Scoring** - Professional risk evaluation with severity ratings
30
+ - **Vulnerability Database** - Extensive vulnerability patterns and signatures
31
+ - **Security Recommendations** - Actionable security improvement suggestions
32
+ - **Compliance Reporting** - Generate compliance reports for audits
33
+
34
+ ### šŸ”§ **Advanced Modification**
35
+ - **Interactive APK Editor** - Real-time APK modification with preview
36
+ - **String Replacement** - Bulk string replacement in smali files
37
+ - **Permission Management** - Add, remove, or bypass permissions
38
+ - **Package Refactoring** - Change package names with automatic updates
39
+ - **Icon Replacement** - Replace app icons with automatic size generation
40
+ - **Manifest Editing** - Direct AndroidManifest.xml modification
41
+
42
+ ### 🌐 **Modern Interfaces**
43
+ - **Web Dashboard** - Beautiful web interface with real-time updates
44
+ - **Batch Processing** - Process hundreds of APKs simultaneously
45
+ - **Real-time Monitoring** - Watch directories for automatic analysis
46
+ - **RESTful API** - Complete API for integration with other tools
47
+ - **WebSocket Updates** - Real-time progress tracking and notifications
48
+
49
+ ### šŸ“Š **Deep Analysis**
50
+ - **Obfuscation Detection** - Analyze code protection and anti-tampering
51
+ - **Network Analysis** - Extract URLs, endpoints, and API keys
52
+ - **Resource Analysis** - Comprehensive resource file analysis
53
+ - **Signature Extraction** - Extract code signatures and metadata
54
+ - **String Analysis** - Categorized string extraction and analysis
55
+
56
+ ---
57
+
58
+ ## šŸ“¦ **Installation**
59
+
60
+ ### Global Installation
61
+ ```bash
62
+ npm install -g apkz
63
+ ```
64
+
65
+ ### Local Development
66
+ ```bash
67
+ git clone https://github.com/kakuzu-aon/apkz
68
+ cd apkz
69
+ npm install
70
+ npm link
71
+ ```
72
+
73
+ ### Requirements
74
+ - **Node.js** 16.0.0 or higher
75
+ - **Java** 8+ (for some operations)
76
+ - **ADB** (for device installation)
77
+ - **7-Zip** (for archive operations)
78
+
79
+ ---
80
+
81
+ ## šŸŽÆ **Quick Start**
82
+
83
+ ### Basic APK Analysis
84
+ ```bash
85
+ # Show comprehensive APK information
86
+ apkz info app.apk
87
+
88
+ # Deep analysis with security scanning
89
+ apkz analyze app.apk --deep --vulnerability
90
+
91
+ # Extract APK with advanced features
92
+ apkz extract app.apk --analyze --vulnerability --network --strings
93
+ ```
94
+
95
+ ### Security Assessment
96
+ ```bash
97
+ # Comprehensive vulnerability scan
98
+ apkz vuln-scan app.apk --obfuscation --severity medium
99
+
100
+ # Generate security report
101
+ apkz vuln-scan app.apk --format html -o security_report.html
102
+
103
+ # Batch security assessment
104
+ apkz batch ./apk_files --vulnerability --obfuscation --parallel 8
105
+ ```
106
+
107
+ ### APK Modification
108
+ ```bash
109
+ # Interactive modification mode
110
+ apkz modify-enhanced app.apk
111
+
112
+ # Quick string replacement
113
+ apkz modify-enhanced app.apk --decode-dir ./decoded
114
+
115
+ # Advanced modification with analysis
116
+ apkz modify-enhanced app.apk --decode-dir ./decoded --analyze
117
+ ```
118
+
119
+ ### Advanced Operations
120
+ ```bash
121
+ # Advanced decompilation
122
+ apkz decompile app.apk --level advanced --deobfuscate --analyze-strings
123
+
124
+ # Real-time monitoring
125
+ apkz monitor ./apk_directory --auto-analyze --vulnerability
126
+
127
+ # Web interface
128
+ apkz web --port 3000
129
+ ```
130
+
131
+ ---
132
+
133
+ ## šŸ“‹ **Command Reference**
134
+
135
+ ### **Core Commands**
136
+ | Command | Description | Options |
137
+ |---------|-------------|---------|
138
+ | `info <apk>` | Show detailed APK information | `--json`, `--summary` |
139
+ | `decode <apk>` | Decode APK resources | `-o <dir>`, `--resources`, `--dex`, `--native` |
140
+ | `build <dir>` | Rebuild APK from decoded directory | `-o <file>`, `--sign` |
141
+ | `analyze <apk>` | Perform deep analysis | `--deep`, `--vulnerability`, `--network` |
142
+ | `modify <apk>` | Interactive modification | `--decode-dir`, `--backup` |
143
+ | `sign <apk>` | Sign APK with keystore | `--keystore`, `--alias`, `--debug` |
144
+ | `install <apk>` | Install on device | `--device`, `--replace` |
145
+ | `diff <apk1> <apk2>` | Compare two APKs | `--format`, `--summary` |
146
+
147
+ ### **Advanced Commands**
148
+ | Command | Description | Options |
149
+ |---------|-------------|---------|
150
+ | `vuln-scan <apk>` | Security vulnerability scan | `--obfuscation`, `--severity`, `--format`, `--deep` |
151
+ | `batch <dir>` | Batch processing | `--vulnerability`, `--parallel`, `--recursive`, `--format` |
152
+ | `web` | Web interface | `--port`, `--host`, `--no-open` |
153
+ | `extract <apk>` | Advanced extraction | `--analyze`, `--vulnerability`, `--network`, `--strings`, `--signatures` |
154
+ | `decompile <apk>` | Advanced decompilation | `--level`, `--deobfuscate`, `--analyze-strings`, `--optimize` |
155
+ | `monitor <dir>` | Real-time monitoring | `--auto-analyze`, `--vulnerability`, `--webhook` |
156
+
157
+ ### **Enhanced Commands**
158
+ | Command | Description | Options |
159
+ |---------|-------------|---------|
160
+ | `modify-enhanced <apk>` | Enhanced modification | `--decode-dir`, `--quick`, `--analyze` |
161
+
162
+ ---
163
+
164
+ ## šŸ” **Security Analysis**
165
+
166
+ ### **Vulnerability Scanning**
167
+ APKZ includes comprehensive vulnerability scanning based on OWASP Top 10 and Mobile Top 10:
168
+
169
+ #### **High Severity**
170
+ - **Hardcoded Secrets** - API keys, passwords, tokens
171
+ - **Weak Cryptography** - Insecure encryption algorithms
172
+ - **Insecure Communication** - HTTP URLs, unencrypted data
173
+ - **SQL Injection** - Vulnerable database queries
174
+ - **Debug Mode** - Debug information in release builds
175
+
176
+ #### **Medium Severity**
177
+ - **Overprivileged Permissions** - Excessive permission requests
178
+ - **Weak Hashing** - MD5, SHA1, outdated algorithms
179
+ - **Hardcoded Endpoints** - API URLs in application code
180
+ - **Insecure Storage** - Unprotected sensitive data
181
+ - **Outdated Libraries** - Libraries with known vulnerabilities
182
+
183
+ #### **Low Severity**
184
+ - **Information Disclosure** - Sensitive data in error messages
185
+ - **Missing Obfuscation** - Code not protected against reverse engineering
186
+ - **Weak Permissions** - Components not properly protected
187
+ - **Logging Issues** - Sensitive data in application logs
188
+
189
+ ### **Risk Assessment**
190
+ - **CVSS Scoring** - Professional severity ratings
191
+ - **Risk Levels** - Critical, High, Medium, Low
192
+ - **Compliance Mapping** - OWASP Top 10 and Mobile Top 10
193
+ - **Recommendations** - Actionable security improvements
194
+
195
+ ---
196
+
197
+ ## šŸ”§ **Modification Capabilities**
198
+
199
+ ### **String Manipulation**
200
+ ```bash
201
+ # Replace specific strings
202
+ apkz modify-enhanced app.apk --decode-dir ./decoded
203
+
204
+ # Batch string replacement
205
+ apkz modify-enhanced app.apk --decode-dir ./decoded --quick
206
+
207
+ # Regex pattern replacement
208
+ apkz modify-enhanced app.apk --decode-dir ./decoded --analyze
209
+ ```
210
+
211
+ ### **Permission Management**
212
+ - **Add Permission Bypasses** - Automatically bypass permission checks
213
+ - **Remove Permission Checks** - Remove security restrictions
214
+ - **Permission Analysis** - Analyze permission usage patterns
215
+
216
+ ### **Package Refactoring**
217
+ - **Package Name Change** - Update all references automatically
218
+ - **Class Name Updates** - Comprehensive refactoring
219
+ - **Resource Updates** - Update resource references
220
+
221
+ ### **Icon Management**
222
+ - **Icon Replacement** - Replace with automatic size generation
223
+ - **Adaptive Icons** - Support for modern adaptive icons
224
+ - **Icon Extraction** - Extract existing app icons
225
+ - **Icon Validation** - Verify icon format and size
226
+
227
+ ---
228
+
229
+ ## 🌐 **Web Interface**
230
+
231
+ ### **Features**
232
+ - **Drag & Drop Upload** - Intuitive file upload interface
233
+ - **Real-time Progress** - Live job progress tracking
234
+ - **Interactive Dashboard** - Beautiful analysis dashboard
235
+ - **Results Download** - Download reports in multiple formats
236
+ - **WebSocket Updates** - Real-time notifications
237
+ - **Job Management** - Track multiple analysis jobs
238
+
239
+ ### **API Endpoints**
240
+ ```bash
241
+ # Upload APK
242
+ POST /api/upload
243
+
244
+ # Start Analysis
245
+ POST /api/analyze
246
+ {
247
+ "filepath": "/path/to/apk",
248
+ "options": {
249
+ "vulnerability": true,
250
+ "obfuscation": true,
251
+ "network": true
252
+ }
253
+ }
254
+
255
+ # Get Results
256
+ GET /api/results/:jobId
257
+
258
+ # List Jobs
259
+ GET /api/jobs
260
+
261
+ # Download Report
262
+ GET /api/download/:jobId/:format
263
+ ```
264
+
265
+ ---
266
+
267
+ ## šŸ“Š **Batch Processing**
268
+
269
+ ### **Batch Analysis**
270
+ ```bash
271
+ # Process entire directory
272
+ apkz batch ./apk_files --vulnerability --obfuscation --parallel 8
273
+
274
+ # Filter specific files
275
+ apkz batch ./apk_files --filter "*.apk" --vulnerability
276
+
277
+ # Generate summary report
278
+ apkz batch ./apk_files --vulnerability --format html
279
+ ```
280
+
281
+ ### **Parallel Processing**
282
+ - **Multi-threaded Analysis** - Process multiple APKs simultaneously
283
+ - **Progress Tracking** - Real-time progress for each job
284
+ - **Resource Management** - Optimized CPU and memory usage
285
+ - **Error Handling** - Robust error handling for batch operations
286
+
287
+ ---
288
+
289
+ ## ļæ½ **Real-time Monitoring**
290
+
291
+ ### **Directory Monitoring**
292
+ ```bash
293
+ # Monitor directory for new APKs
294
+ apkz monitor ./apk_directory --auto-analyze --vulnerability
295
+
296
+ # Recursive monitoring
297
+ apkz monitor ./apk_directory --recursive --auto-analyze
298
+
299
+ # Webhook notifications
300
+ apkz monitor ./apk_directory --webhook https://hooks.slack.com/your-webhook
301
+ ```
302
+
303
+ ### **Event Handling**
304
+ - **File Addition** - Automatic analysis of new APKs
305
+ - **File Modification** - Re-analyze modified APKs
306
+ - **File Removal** - Track deleted files
307
+ - **Progress Updates** - Real-time progress notifications
308
+
309
+ ---
310
+
311
+ ## šŸ“ˆ **Reports & Export**
312
+
313
+ ### **Report Formats**
314
+ - **JSON** - Machine-readable data format
315
+ - **HTML** - Beautiful interactive reports
316
+ - **CSV** - Spreadsheet-compatible format
317
+
318
+ ### **Export Options**
319
+ ```bash
320
+ # Generate HTML security report
321
+ apkz vuln-scan app.apk --format html -o security_report.html
322
+
323
+ # Export vulnerability data
324
+ apkz vuln-scan app.apk --format json -o vuln_data.json
325
+
326
+ # Batch report generation
327
+ apkz batch ./apk_files --format html -o batch_security_report.html
328
+ ```
329
+
330
+ ---
331
+
332
+ ## šŸ”¬ **Obfuscation Analysis**
333
+
334
+ ### **Code Protection Detection**
335
+ - **ProGuard/R8 Detection** - Identify obfuscation tools
336
+ - **String Obfuscation** - Detect encoded/encrypted strings
337
+ - **Control Flow Obfuscation** - Analyze code complexity
338
+ - **Anti-Tampering** - Detect protection mechanisms
339
+
340
+ ### **Analysis Levels**
341
+ - **None** - No obfuscation detected
342
+ - **Light** - Basic obfuscation present
343
+ - **Moderate** - Significant obfuscation
344
+ - **Heavy** - Advanced obfuscation techniques
345
+
346
+ ---
347
+
348
+ ## šŸ› ļø **Development**
349
+
350
+ ### **Project Structure**
351
+ ```
352
+ apkz/
353
+ ā”œā”€ā”€ src/
354
+ │ ā”œā”€ā”€ commands/ # CLI commands
355
+ │ ā”œā”€ā”€ utils/ # Utility classes
356
+ │ └── web/ # Web interface
357
+ ā”œā”€ā”€ test_files/ # Test APKs
358
+ ā”œā”€ā”€ docs/ # Documentation
359
+ └── README.md # This file
360
+ ```
361
+
362
+ ### **Contributing**
363
+ 1. Fork the repository
364
+ 2. Create a feature branch
365
+ 3. Make your changes
366
+ 4. Add tests
367
+ 5. Submit a pull request
368
+
369
+ ### **Building**
370
+ ```bash
371
+ # Install dependencies
372
+ npm install
373
+
374
+ # Run tests
375
+ npm test
376
+
377
+ # Build for production
378
+ npm run build
379
+ ```
380
+
381
+ ---
382
+
383
+ ## šŸ”§ **Configuration**
384
+ <div align="center">
385
+
386
+ **Made with ā¤ļø by Kakuzu**
387
+
388
+ [![GitHub](https://img.shields.io/badge/Github-kakuzu--aon-blue)](https://github.com/kakuzu-aon)
389
+ [![Discord](https://img.shields.io/badge/Discord-kakuzu__aon-7289da)](https://discord.com/users/kakuzu_aon)
390
+ [![Telegram](https://img.shields.io/badge/Telegram-kakuzu__aon-0088cc)](https://t.me/kakuzu_aon)
391
+
392
+ </div>
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@kakuzu_aon/apkz",
3
+ "version": "1.0.0",
4
+ "description": "Modern APK analysis and modification tool with beautiful console output",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "apkz": "src/index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node src/index.js",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "apk",
15
+ "android",
16
+ "reverse-engineering",
17
+ "apktool",
18
+ "decompile",
19
+ "modify",
20
+ "analysis"
21
+ ],
22
+ "author": "Kakuzu <kakuzu_aon>",
23
+ "license": "MIT",
24
+ "type": "commonjs",
25
+ "dependencies": {
26
+ "@xmldom/xmldom": "^0.8.11",
27
+ "adm-zip": "^0.5.10",
28
+ "boxen": "^7.1.1",
29
+ "chalk": "^5.3.0",
30
+ "chokidar": "^5.0.0",
31
+ "cli-progress": "^3.12.0",
32
+ "cli-table3": "^0.6.3",
33
+ "commander": "^11.1.0",
34
+ "commander-completion": "^1.0.1",
35
+ "crypto-js": "^4.2.0",
36
+ "express": "^5.2.1",
37
+ "express-fileupload": "^1.4.3",
38
+ "figlet": "^1.7.0",
39
+ "fs-extra": "^11.2.0",
40
+ "inquirer": "^9.3.8",
41
+ "inquirer-autocomplete-prompt": "^3.0.1",
42
+ "node-fetch": "^3.3.2",
43
+ "node-forge": "^1.3.3",
44
+ "node-stream-zip": "^1.15.0",
45
+ "open": "^11.0.0",
46
+ "ora": "^7.0.1",
47
+ "sharp": "^0.34.5",
48
+ "socket.io": "^4.8.3",
49
+ "xml2js": "^0.6.2",
50
+ "xpath": "^0.0.34",
51
+ "yauzl": "^2.10.0"
52
+ }
53
+ }
@@ -0,0 +1,261 @@
1
+ // ────────────[ KAKUZU ]────────────────────────────
2
+ // | Discord : kakuzu_aon
3
+ // | Telegram : kakuzu_aon
4
+ // | Github : kakuzu-aon
5
+ // | File : analyze.js
6
+ // | License : MIT License Ā© 2026 Kakuzu
7
+ // | Brief : APK deep analysis command implementation
8
+ // ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā˜…ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€
9
+
10
+ const { Command } = require('commander');
11
+ const chalk = require('chalk').default;
12
+ const { default: ora } = require('ora');
13
+ const fs = require('fs-extra');
14
+ const path = require('path');
15
+ const AdmZip = require('adm-zip');
16
+ const Table = require('cli-table3');
17
+
18
+ const analyzeCommand = new Command('analyze')
19
+ .description('Perform comprehensive APK analysis with multiple modules')
20
+ .argument('<apk-file>', 'APK file to analyze')
21
+ .option('-d, --deep', 'Perform deep analysis with advanced techniques')
22
+ .option('-s, --security', 'Focus on security vulnerability analysis')
23
+ .option('--permissions', 'Show detailed permissions analysis and risk assessment')
24
+ .option('--network', 'Analyze network communications and endpoints')
25
+ .option('--native', 'Analyze native libraries and code')
26
+ .option('--resources', 'Analyze resources and assets')
27
+ .option('--components', 'Analyze application components')
28
+ .option('--obfuscation', 'Detect code obfuscation and protection')
29
+ .option('--framework', 'Detect development frameworks and libraries')
30
+ .option('--strings', 'Extract and analyze strings')
31
+ .option('--manifest', 'Deep manifest analysis')
32
+ .option('--certificates', 'Analyze digital certificates')
33
+ .option('--export <file>', 'Export analysis to file')
34
+ .option('--format <format>', 'Export format (json, html, csv)', 'json')
35
+ .option('--parallel <num>', 'Parallel analysis threads', '4')
36
+ .option('--timeout <ms>', 'Analysis timeout in milliseconds', '300000')
37
+ .action(async (apkFile, options) => {
38
+ let spinner;
39
+ try {
40
+ if (!fs.existsSync(apkFile)) {
41
+ console.error(chalk.red(`šŸ”“ Error: APK file not found: ${apkFile}`));
42
+ process.exit(1);
43
+ }
44
+
45
+ spinner = ora('šŸ” Performing deep analysis...').start();
46
+
47
+ const analysis = await performAnalysis(apkFile, options);
48
+
49
+ spinner.succeed('Analysis complete!');
50
+
51
+ displayAnalysis(analysis, options);
52
+
53
+ if (options.output) {
54
+ await fs.writeJson(options.output, analysis, { spaces: 2 });
55
+ console.log(chalk.green(`šŸ’¾ Analysis saved to: ${options.output}`));
56
+ }
57
+
58
+ } catch (error) {
59
+ if (spinner) spinner.fail('Analysis failed');
60
+ console.error(chalk.red('šŸ”“ Error:'), error.message);
61
+ process.exit(1);
62
+ }
63
+ });
64
+
65
+ async function performAnalysis(apkPath, options) {
66
+ const zip = new AdmZip(apkPath);
67
+ const entries = zip.getEntries();
68
+
69
+ const analysis = {
70
+ file: {
71
+ name: path.basename(apkPath),
72
+ path: path.resolve(apkPath),
73
+ size: fs.statSync(apkPath).size,
74
+ created: fs.statSync(apkPath).birthtime,
75
+ modified: fs.statSync(apkPath).mtime
76
+ },
77
+ structure: {
78
+ total_files: entries.length,
79
+ directories: entries.filter(e => e.isDirectory).length,
80
+ files: entries.filter(e => !e.isDirectory).length
81
+ },
82
+ file_types: {},
83
+ security: {
84
+ has_certificates: false,
85
+ certificate_count: 0,
86
+ manifest_signed: false,
87
+ potential_issues: []
88
+ },
89
+ components: {
90
+ activities: [],
91
+ services: [],
92
+ receivers: [],
93
+ providers: []
94
+ },
95
+ permissions: {
96
+ requested: [],
97
+ dangerous: [],
98
+ normal: [],
99
+ signature: []
100
+ }
101
+ };
102
+
103
+ // Analyze file types
104
+ entries.forEach(entry => {
105
+ if (!entry.isDirectory) {
106
+ const ext = path.extname(entry.entryName).toLowerCase() || 'no_extension';
107
+ analysis.file_types[ext] = (analysis.file_types[ext] || 0) + 1;
108
+ }
109
+ });
110
+
111
+ // Security analysis
112
+ const metaInfEntries = entries.filter(e => e.entryName.startsWith('META-INF/'));
113
+ analysis.security.certificate_count = metaInfEntries.filter(e =>
114
+ e.entryName.endsWith('.RSA') || e.entryName.endsWith('.DSA') || e.entryName.endsWith('.SF')
115
+ ).length;
116
+ analysis.security.has_certificates = analysis.security.certificate_count > 0;
117
+
118
+ // Check for potential security issues
119
+ if (analysis.security.certificate_count === 0) {
120
+ analysis.security.potential_issues.push('No digital certificates found');
121
+ }
122
+
123
+ // Look for debug files
124
+ const debugFiles = entries.filter(e =>
125
+ e.entryName.includes('debug') ||
126
+ e.entryName.includes('test') ||
127
+ e.entryName.endsWith('.map')
128
+ );
129
+
130
+ if (debugFiles.length > 0) {
131
+ analysis.security.potential_issues.push(`Found ${debugFiles.length} debug/test files`);
132
+ }
133
+
134
+ // Deep analysis if requested
135
+ if (options.deep) {
136
+ analysis.deep = await performDeepAnalysis(zip, entries);
137
+ }
138
+
139
+ return analysis;
140
+ }
141
+
142
+ async function performDeepAnalysis(zip, entries) {
143
+ const deep = {
144
+ string_analysis: {
145
+ urls: [],
146
+ emails: [],
147
+ api_keys: [],
148
+ file_paths: []
149
+ },
150
+ native_libraries: {
151
+ architectures: [],
152
+ count: 0
153
+ },
154
+ resources: {
155
+ images: 0,
156
+ layouts: 0,
157
+ values: 0,
158
+ drawables: 0
159
+ }
160
+ };
161
+
162
+ // Analyze native libraries
163
+ const libEntries = entries.filter(e => e.entryName.startsWith('lib/') && e.entryName.endsWith('.so'));
164
+ deep.native_libraries.count = libEntries.length;
165
+ deep.native_libraries.architectures = [...new Set(libEntries.map(e =>
166
+ e.entryName.split('/')[1]
167
+ ))];
168
+
169
+ // Analyze resources
170
+ deep.resources.images = entries.filter(e =>
171
+ e.entryName.startsWith('res/') &&
172
+ (e.entryName.endsWith('.png') || e.entryName.endsWith('.jpg') || e.entryName.endsWith('.jpeg'))
173
+ ).length;
174
+
175
+ deep.resources.layouts = entries.filter(e =>
176
+ e.entryName.startsWith('res/layout/') && e.entryName.endsWith('.xml')
177
+ ).length;
178
+
179
+ deep.resources.values = entries.filter(e =>
180
+ e.entryName.startsWith('res/values/') && e.entryName.endsWith('.xml')
181
+ ).length;
182
+
183
+ deep.resources.drawables = entries.filter(e =>
184
+ e.entryName.startsWith('res/drawable') && e.entryName.endsWith('.xml')
185
+ ).length;
186
+
187
+ return deep;
188
+ }
189
+
190
+ function displayAnalysis(analysis, options) {
191
+ // File information box
192
+ const fileInfo = `
193
+ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
194
+ │ šŸ” Deep Analysis: ${chalk.cyan(analysis.file.name.padEnd(20))} │
195
+ ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
196
+ │ šŸ’¾ Size: ${chalk.magenta(formatBytes(analysis.file.size).padEnd(35))} │
197
+ │ šŸ“ Files: ${chalk.blue(analysis.structure.files.toString().padEnd(34))} │
198
+ │ šŸ“‚ Dirs: ${chalk.blue(analysis.structure.directories.toString().padEnd(35))} │
199
+ │ šŸ” Certificates: ${chalk.green(analysis.security.certificate_count.toString().padEnd(27))} │
200
+ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜`;
201
+
202
+ console.log(fileInfo);
203
+
204
+ // File types table
205
+ const fileTypeTable = new Table({
206
+ head: [chalk.gray('Extension'), chalk.gray('Count'), chalk.gray('Percentage')],
207
+ colWidths: [20, 10, 15]
208
+ });
209
+
210
+ const totalFiles = analysis.structure.files;
211
+ Object.entries(analysis.file_types)
212
+ .sort(([,a], [,b]) => b - a)
213
+ .forEach(([ext, count]) => {
214
+ const percentage = ((count / totalFiles) * 100).toFixed(1) + '%';
215
+ fileTypeTable.push([ext, count.toString(), percentage]);
216
+ });
217
+
218
+ console.log(chalk.bold('\nšŸ“Š File Types:'));
219
+ console.log(fileTypeTable.toString());
220
+
221
+ // Security analysis
222
+ console.log(chalk.bold('\nšŸ”’ Security Analysis:'));
223
+ if (analysis.security.has_certificates) {
224
+ console.log(chalk.green(` āœ… Signed with ${analysis.security.certificate_count} certificate(s)`));
225
+ } else {
226
+ console.log(chalk.red(' šŸ”“ Not signed'));
227
+ }
228
+
229
+ if (analysis.security.potential_issues.length > 0) {
230
+ console.log(chalk.yellow('\nāš ļø Potential Issues:'));
231
+ analysis.security.potential_issues.forEach(issue => {
232
+ console.log(chalk.yellow(` • ${issue}`));
233
+ });
234
+ }
235
+
236
+ // Deep analysis
237
+ if (analysis.deep) {
238
+ console.log(chalk.bold('\nšŸ”¬ Deep Analysis:'));
239
+
240
+ if (analysis.deep.native_libraries.count > 0) {
241
+ console.log(chalk.gray(` • Native Libraries: ${analysis.deep.native_libraries.count}`));
242
+ console.log(chalk.gray(` Architectures: ${analysis.deep.native_libraries.architectures.join(', ')}`));
243
+ }
244
+
245
+ console.log(chalk.gray(' • Resources:'));
246
+ console.log(chalk.gray(` - Images: ${analysis.deep.resources.images}`));
247
+ console.log(chalk.gray(` - Layouts: ${analysis.deep.resources.layouts}`));
248
+ console.log(chalk.gray(` - Values: ${analysis.deep.resources.values}`));
249
+ console.log(chalk.gray(` - Drawables: ${analysis.deep.resources.drawables}`));
250
+ }
251
+ }
252
+
253
+ function formatBytes(bytes) {
254
+ if (bytes === 0) return '0 Bytes';
255
+ const k = 1024;
256
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
257
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
258
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
259
+ }
260
+
261
+ module.exports = analyzeCommand;