@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 +392 -0
- package/package.json +53 -0
- package/src/commands/analyze.js +261 -0
- package/src/commands/batch.js +549 -0
- package/src/commands/build.js +134 -0
- package/src/commands/clean.js +159 -0
- package/src/commands/compile.js +285 -0
- package/src/commands/config.js +343 -0
- package/src/commands/decode.js +133 -0
- package/src/commands/decompile.js +444 -0
- package/src/commands/diff.js +334 -0
- package/src/commands/extract.js +410 -0
- package/src/commands/info.js +886 -0
- package/src/commands/install.js +258 -0
- package/src/commands/modify-enhanced.js +1077 -0
- package/src/commands/modify.js +375 -0
- package/src/commands/monitor.js +421 -0
- package/src/commands/plugin.js +239 -0
- package/src/commands/sign.js +169 -0
- package/src/commands/vulnerability-scan.js +404 -0
- package/src/commands/web.js +97 -0
- package/src/index.js +139 -0
- package/src/utils/config.js +492 -0
- package/src/utils/config.json +118 -0
- package/src/utils/icon-manager.js +544 -0
- package/src/utils/manifest-parser.js +506 -0
- package/src/utils/network-analyzer.js +461 -0
- package/src/utils/obfuscation-detector.js +819 -0
- package/src/utils/plugin-system.js +390 -0
- package/src/utils/smali-editor.js +480 -0
- package/src/utils/vulnerability-scanner.js +838 -0
- package/src/web/public/index.html +1017 -0
- package/src/web/web-server.js +587 -0
- package/test_files/test.js +131 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// ────────────[ KAKUZU ]────────────────────────────
|
|
2
|
+
// | Discord : kakuzu_aon
|
|
3
|
+
// | Telegram : kakuzu_aon
|
|
4
|
+
// | Github : kakuzu-aon
|
|
5
|
+
// | File : install.js
|
|
6
|
+
// | License : MIT License © 2026 Kakuzu
|
|
7
|
+
// | Brief : APK install 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 { exec } = require('child_process');
|
|
16
|
+
const util = require('util');
|
|
17
|
+
const execPromise = util.promisify(exec);
|
|
18
|
+
|
|
19
|
+
const installCommand = new Command('install')
|
|
20
|
+
.description('Install APK on connected device')
|
|
21
|
+
.argument('<apk-file>', 'APK file to install')
|
|
22
|
+
.option('-d, --device <id>', 'Target specific device ID')
|
|
23
|
+
.option('-r, --replace', 'Replace existing application')
|
|
24
|
+
.option('--allow-downgrade', 'Allow downgrade of installed app')
|
|
25
|
+
.option('--no-test', 'Skip compatibility test')
|
|
26
|
+
.action(async (apkFile, options) => {
|
|
27
|
+
let spinner;
|
|
28
|
+
try {
|
|
29
|
+
if (!fs.existsSync(apkFile)) {
|
|
30
|
+
console.error(chalk.red(`🔴 Error: APK file not found: ${apkFile}`));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
spinner = ora('📱 Installing APK...').start();
|
|
35
|
+
|
|
36
|
+
await installAPK(apkFile, options);
|
|
37
|
+
|
|
38
|
+
spinner.succeed('APK installed successfully!');
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (spinner) spinner.fail('Installation failed');
|
|
42
|
+
console.error(chalk.red('🔴 Error:'), error.message);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async function installAPK(apkPath, options) {
|
|
48
|
+
const resolvedApkPath = path.resolve(apkPath);
|
|
49
|
+
|
|
50
|
+
// Check ADB availability
|
|
51
|
+
const adbAvailable = await checkADB();
|
|
52
|
+
if (!adbAvailable) {
|
|
53
|
+
throw new Error('ADB (Android Debug Bridge) not found. Please install Android SDK tools.');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Get connected devices
|
|
57
|
+
const devices = await getConnectedDevices();
|
|
58
|
+
if (devices.length === 0) {
|
|
59
|
+
throw new Error('No connected Android devices found. Please connect a device and enable USB debugging.');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Select device
|
|
63
|
+
let targetDevice;
|
|
64
|
+
if (options.device) {
|
|
65
|
+
targetDevice = devices.find(d => d.id === options.device);
|
|
66
|
+
if (!targetDevice) {
|
|
67
|
+
throw new Error(`Device not found: ${options.device}`);
|
|
68
|
+
}
|
|
69
|
+
} else if (devices.length === 1) {
|
|
70
|
+
targetDevice = devices[0];
|
|
71
|
+
} else {
|
|
72
|
+
targetDevice = await selectDevice(devices);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(chalk.blue(`📱 Installing on: ${targetDevice.model} (${targetDevice.id})`));
|
|
76
|
+
|
|
77
|
+
// Test APK compatibility if not disabled
|
|
78
|
+
if (!options.noTest) {
|
|
79
|
+
await testCompatibility(resolvedApkPath, targetDevice.id);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Install APK
|
|
83
|
+
await performInstall(resolvedApkPath, targetDevice.id, options);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function checkADB() {
|
|
87
|
+
try {
|
|
88
|
+
await execPromise('adb version');
|
|
89
|
+
return true;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function getConnectedDevices() {
|
|
96
|
+
try {
|
|
97
|
+
const { stdout } = await execPromise('adb devices -l');
|
|
98
|
+
const lines = stdout.split('\n').slice(1); // Skip header
|
|
99
|
+
|
|
100
|
+
const devices = [];
|
|
101
|
+
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
const trimmed = line.trim();
|
|
104
|
+
if (trimmed && !trimmed.startsWith('*')) {
|
|
105
|
+
const parts = trimmed.split(/\s+/);
|
|
106
|
+
const deviceId = parts[0];
|
|
107
|
+
const status = parts[1];
|
|
108
|
+
|
|
109
|
+
if (status === 'device') {
|
|
110
|
+
// Get device model
|
|
111
|
+
try {
|
|
112
|
+
const { stdout: modelOutput } = await execPromise(`adb -s ${deviceId} shell getprop ro.product.model`);
|
|
113
|
+
const model = modelOutput.trim();
|
|
114
|
+
devices.push({ id: deviceId, model, status });
|
|
115
|
+
} catch (error) {
|
|
116
|
+
devices.push({ id: deviceId, model: 'Unknown', status });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return devices;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw new Error(`Failed to get connected devices: ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function selectDevice(devices) {
|
|
129
|
+
const inquirer = require('inquirer');
|
|
130
|
+
|
|
131
|
+
const { deviceId } = await inquirer.prompt([
|
|
132
|
+
{
|
|
133
|
+
type: 'list',
|
|
134
|
+
name: 'deviceId',
|
|
135
|
+
message: 'Select device to install on:',
|
|
136
|
+
choices: devices.map(d => ({
|
|
137
|
+
name: `${d.model} (${d.id})`,
|
|
138
|
+
value: d.id
|
|
139
|
+
}))
|
|
140
|
+
}
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
return devices.find(d => d.id === deviceId);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function testCompatibility(apkPath, deviceId) {
|
|
147
|
+
console.log(chalk.blue('🔍 Testing compatibility...'));
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
// Get device Android version
|
|
151
|
+
const { stdout: sdkVersion } = await execPromise(`adb -s ${deviceId} shell getprop ro.build.version.sdk`);
|
|
152
|
+
const deviceSDK = parseInt(sdkVersion.trim());
|
|
153
|
+
|
|
154
|
+
// Get device architecture
|
|
155
|
+
const { stdout: abi } = await execPromise(`adb -s ${deviceId} shell getprop ro.product.cpu.abi`);
|
|
156
|
+
const deviceABI = abi.trim();
|
|
157
|
+
|
|
158
|
+
console.log(chalk.gray(` • Device SDK: ${deviceSDK}`));
|
|
159
|
+
console.log(chalk.gray(` • Device ABI: ${deviceABI}`));
|
|
160
|
+
|
|
161
|
+
// Basic APK analysis
|
|
162
|
+
const AdmZip = require('adm-zip');
|
|
163
|
+
const zip = new AdmZip(apkPath);
|
|
164
|
+
const entries = zip.getEntries();
|
|
165
|
+
|
|
166
|
+
// Check for native libraries
|
|
167
|
+
const libEntries = entries.filter(e => e.entryName.startsWith('lib/'));
|
|
168
|
+
const supportedABIs = new Set();
|
|
169
|
+
|
|
170
|
+
libEntries.forEach(entry => {
|
|
171
|
+
const parts = entry.entryName.split('/');
|
|
172
|
+
if (parts.length >= 3) {
|
|
173
|
+
supportedABIs.add(parts[1]);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if (supportedABIs.size > 0 && !supportedABIs.has(deviceABI)) {
|
|
178
|
+
console.log(chalk.yellow(`⚠️ APK supports ${Array.from(supportedABIs).join(', ')} but device is ${deviceABI}`));
|
|
179
|
+
console.log(chalk.yellow(' Installation may fail due to incompatible native libraries'));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log(chalk.green('✅ Compatibility test completed'));
|
|
183
|
+
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.log(chalk.yellow(`⚠️ Could not perform compatibility test: ${error.message}`));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function performInstall(apkPath, deviceId, options) {
|
|
190
|
+
let installCommand = `adb -s ${deviceId} install`;
|
|
191
|
+
|
|
192
|
+
if (options.replace) {
|
|
193
|
+
installCommand += ' -r';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (options.allowDowngrade) {
|
|
197
|
+
installCommand += ' -d';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
installCommand += ` "${apkPath}"`;
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
console.log(chalk.blue('📦 Installing APK...'));
|
|
204
|
+
|
|
205
|
+
const { stdout, stderr } = await execPromise(installCommand);
|
|
206
|
+
|
|
207
|
+
if (stdout.includes('Success')) {
|
|
208
|
+
console.log(chalk.green('✅ APK installed successfully'));
|
|
209
|
+
|
|
210
|
+
// Get package name for additional info
|
|
211
|
+
try {
|
|
212
|
+
const AdmZip = require('adm-zip');
|
|
213
|
+
const zip = new AdmZip(apkPath);
|
|
214
|
+
|
|
215
|
+
// Try to extract package name from manifest
|
|
216
|
+
console.log(chalk.blue('🔍 Getting app info...'));
|
|
217
|
+
|
|
218
|
+
// Launch app if possible
|
|
219
|
+
setTimeout(async () => {
|
|
220
|
+
try {
|
|
221
|
+
// This is a simplified approach - would need manifest parsing for package name
|
|
222
|
+
console.log(chalk.gray('💡 Tip: Use apkz info to get package name for launching'));
|
|
223
|
+
} catch (error) {
|
|
224
|
+
// Ignore launch errors
|
|
225
|
+
}
|
|
226
|
+
}, 2000);
|
|
227
|
+
|
|
228
|
+
} catch (error) {
|
|
229
|
+
// Ignore info extraction errors
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
} else {
|
|
233
|
+
console.log(chalk.yellow('⚠️ Installation completed with warnings:'));
|
|
234
|
+
console.log(chalk.gray(stdout));
|
|
235
|
+
if (stderr) {
|
|
236
|
+
console.log(chalk.gray(stderr));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
} catch (error) {
|
|
241
|
+
// Check for common installation errors
|
|
242
|
+
const errorMessage = error.message;
|
|
243
|
+
|
|
244
|
+
if (errorMessage.includes('INSTALL_FAILED_INSUFFICIENT_STORAGE')) {
|
|
245
|
+
throw new Error('Device storage insufficient. Free up space and try again.');
|
|
246
|
+
} else if (errorMessage.includes('INSTALL_FAILED_ALREADY_EXISTS') && !options.replace) {
|
|
247
|
+
throw new Error('App already installed. Use --replace to update existing installation.');
|
|
248
|
+
} else if (errorMessage.includes('INSTALL_FAILED_VERSION_DOWNGRADE') && !options.allowDowngrade) {
|
|
249
|
+
throw new Error('Trying to install older version. Use --allow-downgrade to force install.');
|
|
250
|
+
} else if (errorMessage.includes('INSTALL_FAILED_NO_MATCHING_ABIS')) {
|
|
251
|
+
throw new Error('Incompatible device architecture. APK native libraries don\'t match device.');
|
|
252
|
+
} else {
|
|
253
|
+
throw new Error(`Installation failed: ${errorMessage}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
module.exports = installCommand;
|