andriod 解包
Posted phyxis_xu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了andriod 解包相关的知识,希望对你有一定的参考价值。
使用 baksmali.jar 进行解包
命令 java -jar baksmail.jar -o classout/ classes.dex
public ArrayList<CheckSDK> check(String apkPath, String baksmaliPath, String cachDire) { ArrayList<CheckSDK> result = null; long currenTime = System.currentTimeMillis(); File cachDir = new File(cachDire, currenTime + ""); if (!cachDir.exists()) cachDir.mkdir();
//把文件拷贝到临时目录 List<File> listDex = moveDex(apkPath, cachDir); if (listDex == null) { return null; } for (int i = 0; i < listDex.size(); i++) { File dexFile = listDex.get(i); File newCachDir = new File(cachDir, System.currentTimeMillis()+ "_classout"); String cmdStr = String.format("java -jar %s -o %s %s",baksmaliPath, newCachDir.getAbsolutePath(), dexFile.getAbsolutePath()); String[] instructs = new String[] { cmdStr }; runTime(instructs); ArrayList<CheckSDK> checkResult = checkExits(newCachDir); if (checkResult != null) { if (result == null) result = new ArrayList<CheckSDK>(); for (int x = 0; x < checkResult.size(); x++) { result.add(checkResult.get(x)); } } } SDCatch(cachDir); return result; }
private List<File> moveDex(String apkPath, File cachDir) { List<File> listDexes = new ArrayList<File>(); try { ZipFile zipFile = new ZipFile(apkPath); Enumeration<?> en = zipFile.entries(); while (en.hasMoreElements()) { ZipEntry ze = (ZipEntry) en.nextElement(); if (ze.getName().endsWith(".dex")) { File dexFile = new File(cachDir, System.currentTimeMillis()+ "_class.dex"); if (!dexFile.exists()) dexFile.createNewFile(); BufferedOutputStream output = new BufferedOutputStream( new FileOutputStream(dexFile)); BufferedInputStream input = new BufferedInputStream(zipFile.getInputStream(ze)); byte[] buffer = new byte[1024 * 1024]; int readLen = -1; while ((readLen = input.read(buffer)) != -1) { output.write(buffer, 0, readLen); } output.flush(); output.close(); input.close(); listDexes.add(dexFile); } } } catch (Exception e) { e.printStackTrace(); } return listDexes; }
用 smali.jar 打包
java -jar smali-1.4.1.jar classout/ -o classes.dex
以上是关于andriod 解包的主要内容,如果未能解决你的问题,请参考以下文章
应用程序可能在 Andriod 中的主线程(Firebase 数据库)上做了太多工作