日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 )

發(fā)布時間:2025/6/17 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 ) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 一、ART 虛擬機下 DexClassLoader 類加載器脫殼點總結
    • 1、file_magic.cc#OpenAndReadMagic 函數(shù)
    • 2、dex_file.cc#DexFile::OpenCommon
    • 3、dex_file.cc#DexFile::DexFile
  • 總結 ( 兼容 InMemoryDexClassLoader 和 DexClassLoader 兩種類加載器的 脫殼點 )





一、ART 虛擬機下 DexClassLoader 類加載器脫殼點總結



從 /art/runtime/dex_file.cc#DexFile::Open 函數(shù)開始分析脫殼點位置 ;

其中調用的 /art/runtime/base/file_magic.cc#OpenAndReadMagic 函數(shù) , 可以作為脫殼點 ;

在 /art/runtime/dex_file.cc#OpenFile 函數(shù)中 , 調用了 /art/runtime/dex_file.cc#OpenCommon 函數(shù) , 是脫殼點 ;

bool DexFile::Open(const char* filename,const std::string& location,bool verify_checksum,std::string* error_msg,std::vector<std::unique_ptr<const DexFile>>* dex_files) {ScopedTrace trace(std::string("Open dex file ") + std::string(location));DCHECK(dex_files != nullptr) << "DexFile::Open: out-param is nullptr";uint32_t magic;// ★ 脫殼點后漢書 File fd = OpenAndReadMagic(filename, &magic, error_msg);if (fd.Fd() == -1) {DCHECK(!error_msg->empty());return false;}if (IsZipMagic(magic)) {return DexFile::OpenZip(fd.Release(), location, verify_checksum, error_msg, dex_files);}if (IsDexMagic(magic)) {// ★ 脫殼點函數(shù)std::unique_ptr<const DexFile> dex_file(DexFile::OpenFile(fd.Release(),location,/* verify */ true,verify_checksum,error_msg));if (dex_file.get() != nullptr) {dex_files->push_back(std::move(dex_file));return true;} else {return false;}}*error_msg = StringPrintf("Expected valid zip or dex file: '%s'", filename);return false; }

1、file_magic.cc#OpenAndReadMagic 函數(shù)


file_magic.cc#OpenAndReadMagic 函數(shù)是 脫殼點 , 第一個參數(shù) const char* filename 是 Dex 文件的路徑 ;

調用該函數(shù)的上一個調用位置是 /art/runtime/dex_file.cc#DexFile::Open 函數(shù) ;


file_magic.cc 源碼 :

#include "file_magic.h"#include <fcntl.h> #include <sys/stat.h> #include <sys/types.h>#include "android-base/stringprintf.h"#include "base/logging.h" #include "base/unix_file/fd_file.h" #include "dex_file.h"namespace art {using android::base::StringPrintf;File OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* error_msg) {CHECK(magic != nullptr);File fd(filename, O_RDONLY, /* check_usage */ false);if (fd.Fd() == -1) {*error_msg = StringPrintf("Unable to open '%s' : %s", filename, strerror(errno));return File();}int n = TEMP_FAILURE_RETRY(read(fd.Fd(), magic, sizeof(*magic)));if (n != sizeof(*magic)) {*error_msg = StringPrintf("Failed to find magic in '%s'", filename);return File();}if (lseek(fd.Fd(), 0, SEEK_SET) != 0) {*error_msg = StringPrintf("Failed to seek to beginning of file '%s' : %s", filename,strerror(errno));return File();}return fd; }bool IsZipMagic(uint32_t magic) {return (('P' == ((magic >> 0) & 0xff)) &&('K' == ((magic >> 8) & 0xff))); }bool IsDexMagic(uint32_t magic) {return DexFile::IsMagicValid(reinterpret_cast<const uint8_t*>(&magic)); }} // namespace art

源碼路徑 : /art/runtime/base/file_magic.cc#OpenAndReadMagic


2、dex_file.cc#DexFile::OpenCommon


dex_file.cc#DexFile::OpenCommon 函數(shù)中 , 可以獲取 Dex 文件在內存中的起始地址 ;

注意 : 該脫殼點 與 InMemoryDexClassLoader 類加載器的脫殼點重合 ;


std::unique_ptr<DexFile> DexFile::OpenCommon(const uint8_t* base,size_t size,const std::string& location,uint32_t location_checksum,const OatDexFile* oat_dex_file,bool verify,bool verify_checksum,std::string* error_msg,VerifyResult* verify_result) {if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifyNotAttempted;}std::unique_ptr<DexFile> dex_file(new DexFile(base,size,location,location_checksum,oat_dex_file));if (dex_file == nullptr) {*error_msg = StringPrintf("Failed to open dex file '%s' from memory: %s", location.c_str(),error_msg->c_str());return nullptr;}if (!dex_file->Init(error_msg)) {dex_file.reset();return nullptr;}if (verify && !DexFileVerifier::Verify(dex_file.get(),dex_file->Begin(),dex_file->Size(),location.c_str(),verify_checksum,error_msg)) {if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifyFailed;}return nullptr;}if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifySucceeded;}return dex_file; }

源碼地址 : /art/runtime/dex_file.cc#OpenCommon


