def recompileApk(srcFolder, apkFile, apkTool='apktool2.jar'): """ recompile Apk after decompile apk. """ os.chdir(file_operate.curDir) apkFile = file_operate.getFullPath(apkFile) srcFolder = file_operate.getFullPath(srcFolder) apkTool = file_operate.getToolPath(apkTool) print "apkTool" + apkTool print "java" + file_operate.getJava() if os.path.exists(srcFolder): cmd = '"%s" -jar -Xms512m -Xmx512m "%s" -q b -f "%s" -o "%s"' % ( file_operate.getJava(), apkTool, srcFolder, apkFile) ret = file_operate.execFormatCmd(cmd) if ret: error_operate.error(130) return 1 else: return 0
def smaliTrans2dex(smaliDir, targetFile): smaliDir = file_operate.getFullPath(smaliDir) targetFile = file_operate.getFullPath(targetFile) smaliFile = file_operate.getToolPath('smali.jar') cmd = '"%s" -jar -Xms512m -Xmx512m "%s" "%s" -o "%s"' % ( file_operate.getJava(), smaliFile, smaliDir, targetFile) ret = file_operate.execFormatCmd(cmd) if ret: error_operate.error(50) return 1 else: file_operate.delete_file_folder('file/smali') return 0
def decompileApk(apkFile, targetDir, apkTool='apktool2.jar'): """ Decompile apk """ apkFile = file_operate.getFullPath(apkFile) targetDir = file_operate.getFullPath(targetDir) apkTool = file_operate.getToolPath(apkTool) if os.path.exists(targetDir): file_operate.delete_file_folder(targetDir) if not os.path.exists(targetDir): os.makedirs(targetDir) cmd = '"%s" -jar -Xms512m -Xmx512m "%s" -q d -b -f "%s" -o "%s"' % ( file_operate.getJava(), apkTool, apkFile, targetDir) ret = file_operate.execFormatCmd(cmd) if ret: error_operate.error(80) return 1 else: return 0
def dexTrans2Smali(dexFile, targetDir, step, baksmali='baksmali.jar'): if not os.path.exists(targetDir): os.mkdir(targetDir) if os.path.exists(dexFile): dexFile = file_operate.getFullPath(dexFile) smaliFile = file_operate.getToolPath(baksmali) targetDir = file_operate.getFullPath(targetDir) cmd = '"%s" -jar -Xms512m -Xmx512m "%s" -o "%s" "%s"' % ( file_operate.getJava(), smaliFile, targetDir, dexFile) ret = file_operate.execFormatCmd(cmd) if ret: if step == 3: error_operate.error(30) return 1 elif step == 4: error_operate.error(40) return 1 else: error_operate.error(105) return 1 else: return 0