iT邦幫忙

2025 iThome 鐵人賽

DAY 22
0
Security

逆向系列 第 22

組合語言筆記 - Strip是什麼?

  • 分享至 

  • xImage
  •  

Strip 是什麼?

在學習逆向工程的過程中,有時將 ELF 檔(執行檔),有些丟進 IDA 後只剩下 sub_401000loc_80483F4 這種沒有特殊意義的編號,這就是程式經過了 strip 處理,藉由 strip 我們可以刪除可執行檔中的以下資訊:

  • 符號 (Symbols):函式名稱、變數名稱等
  • 除錯資訊 (Debug Info):對應的原始碼行數、註解資訊等

因此經過 strip 的程式,檔案大小會變小,可讀的資訊也會變少,但依然可以正常執行

Strip 優點

  1. 縮小檔案大小
    在嵌入式系統、IoT 裝置這類空間有限的環境,strip 後能省下幾百 KB ~ 幾 MB

  2. 提升安全性

    • 若未經 strip ,逆向的人丟進 IDA 就能馬上看到例如 checkLicense()verifyPassword() 函式名稱,破解就變得非常簡單。
    • trip 後這些名稱不見了,逆向工程師只能看到自動命名的 sub_xxx,分析難度就會提升
  3. 為發佈版本的標準做法

    • 在發佈 (Release) 時,通常會把符號 Symbols 去掉,只留下最小化、可執行的程式

如何查看程式有沒有被 strip?

在 Linux 中,我們可以用 file 指令來檢查:

file 檔案

例如:

  • 沒被 strip 的程式,最後面會顯示 not stripped
test_program: ELF 64-bit LSB executable, x86-64, dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0,
not stripped
  • 被 strip 過的程式,最後面會顯示 stripped
test_program: ELF 64-bit LSB executable, x86-64, dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0,
stripped

上一篇
逆向題目練習(五) - Endian 轉換
下一篇
組合語言筆記 - Linking
系列文
逆向30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言