3、dex_file.cc#DexFile::DexFile


在 dex_file.cc#DexFile::DexFile 構造函數(shù)中 , 可以獲取到 Dex 文件地址 ;

注意 : 該脫殼點 與 InMemoryDexClassLoader 類加載器的脫殼點重合 ;


DexFile::DexFile(const uint8_t* base,size_t size,const std::string& location,uint32_t location_checksum,const OatDexFile* oat_dex_file): begin_(base),size_(size),location_(location),location_checksum_(location_checksum),header_(reinterpret_cast<const Header*>(base)),string_ids_(reinterpret_cast<const StringId*>(base + header_->string_ids_off_)),type_ids_(reinterpret_cast<const TypeId*>(base + header_->type_ids_off_)),field_ids_(reinterpret_cast<const FieldId*>(base + header_->field_ids_off_)),method_ids_(reinterpret_cast<const MethodId*>(base + header_->method_ids_off_)),proto_ids_(reinterpret_cast<const ProtoId*>(base + header_->proto_ids_off_)),class_defs_(reinterpret_cast<const ClassDef*>(base + header_->class_defs_off_)),method_handles_(nullptr),num_method_handles_(0),call_site_ids_(nullptr),num_call_site_ids_(0),oat_dex_file_(oat_dex_file) {CHECK(begin_ != nullptr) << GetLocation();CHECK_GT(size_, 0U) << GetLocation();// Check base (=header) alignment.// Must be 4-byte aligned to avoid undefined behavior when accessing// any of the sections via a pointer.CHECK_ALIGNED(begin_, alignof(Header));InitializeSectionsFromMapList(); }

源碼地址 : /art/runtime/dex_file.cc#DexFile


總結 ( 兼容 InMemoryDexClassLoader 和 DexClassLoader 兩種類加載器的 脫殼點 )

加固廠商可能使用 InMemoryDexClassLoader 類加載器 , 也可能使用 DexClassLoader 類加載器 , 這里為了保證不管使用什么類加載器 , 都可以進行脫殼 , 選擇 222 個類加載器都有的脫殼點 , 可以兼容兩種類加載器 ;

總結

以上是生活随笔為你收集整理的【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 )的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美性在线观看 | 成人3d动漫一区二区三区 | 在线观看福利视频 | 伊人五月婷婷 | 国产情侣久久久久aⅴ免费 caoporn成人 | 黄色一大片 | av色在线观看 | 少妇被躁爽到高潮无码文 | 一区二区三区av | 少妇2做爰hd韩国电影 | 在线视频国产一区 | 国产精品久久久久久久久久久新郎 | 天天看夜夜看 | 久久精品视频一区二区三区 | 在线天堂1| 亚洲成年人网站在线观看 | 日韩人妻无码精品久久久不卡 | 哪个网站可以看毛片 | 经典一区二区三区 | 成人动漫在线观看 | 我们俩电影网mp4动漫官网 | 亚洲精品中文字幕成人片 | cao在线视频 | 午夜成人亚洲理伦片在线观看 | 成人国产精品入口免费视频 | 午夜av一区 | 色吊丝av中文字幕 | 欧美三级视频在线播放 | 99热免费在线观看 | 日剧网| 欧美a在线 | 国产 欧美 在线 | 天天操夜夜干 | 韩国三级视频 | 四虎影院成人 | 男人操女人的软件 | 七仙女欲春2一级裸体片 | 69性视频 | 国产精品视频在线免费观看 | 老女人网站 | 五月色丁香| 午夜av剧场 | 91久久精品在线 | 992av| 黑人巨大精品欧美一区二区蜜桃 | 一级特黄aa| 精品在线小视频 | 日本性爱视频在线观看 | 成人国产毛片 | 97超碰人人澡 | 天天摸夜夜 | 成人免费播放视频 | 人妖一区二区三区 | 欧美一区二区免费视频 | 国产中文欧美日韩在线 | 少妇太爽了 | 国产欧美123| 四级毛片 | 欧美少妇xxx | 日本免费一区二区三区四区 | 日日夜夜狠狠爱 | 一区二区三区四区免费视频 | 奇米影视欧美 | 一区二区三区四区在线播放 | 亚洲少妇在线 | 日韩一及片 | 手机看片欧美日韩 | 亚洲av无码一区二区三区人 | 99精品视频在线看 | 福利在线国产 | 色视频在线看 | av在线专区 | 欧美涩涩视频 | 国产91啪 | 福利毛片| 伊人22综合 | 日韩专区一区二区三区 | 精品国产av无码一区二区三区 | 精品盗摄一区二区三区 | 狠狠久| 欧美性开放视频 | 91极品视觉盛宴 | 日韩精品在线免费看 | 性欧美丰满熟妇xxxx性仙踪林 | 免费在线色 | 欧美精品18videosex性欧美 | 亚洲av无码潮喷在线观看 | 久久嫩草视频 | 久久av无码精品人妻出轨 | 国产3级在线| 好吊色网站 | 可以免费看av的网站 | 亚洲女则毛耸耸bbw 边吃奶边添下面好爽 | xxxx国产视频 | 男女视频久久 | 国产精品一区二区三区免费 | www.成人网.com | 日韩福利一区 | 91亚洲国产成人精品性色 |