zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    zookeeper logs is missing zookeeper 日志丢失
    Java Spring IoC 学习(3)
    jsp中include的两种用法
    java多态
    Referenced file contains errors
    类的初始化顺序
    PHP处理session跨域
    Apache中按天分割日志(Windows)
    redis和memcached的区别(总结)
    PHP中的traits简单理解
  • 原文地址:https://www.cnblogs.com/phyxis/p/5601182.html
Copyright © 2011-2022 走看看