Obfuscar的使用

1、在程序中nuget安装Obfuscar

 2、在工程中新建Obfuscar.xml文件,内容如下

<?xml version='1.0'?>
<Obfuscator>
	<!-- 输入的工作路径,采用如约定的 Windows 下的路径表示法,如以下表示当前工作路径 -->
	<!-- 推荐使用当前工作路径,因为 DLL 的混淆过程,需要找到 DLL 的所有依赖。刚好当前工作路径下,基本都能满足条件 -->
	<Var name="InPath" value="." />
	<!-- 混淆之后的输出路径,如下面代码,设置为当前工作路径下的 Obfuscar 文件夹 -->
	<!-- 混淆完成之后的新 DLL 将会存放在此文件夹里 -->
	<Var name="OutPath" value=".\Obfuscar" />
	<!-- 以下的都是细节的配置,配置如何进行混淆 -->

	<!-- 使用 KeepPublicApi 配置是否保持公开的 API 不进行混淆签名,如公开的类型公开的方法等等,就不进行混淆签名了 -->
	<!-- 语法的写法就是 name 表示某个开关,而 value 表示值 -->
	<!-- 对于大部分的库来说,设置公开的 API 不进行混淆是符合预期的 -->
	<Var name="KeepPublicApi" value="true" />
	<!-- 设置 HidePrivateApi 为 true 表示,对于私有的 API 进行隐藏,隐藏也就是混淆的意思 -->
	<!-- 可以通过后续的配置,设置混淆的方式,例如使用 ABC 字符替换,或者使用不可见的 Unicode 代替 -->
	<Var name="HidePrivateApi" value="true" />
	<!-- 设置 HideStrings 为 true 可以设置是否将使用的字符串进行二次编码 -->
	<!-- 由于进行二次编码,将会稍微伤一点点性能,二次编码需要在运行的时候,调用 Encoding 进行转换为字符串 -->
	<Var name="HideStrings" value="true" />
	<!-- 设置 UseUnicodeNames 为 true 表示使用不可见的 Unicode 字符代替原有的命名,通过此配置,可以让反编译看到的类和命名空间和成员等内容都是不可见的字符 -->
	<Var name="UseUnicodeNames" value="true" />
	<!-- 是否复用命名,设置为 true 的时候,将会复用命名,如在不同的类型里面,对字段进行混淆,那么不同的类型的字段可以是重名的 -->
	<!-- 设置为 false 的时候,全局将不会有重复的命名 -->
	<Var name="ReuseNames" value="true" />
	<!-- 配置是否需要重命名字段,默认配置了 HidePrivateApi 为 true 将都会打开重命名字段,因此这个配置的存在只是用来配置为 false 表示不要重命名字段 -->
	<Var name="RenameFields" value="true" />
	<!-- 是否需要重新生成调试信息,生成 PDB 符号文件 -->
	<Var name="RegenerateDebugInfo" value="false" />

	<Var name="OptimizeMethods" value="true"/>

	<Var name="SuppressIldasm" value="false"/>

	<!-- 需要进行混淆的程序集,可以传入很多个,如传入一排排 -->
	<!-- <Module file="$(InPath)\Lib1.dll" /> -->
	<!-- <Module file="$(InPath)\Lib2.dll" /> -->
	<Module file="$(InPath)\FengHua.Converter2.dll">
		<!--SkipType跳过指定的类 Program是Main所在的类名-->
		<!--
		<SkipType name="Program"  />
		-->
		<!--SkipMethod 跳过指定的方法-->
		<!--
		<SkipMethod type="Program" name="Main"/>-->
	</Module>


	<!-- 程序集的引用加载路径,对于 dotnet 6 应用,特别是 WPF 或 WinForms 项目,是需要特别指定引用加载路径的 -->
	<!-- 这里有一个小的需要敲黑板的知识点,应该让 Microsoft.WindowsDesktop.App 放在 Microsoft.NETCore.App 之前 -->
	<!-- 对于部分项目,如果没有找到如下顺序,将会在混淆过程中,将某些程序集解析为旧版本,从而失败 -->
	<!--<AssemblySearchPath path="C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.1\" />
	<AssemblySearchPath path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.1\" />-->
</Obfuscator>

其中

 3、设置生成事件指令

 

"$(Obfuscar)" Obfuscar.xml

4、最后编译运行即可。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This asset obfuscates your code to make it harder for bad guys to reverse engineer your projects. Specifically designed for Unity, it seamlessly links in with its build process. The top priority of this package is to work straight out of the box with no extra steps required. While other obfuscators can stop a game from working, Beebyte's obfuscator looks for specific Unity related code that must be protected. The contents of your source files are unchanged, the obfuscation targets the compiled assembly. Features: - Supports IL2CPP - Supports Assembly Definition Files (Unity 2017.3+) - Removes Namespaces without any conflicts - Recognises Unity related code that must not be changed - Renames Classes (including MonoBehaviours) - Renames Methods - Renames Parameters - Renames Fields - Renames Properties - Renames Events - String literal obfuscation - Adds fake methods - Easy and extensive customisation using the Unity inspector window - Consistent name translations are possible across multiple builds and developers - Semantically secure cryptographic naming convention for renamed members The asset works for both Unity Free and Unity Pro version 4.2.0 onwards (including Unity 5 & 2017 & 2018). Build targets include Standalone, Android, iOS, WebGL, UWP. Other platforms are not guaranteed or supported but may become supported at a future date. IL2CPP builds are much harder to reverse engineer but strings and member information (class, method names etc) are visible in the global-metadata.dat file. Obfuscation will apply to this file adding further security. Why not complement your security with the Anti-Cheat Toolkit - a great third party asset. For more information about the Obfuscator, please see the FAQ

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值