bananalyzer
Version:
A simple tool for windows 10, that downloads APKs from Google playstore, analyzes them, and lists all the Google and Huawei SDKs (kits) that are integrated, along with other metadata
174 lines (173 loc) • 8.09 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var consts_1 = require("./consts");
/**
* No Copyright 2022 Younes Megaache
* All right can be abused (respectfully)
*
* 💀💀💀 DANGER 💀💀💀
* Reading this code can cause headaches, reduce your IQ level or give you a permanent brain damage
*
*/
//todo: update all packages
('use strict');
var fs_1 = __importDefault(require("fs"));
var consts_2 = require("./consts");
var utils_1 = require("./core/utils");
var cliHelper_1 = __importDefault(require("./cliHelper"));
var cliHelper_2 = require("./cliHelper");
var debug_1 = __importDefault(require("debug"));
var pickFileCommand_1 = require("./commands/pickFileCommand");
var packageCommand_1 = __importDefault(require("./commands/packageCommand"));
var apkCommand_1 = __importDefault(require("./commands/apkCommand"));
var pickFileApk_1 = require("./commands/pickFileApk");
require('is-plain-object');
var debug = (0, debug_1.default)('main');
if ((0, utils_1.currentPlatform)() == 'win32') {
(0, cliHelper_2.commitSuicide)('(ಠ_ಠ) Seriously? 32bit windows machine!? sorry this program is designed for 64 bit machines!');
process.exit(2);
//program will stop here
}
var requiredTools = [consts_2.APP_CHECK_JAR, consts_1.APKTOOL_JAR];
for (var _i = 0, requiredTools_1 = requiredTools; _i < requiredTools_1.length; _i++) {
var tool = requiredTools_1[_i];
if (!fs_1.default.existsSync(tool)) {
(0, cliHelper_2.commitSuicide)("(ಠ_ಠ) some parts of me are missing! I couldn't find " + tool);
process.exit(3);
//program will stop here
}
}
if (!cliHelper_1.default.input ||
typeof cliHelper_1.default.input != typeof [] ||
cliHelper_1.default.input.length < 1 ||
cliHelper_1.default.input.length > 2) {
// cliHelper.showHelp();
console.log('run command `help` for instructions');
}
var cmd = cliHelper_1.default.input[0];
var flags = cliHelper_1.default.flags;
var useExisting = flags.reuse; // if true, will use existing apk in ./download, if false, will force download apks
var keepApks = flags.keep; // if set, the program will not delete the downloaded apks, apks can be found ./downloads folder
var enableLogs = flags.debug; // debug logs
var batchSize = +flags.batch; // download and anlyze X apps at the same time, default value is 3
if (enableLogs) {
debug_1.default.enable('*');
}
else {
debug_1.default.disable();
}
debug('platform: ' + (0, utils_1.currentPlatform)());
debug('IS_PROD=', consts_2.IS_PROD);
debug('SRC_DIR=', consts_2.SRC_DIR);
debug('EXPORT_DIR=', consts_2.EXPORT_DIR);
debug('APP_DATA_FOLDER =', consts_2.APP_DATA_FOLDER);
debug('APP_DATA_FOLDER =', consts_2.DOWNLOAD_FOLDER);
if (consts_2.IS_PROD && !flags.debug) {
// hide all nodejs warnings
process.removeAllListeners('warning');
}
var cli = function () { return __awaiter(void 0, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = cmd;
switch (_a) {
case cliHelper_2.CMD_LIST: return [3 /*break*/, 1];
case cliHelper_2.CMD_APK_LIST: return [3 /*break*/, 3];
case cliHelper_2.CMD_PACKAGE: return [3 /*break*/, 5];
case cliHelper_2.CMD_APK: return [3 /*break*/, 7];
case cliHelper_2.CMD_VERSION: return [3 /*break*/, 9];
}
return [3 /*break*/, 10];
case 1:
//dowlnoad and analyze list of apps
return [4 /*yield*/, new pickFileCommand_1.PickFileCommand(flags).exec()];
case 2:
//dowlnoad and analyze list of apps
_b.sent();
(0, utils_1.pause)();
return [3 /*break*/, 11];
case 3:
//dowlnoad and analyze list of apps
return [4 /*yield*/, new pickFileApk_1.PickFileApkCommand(flags).exec()];
case 4:
//dowlnoad and analyze list of apps
_b.sent();
(0, utils_1.pause)();
return [3 /*break*/, 11];
case 5:
//downlaod ana anlyze package
return [4 /*yield*/, new packageCommand_1.default(flags).exec()];
case 6:
//downlaod ana anlyze package
_b.sent();
(0, utils_1.pause)();
return [3 /*break*/, 11];
case 7:
flags.keep = true;
//analyze apk
return [4 /*yield*/, new apkCommand_1.default(flags).exec()];
case 8:
//analyze apk
_b.sent();
(0, utils_1.pause)();
return [3 /*break*/, 11];
case 9:
{
// console.log('Banalyzer version=', info.version);
cliHelper_1.default.showVersion();
return [3 /*break*/, 11];
}
_b.label = 10;
case 10:
{
//show help
cliHelper_1.default.showHelp();
}
_b.label = 11;
case 11: return [2 /*return*/];
}
});
}); };
debug('DebugLogs =' + enableLogs, ', UseExisting =' + useExisting, ', BatchSize = ' + batchSize, ', KeepAPKs = ' + keepApks);
cli();