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
  • 相关阅读:
    不同长度的数据进行位运算
    Linux的sleep()和usleep()的使用和区别
    linux inode已满解决方法
    Debian 系统修改语言设置成英文
    IIS设置问题
    Ajax实现跨域访问的三种方法
    HTML--备忘点
    C#基础---值类型和引用类型
    dapper.net框架使用随笔
    WebService的搭建,部署,简单应用和实体类结合使用
  • 原文地址:https://www.cnblogs.com/phyxis/p/5601182.html
Copyright © 2011-2022 走看看