def viewapk(apk_path): infoFile = os.path.splitext(apk_path)[0] + '_apkinfo.txt' retcode, msg = star.runcmd2( [PathManager.get_aapt_path(), 'dump', 'badging', apk_path]) if retcode == 0: package = star.find("package: name='(.*?)'", msg) versionCode = star.find("versionCode='(.*?)'", msg) versionName = star.find("versionName='(.*?)'", msg) appName = star.find("application-label:'(.*?)'", msg) activity = star.find("launchable-activity: name='(.*?)'", msg) print(package) print(versionCode) print(versionName) print(appName) print(activity) # APK类型探测 app_type, is_game_app = detectApk(apk_path) if is_game_app: info = '软件名称: {0}\n软件包名: {1}\n软件版本: {2} ( {3} )\n启动Activity: {4}\n该apk为游戏类型app,使用的游戏引擎为: {5}\n'.format( appName, package, versionName, versionCode, activity, ''.join(app_type)) else: info = '软件名称: {0}\n软件包名: {1}\n软件版本: {2} ( {3} )\n启动Activity: {4}\n'.format( appName, package, versionName, versionCode, activity) star.log(info, infoFile) # 打开日志文件 if os.path.exists(infoFile): star.run_cmd_asyn(['notepad', infoFile]) return retcode, msg
def viewsign(f): infoFile = os.path.splitext(f)[0] + '_signinfo.txt' check_v2sign_tool_path = PathManager.get_checkV2_sign_tool_path() code, info = star.runcmd2(['java', '-jar', check_v2sign_tool_path, f]) if code == 0: msg_dic = json.loads(info) if msg_dic['isV1OK']: # 如果使用了v1签名,不管是否使用了v2签名检测v1签名 code, info = star.runcmd2([Constant.KEYTOOL_FILENAME, '-printcert', '-jarfile', f]) if msg_dic['isV2'] and not msg_dic['isV1OK']: # 未使用v1签名,仅仅使用了v2签名 info += u"该apk仅仅使用了v2签名,未使用v1签名,具体信息如上所示" if code == 0: star.log(info, infoFile) if os.path.exists(infoFile): star.run_cmd_asyn(['notepad', infoFile]) return code, info
def viewphone(f): adb = ADBManager() if len(adb.get_devices()) == 0: print(u"该功能需要连接手机或者模拟器,请确保手机或者模拟器已经启动") return 0, None ret, model = adb.shell('getprop ro.product.model') ret, name = adb.shell('getprop ro.product.name') ret, release = adb.shell('getprop ro.build.version.release') ret, sdk = adb.shell('getprop ro.build.version.sdk') ret, cpu = adb.shell('getprop ro.product.cpu.abi') ret, cpu2 = adb.shell('getprop ro.product.cpu.abi2') ret, serialno = adb.shell('getprop ro.serialno') ret, imei = adb.shell('getprop gsm.sim.imei') ret, androidid = adb.shell('getprop net.hostname') ret, description = adb.shell('getprop ro.build.description') ret, mac = adb.shell('cat /sys/class/net/wlan0/address') ret, size = adb.shell('wm size') if ret == 0: size = star.find('size: (.*?)\s', size) infoFile = os.path.splitext(f)[0] + '_phone.txt' star.log('手机类型:' + model, infoFile) star.loga('手机名称:' + name, infoFile) star.loga('系统版本:' + release, infoFile) star.loga('API版本:' + sdk, infoFile) star.loga('CPU:' + cpu, infoFile) star.loga('CPU2:' + cpu2, infoFile) star.loga('MAC:' + mac, infoFile) star.loga('序列号:' + serialno, infoFile) star.loga('IMEI:' + imei, infoFile) star.loga('AndroidId:' + androidid, infoFile) star.loga('描述信息:' + description, infoFile) if size is not None: # 获取分辨率如果失败size将会是None对象,此时不能使用+连接 star.loga('分辨率:' + size, infoFile) if os.path.exists(infoFile): star.run_cmd_asyn(['notepad', infoFile]) return 1, None