看板 ASM 關於我們 聯絡資訊
不是很確定和你要的是不是一樣? 在 memset 之後, f1() 就會被抹除, 無法執行 f1() 此環境在 linux 下執行, 在 stm32 應該會更簡單。 #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <cstring> #include <stdint.h> #include <unistd.h> #include <sys/mman.h> void f1() { printf("xx f1\n"); } void f2() { printf("xx f2\n"); } int main(int argc, char *argv[]) { f1(); f2(); auto len = ((char *)f2-(char *)f1); auto pagesize = getpagesize(); printf("pagesize: %d\n", pagesize); uintptr_t b = (((uintptr_t)f1)+4095 & (~4095)); b = (uintptr_t)f1 - (uintptr_t)f1 % pagesize; printf("f1: %p\n", f1); printf("b: %p\n", b); if (0 == mprotect((void*)b, pagesize, PROT_WRITE|PROT_READ|PROT_EXEC)) { printf("set to write|read|exec\n"); } else { perror("mprotect fail\n"); } memset((void*)f1, 0, len); f2(); f1(); //printf("len: %p\n", len); return 0; } ※ 引述《lazyblack (懶黑)》之銘言: : 用eclipse編譯 stm32 希望增加反編譯難度 請問是否能指定特定位址給函數 以便單次執 : 行後抹除?聽某些人說修改linker檔可達成有前輩知道大概要怎麼做嗎? : 另外也想問算出來的密鑰儲存的記憶體位址,會對反編譯難度造成影響嗎? : 還是說以上作法都是自嗨,無法根本提升破解困難度? : 還望各位給予各種建議或方向,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 113.196.174.254 ※ 文章網址: https://www.ptt.cc/bbs/ASM/M.1521196033.A.2F3.html ※ 編輯: descent (113.196.174.254), 03/16/2018 18:27:36
cs8425: 你的認知錯誤喔 MCU比較麻煩 03/16 19:31
cs8425: MCU的ROM是flash 不能直接memset 03/16 19:31
cs8425: 要call專門的API去抹寫 通常會有page size限制 03/16 19:32
cs8425: 除非函數的code放在RAM 才能用你這招 03/16 19:33
cs8425: 問題是這作法ROM也會有一份code... 03/16 19:33