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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

【Android 逆向】ART 脱壳 ( 修改 /art/runtime/dex_file.cc#OpenCommon 系统源码进行脱壳 )

發布時間:2025/6/17 C# 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Android 逆向】ART 脱壳 ( 修改 /art/runtime/dex_file.cc#OpenCommon 系统源码进行脱壳 ) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 一、要修改的源碼 /art/runtime/dex_file.cc#OpenCommon
  • 二、修改 /art/runtime/dex_file.cc#OpenCommon 函數源碼進行脫殼





一、要修改的源碼 /art/runtime/dex_file.cc#OpenCommon



/art/runtime/dex_file.cc#OpenCommon 方法可以作為脫殼點 , 在該函數中可以獲取 DEX 文件在內存中的 起始地址 和 文件大小 , 直接將該文件保存到本地 SD 卡即可 ;

脫殼的代碼與 【Android 逆向】整體加固脫殼 ( 脫殼點簡介 | 修改系統源碼進行脫殼 ) 博客中的代碼類似 ;


/art/runtime/dex_file.cc#OpenCommon 函數源碼 :

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





二、修改 /art/runtime/dex_file.cc#OpenCommon 函數源碼進行脫殼



/art/runtime/dex_file.cc#OpenCommon 函數中 ,

const uint8_t* base 參數是 dex 文件在內存的首地址 ,

size_t size 參數是 dex 文件在內存中的大小 ;


修改源碼后 , 重新編譯系統 , 在新編譯的系統中 , 運行要脫殼的應用 , 即可將應用脫殼后的 dex 文件 , 輸出到 /sdcard/pid_dexCount_output.dex 路徑中 ;


編譯結束后 , 運行虛擬機 , 或者刷到 Pixel 手機中 , 即可運行該系統 ;


修改后的 /art/runtime/dex_file.cc#OpenCommon 函數源碼 :

/* 記錄當前 dex 文件索引 */ int dexCount = 0;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) {// ---------- ★ 下面是脫殼內容 ----------// 系統啟動后 , 可能會生成很多 dex 文件 , // DEX 文件保存路徑char output[50]={0};// 獲取當前進程 ID , 這是為了區分準備的 int pid = getpid();// 生成文件名稱 , 由于單個 APK 可能有多個 DEX 文件 // 這里將每個 DEX 文件的 進程 ID 和 DEX 文件字節大小 // 放入 DEX 文件名中 , 加以識別sprintf(output, "/sdcard/%d_%d_output.dex", pid, dexCount);// dex 文件索引自增dexCount++;// 以寫的方式 , 打開文件 , 如果沒有就創建該文件int fd = open(output, "wb+");// 文件打開成功 , 則 dump 內存數據到 /sdcard/output.dex 文件中if (fd > 0){// 將 base 地址的內存數據拷貝到 fd 文件中 , 拷貝 size 字節write(fd, base, size);// 關閉文件 close(fd);}// ---------- ★ 上面是脫殼內容 ----------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

總結

以上是生活随笔為你收集整理的【Android 逆向】ART 脱壳 ( 修改 /art/runtime/dex_file.cc#OpenCommon 系统源码进行脱壳 )的全部內容,希望文章能夠幫你解決所遇到的問題。

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