美文网首页
android脱壳-修改dex2oat

android脱壳-修改dex2oat

作者: lastingyang | 来源:发表于2016-10-25 15:58 被阅读0次

    android 6.0.1 dex2oat.cc文件Setup函数中 修改如下

        // Ensure opened dex files are writable for dex-to-dex transformations.
        for (const auto& dex_file : dex_files_) {
          if (!dex_file->EnableWrite()) {
            PLOG(ERROR) << "Failed to make .dex file writeable '" << dex_file->GetLocation() << "'\n";
          }
    ////////////////////////////分割线 以下为添加的代码///////////////////////////////////////////////////////////
          std::string dex_name = dex_file->GetLocation();
          LOG(INFO) << "dex2oat::dex_file name-->" << dex_name;
    
          if (dex_name.find("jiagu") != std::string::npos
            || dex_name.find("cache") != std::string::npos
            || dex_name.find("files") != std::string::npos
            || dex_name.find("tx_shell") != std::string::npos
            || dex_name.find("app_dex") != std::string::npos
            || dex_name.find("nagain") != std::string::npos) {
            int nDexLen = dex_file->Size();
            char pszDexFileName[260] = {0};
            sprintf(pszDexFileName, "%s_%d", dex_name.c_str(), nDexLen);
            int fd = open(pszDexFileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
            if (fd > 0) {
              if (write(fd, (char*)dex_file->Begin(), nDexLen) <= 0) {
                LOG(INFO) << "dex2oat::write dex file failed-->" << pszDexFileName;
              } else {
                LOG(INFO) << "dex2oat::write dex file success-->" << pszDexFileName;
              }
              close(fd);
            } else {
              LOG(INFO) << "dex2oat::open dex file failed-->" << pszDexFileName;
            }
          }
    ////////////////////////////分割线 以上为添加的代码///////////////////////////////////////////////////////////
        }
    

    参考资料:
    http://www.mottoin.com/89035.html
    http://bbs.pediy.com/showthread.php?t=210275

    下面的dex2oat 仅供nexus5(6.0.1)使用

    对应aosp源码版本
    M4B30Z android-6.0.1_r77 Marshmallow Nexus 5
    下载地址:
    链接: https://pan.baidu.com/s/1p6NuuvJ5KUegf5zCGAvRGQ 密码: itf3

    相关文章

      网友评论

          本文标题:android脱壳-修改dex2oat

          本文链接:https://www.haomeiwen.com/subject/zwbruttx.html