關於 Dotfuscator Community & Visual Studio
PreEmptive Protection - Dotfuscator 提供完整的 .NET 應用程式保護,可輕鬆融入您的安全軟體開發生命週期。 使用它來強化、保護和修剪桌面、行動、伺服器和內嵌應用程式,協助保護商業秘密和其他智慧財產權(IP)、減少盜版和偽造,並防止竄改和未經授權的偵錯。 Dotfuscator 可在編譯的元件上運作,而不需要進行更多程序設計,甚至存取原始程式碼。
為什麼保護很重要
請務必 保護您的智慧財產權(IP)。 應用程式的程式代碼包含設計和實作詳細數據,可視為IP。 不過,建置在 .NET Framework 上的應用程式 包含重要的元數據和高階中繼程序代碼,因此只要使用許多免費自動化工具之一,就能輕鬆進行反向工程。 藉由中斷和停止反向工程,您可以防止未經授權的IP洩漏,並證明您的程式代碼包含商業秘密。 Dotfuscator 可以 模糊化 .NET 元件來阻礙反向工程,同時維護原始應用程序行為。
保護應用程式的完整性也很重要。 除了反向工程之外,惡意行為者可能會嘗試盜用您的應用程式、在運行時改變應用程式的行為,或操控數據。 Dotfuscator 可以為您的應用程式添加功能,以偵測並回應未經授權的使用行為,包括程式竄改、第三方偵錯以及已取得 root 權限的裝置。
如需 Dotfuscator 如何融入安全軟體開發生命週期的詳細資訊,請參閱 PreEmptive Solutions 的 SDL 應用程式保護頁面。
關於 Dotfuscator 社群
您的 Microsoft Visual Studio 複本包含一份 PreEmptive Protection - Dotfuscator Community複本,可供個人使用。 (此免費版本先前稱為 Dotfuscator Community Edition 或 Dotfuscator CE。
如需如何安裝 Visual Studio 隨附之 Dotfuscator Community 版本的指示,請參閱 安裝頁面。
Dotfuscator Community 為開發人員、架構設計人員和測試人員提供一系列 軟體保護和強化 服務。 Dotfuscator 社群中包含的 .NET 混淆 和其他 應用程式保護 功能的範例包括:
- 重新命名 標識符,使編譯元件的反向工程變得更困難。
- 反竄改 偵測竄改應用程式的執行,並終止或回應竄改的會話。
- 反偵錯 偵測偵錯工具是否附加到運行中的應用程式,並終止或回應被偵錯的會話。
- 反根裝置,以偵測應用程式是否在已 root 的 Android 裝置上執行,並終止或響應這些裝置上的會話。
- 應用程式到期行為 編碼「生命周期結束」日期,並終止過期的應用程式會話。
如需這些功能的詳細資訊,包括它們如何融入您的應用程式保護策略,請參閱 功能頁面。
Dotfuscator Community 提供即時使用的基本保護。 Dotfuscator Community 的註冊用戶,以及 PreEmptive Protection - Dotfuscator Professional的使用者,全球領先的 .NET Obfuscator,均可以享受更多的應用程式保護措施。 如需增強 Dotfuscator 的詳細資訊,請參閱 升級頁面。
開始
若要從 Visual Studio 開始使用 Dotfuscator Community,請在 搜尋方塊 (Ctrl+Q) 中輸入 dotfuscator
。
- 如果已安裝 Dotfuscator Community,搜尋方塊 會在 [功能表] 標題下顯示啟動 Dotfuscator Community 的選項。 如需詳細資訊,請參閱 完整 Dotfuscator Community 使用者指南的 [快速入門] 頁面。
- 如果尚未安裝 Dotfuscator Community,搜尋方塊 將顯示在 個別元件 標題下的 Install PreEmptive Protection - Dotfuscator。 如需詳細資訊,請參閱 安裝頁面。
您也可以從 preemptive.com 上的 Dotfuscator 下載頁面取得 Dotfuscator Community 最新版本。
從 Dotfuscator Community 5 升級
瞭解如何升級至 PreEmptive Protection - Dotfuscator Community 6。
視您的安裝歷程記錄和 Visual Studio 版本而定,您可能目前執行舊版 Dotfuscator Community 5。 如果是,您應該升級,因為請務必確保程式代碼 最新的保護措施。 免費提供升級。
本文說明如何判斷您目前擁有的版本、如何在必要時升級至第 6 版,以及兩個版本之間已取代或移除哪些功能。
判斷 Dotfuscator 版本
如果您不確定您正在執行的 Dotfuscator 版本,您可以執行下列其中一個選項來判斷版本:
啟動 Dotfuscator Community 圖形使用者介面 (GUI),請移至 Visual Studio 的 [工具] 功能表,然後選取 [PreEmptive Protection - Dotfuscator Community]。
從 Dotfuscator GUI 中,開啟 [Help] 功能表,然後選取 [關於...] 以顯示 [關於] 畫面。
此畫面會列出 Dotfuscator 的版本。
如果您已將 Dotfuscator 與 命令列介面整合至建置,您也可以檢查建置日誌中是否有類似下列範例的行:
Dotfuscator Community Version 5.42.0.9514-e0e25f754
您可能需要增加組建的詳細資訊,才能看到此文字。 針對 Visual Studio,請參閱 詳細級別設定。
版本的第一個整數,在第一個點 .
之前,表示 Dotfuscator 的主要版本。 如果第一個整數是 5
,則您應該在此頁面上執行升級步驟,以便利用最新的 Dotfuscator 6 功能和保護更新。
升級指示
本節包含將 Dotfuscator Community 一般使用方式從第 5 版升級至第 6 版的指示集。
安裝 Dotfuscator 6
Dotfuscator Community 作為 Visual Studio 的延伸模組發行。 安裝 Dotfuscator 6 的指示會因您擁有的 Visual Studio 版本而異:
Visual Studio 2022 Dotfuscator Community 6 包含在 Visual Studio 2022 中。
Visual Studio 2019 Dotfuscator Community 6 已包含在更新版本的 Visual Studio 2019(16.10.0 版及更高版本)中。 將Visual Studio 2019 更新為最新版本。 更新 Visual Studio 會自動將任何 Dotfuscator Community 5 安裝升級至 Dotfuscator Community 6。
如果您尚未安裝 Dotfuscator,請先更新 Visual Studio,然後參閱 安裝。
除了 Visual Studio 的版本之外,您隨時可以從 Dotfuscator 下載頁 獲取最新版本的 Dotfuscator Community。
Visual Studio 2017 這個版本的 Visual Studio 僅隨附於 Dotfuscator Community 5。 不過,您可以移至 Dotfuscator 下載 頁面,然後選取適當的下載連結,以安裝或升級至 Dotfuscator Community 6。
執行下載的
.vsix
檔案,並依照提示將 Dotfuscator Community 6 安裝到 Visual Studio。 現有的 Dotfuscator Community 5 安裝也會升級。早期版本的 Visual Studio 在這些版本的 Visual Studio 中不支援 Dotfuscator Community 6。 建議您升級至較新版本的 Visual Studio,或 從 Dotfuscator Community 升級至 Dotfuscator Professional。
如果您先前已 註冊 Dotfuscator Community 5,這項註冊會在您第一次執行 Dotfuscator Community 6 時自動轉換。
更新 CLI 的路徑
如果您先前使用 Dotfuscator 5 的 命令行介面 (CLI) 來保護您的應用程式,則必須在任何專案中更新 CLI 的路徑,並建置參考它的腳本。
Dotfuscator CLI 路徑現在可能無效的原因,是因為 Dotfuscator Community 安裝的一些可執行檔名稱已在 Dotfuscator 6 中變更。 這項變更可讓這些可執行檔名稱在 Dotfuscator Community 和 Dotfuscator Professional 中相同。
可執行檔案... | Dotfuscator 5 | Dotfuscator 6 |
---|---|---|
GUI | dotfuscator.exe |
dotfuscatorUI.exe |
CLI | dotfuscatorCLI.exe |
dotfuscator.exe |
注意
如果您在主要版本的 Visual Studio 之間升級或切換 Visual Studio 版本,因為 Dotfuscator CLI 安裝在 Visual Studio 的安裝目錄下,CLI 路徑也可能無效。 下列徵兆和解決方案也適用於此案例。
如果您的組建使用無效的 Dotfuscator CLI 路徑,您可能會收到錯誤,例如下列其中一個範例:
'"[...]\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe"' is not recognized as an internal or external command, operable program or batch file.
The command ""[...]\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe" Dotfuscator.xml" exited with code 9009.
若要更新組建以使用正確的 CLI 路徑:
要啟動 Dotfuscator Community GUI,請移至 Visual Studio 的 [Tools] 功能表,然後選取 [PreEmptive Protection - Dotfuscator Community]。
在 Dotfuscator Community GUI 中,移至 [工具] 功能表,然後選取 [Dotfuscator 命令提示字元]。
開啟的指令提示字元中,輸入
where dotfuscator.exe
。 複製顯示至純文本檔的第一個路徑,以供稍後參考。 此路徑是 Dotfuscator Community 6 CLI 的新路徑。視您的建置系統情況開啟專案或建置組態。
- 針對 Visual Studio 專案,請以純文字形式開啟項目檔 (
.csproj
、.vbproj
或.fsproj
)。 在 Visual Studio 中開啟項目檔。
- 針對 Visual Studio 專案,請以純文字形式開啟項目檔 (
找出專案或建置組態中任何使用 Dotfuscator Community 5 CLI 舊路徑的位置。 它通常是以
dotfuscatorCLI.exe
結尾的路徑。以您在步驟 3 中指出的新路徑取代步驟 5 中的舊路徑。
如果其中一個舊路徑不是絕對路徑,則您應該根據內容適當地調整新路徑。 在下列範例中,
VSInstallDir
環境變數用於舊路徑中,因此對應的新路徑應該執行相同的動作。- 步驟 3 的新路徑:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscator.exe
- 項目檔中的舊路徑:
%VSInstallDir%\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe
- 項目檔中的新路徑:
%VSInstallDir%\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscator.exe
- 步驟 3 的新路徑:
如果您使用原始檔控制系統,例如 Git,請確定步驟 6 中的變更會反映在該系統中。 請根據您的系統和組織的需求,將這些變更分發給團隊的其他成員。
警告
由於 dotfuscator.exe
參照 Dotfuscator 5 中的圖形使用者介面 (GUI),但參考 Dotfuscator 6 中的命令行介面 (CLI),因此在更新跨多部計算機共用的組建腳本時請小心。
已安裝 Dotfuscator 5 的電腦,執行 Dotfuscator 6 更新的腳本會導致腳本啟動圖形使用者介面,而不是預期的命令行介面。 這可能會導致組建成功,儘管未套用 Dotfuscator 的保護,這表示您的輸出套件將不會受到保護。
在其他情況下,可能會導致建置失敗。
若要避免這些案例,請將 Dotfuscator Community 從第 5 版升級至所有機器的第 6 版,並同時建置腳本。
升級 Dotfuscator 組態檔
所有在 Dotfuscator 6 之前建立的 Dotfuscator 配置檔(例如 Dotfuscator.xml
)都需要升級。
如果您嘗試使用舊組態檔執行 Dotfuscator CLI,您會收到類似下列範例的錯誤:
Dotfuscator Engine Initialization error: PreEmptive Analytics, Authenticode signing, and the Introduce Explicit Method Overrides setting are no longer supported. Please open your Dotfuscator config in the Config Editor which automatically upgrades it.
重要
即使您未使用所述的功能,您仍會收到此錯誤,而且需要升級組態檔。
若要升級組態檔:
移至 Visual Studio 的 [工具] 功能表,然後選取 [PreEmptive Protection - Dotfuscator Community,以啟動 Dotfuscator Community (GUI) 的 Dotfuscator Community。
開啟有問題的 Dotfuscator 組態檔 (Ctrl+O)。
下列訊息會顯示在 [建置輸出] 索引標籤:
PreEmptive Analytics, Authenticode signing, and the Introduce Explicit Method Overrides setting are no longer supported. The associated settings have been removed. Please save your upgraded Dotfuscator config.
儲存更新后的 Dotfuscator 配置檔 (Ctrl+S)。
如果您使用原始檔控制系統,例如 Git,請確定 Dotfuscator 配置檔的變更會反映在該系統中。 根據您的系統和組織的需求,適當地將這些變更分發給團隊其他成員。
更新與屬性相關的資料庫參考
Dotfuscator 可讓您透過原始程式碼中 .NET 屬性來設定特定功能。 如果您的專案使用這類屬性,您可能需要更新它們以處理 Dotfuscator 6 中的變更。
模糊化屬性
模糊屬性沒有任何變更。 這些屬性定義在 .NET 的基礎類別庫中,Dotfuscator Community 6 繼續支援這些屬性。
檢查屬性
包含 Check Attributes 的程式庫已變更。 在 Dotfuscator Community 5 中,它會與 Dotfuscator 本身一起以檔案的形式散發。 從 Dotfuscator Community 6 開始,它會改為以公用 NuGet 套件的形式散發。
如果您嘗試建置仍然參考舊位置的 Visual Studio 專案,您可能會收到類似下列範例的錯誤:
The type or namespace name 'PreEmptive' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'TamperCheckAttribute' could not be found (are you missing a using directive or an assembly reference?)
您也可以收到此警告:
Could not resolve this reference. Could not locate the assembly "PreEmptive.Attributes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
若要更新您的專案以使用新位置:
移除項目的
PreEmptive.Attributes.dll
組件參考。將 NuGet 套件參考
PreEmptive.Protection.Checks.Attributes
新增至專案。 套件可在預設的 NuGet 來源上取得,nuget.org。
也會移除每個 Check 屬性的 ExtendedKey
參數。
Dotfuscator Community 5 中會忽略這些參數,但如果您的原始程式碼使用它們,請移除這些使用方式,讓您的專案進行編譯。
儀表屬性
設備屬性用於在 Dotfuscator 5 中配置 PreEmptive Analytics 功能。 不過,Dotfuscator 6 已移除 PreEmptive Analytics;請參閱已移除的功能子區段 PreEmptive Analytics。 因此,儀器屬性也已被移除。
如果您嘗試建置使用檢測屬性的 Visual Studio 專案,您可能會收到與 檢查屬性中所述的相同錯誤和警告類型,不過屬性名稱不同(例如,FeatureAttribute
而不是 TamperCheckAttribute
)。
如果您嘗試在包含檢測屬性使用方式的已建置元件上執行 Dotfuscator,您會收到類似下列範例的錯誤:
The PreEmptive.Attributes.FeatureAttribute attribute (annotating SomeNamespace.SomeType::SomeMethod) is not recognized by this version of Dotfuscator.
若要修正這些問題,請從原始程式碼中移除檢測屬性的所有使用方式。
您也需要移除定義屬性的函式庫的組件參考,PreEmptive.Attributes.dll
。
(如果您也使用此程式庫中定義的檢查屬性,它們已移動。請參閱上述 檢查屬性。)
已移除的功能
Dotfuscator Community 6 引進 Dotfuscator Community 5 的重大變更。 如果您使用 Dotfuscator Community 5,本節說明如何處理可能需要建置修改或影響 Dotfuscator 輸出的變更。
changelog中提供變更的完整清單。
預防性分析
Dotfuscator 6 不支援 PreEmptive Analytics,包括 Check Telemetry。 不過,仍支援 檢查 本身(包括 應用程式通知 和 檢查動作)。
若要使用 Dotfuscator 6,升級組態檔 移除 PreEmptive Analytics 設定。
如果您使用程式代碼內屬性來設定 PreEmptive Analytics,請先從原始程式碼中移除它們, 然後重建您的輸入元件,才能讓 Dotfuscator 6 保護這些元件。
如果您使用檢查遙測來報告檢查偵測到無效狀態時(例如在 偵測到竄改時),您可以將它取代為自定義 應用程式通知,以將事件報告至 Azure Application Insights 或您選擇的其他服務。
不支援的應用程式類型
Dotfuscator 6 不再支援下列應用程式類型:
- Windows Phone
- WinRT (Windows 8 應用程式)
- Silverlight
- Unity (遊戲引擎)
- 通用 Windows 平臺 (UWP)
若要保護其他類型的 UWP 應用程式,升級至 Dotfuscator Professional,並遵循 保護您的應用程式 指示。
不支援的輸入
Dotfuscator Community 不再支援通用 Windows 平臺 (UWP) .appx
套件作為 輸入。 若要保護 UWP app,升級至 Dotfuscator Professional,並遵循 保護您的應用程式 指示。
此外,.xap
套件無法再作為輸入使用,因為不再支援 Silverlight。
引入明確的方法覆寫
已從 Dotfuscator 移除用於引入明確方法覆寫的重新命名選項。 若要使用 Dotfuscator 6,升級組態檔 移除此設定。
完整文件
如需詳細的使用指示,請參閱 preemptive.com的完整 Dotfuscator 社群使用者指南,包括 如何開始使用 Dotfuscator Community 使用者介面。