freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

Obfuscar:一款针对.NET程序的开源代码混淆工具
2024-12-08 16:47:45
所属地 广西

关于Obfuscar

Obfuscar是一款针对.NET程序的开源代码混淆工具,该工具支持使用大量重载将 .NET 程序集中的元数据(包括方法、属性、事件、字段、类型和命名空间的名称)重命名为最小集合,在大多数情况下仅通过签名即可区分。

例如,如果某个类仅包含接受不同参数的方法,则可以将它们全部重命名为“A”。如果向该类添加另一个接受与现有方法相同参数的方法,则可以将其命名为“a”。简而言之,该工具可以让反编译后的代码更加难以理解。

基本上,Obfuscar 会打乱一组程序集中的元数据。它会根据签名和类型信息将所有内容重命名为可用于识别它们的最小名称集。由于这些新名称比旧名称短,因此它还会大幅缩小可执行文件的大小。

功能介绍

1、简单配置:隐藏所有私密内容,同时保持所有公开内容。您可以通过默认设置轻松实现这一点。

2、名称混淆:隐藏您不想公开的类/方法/属性/事件名称。这是不可逆的。

3、字符串压缩:字符串内容可以被压缩,这样终端用户就不容易知道它们。但是,这可以通过某些工具进行逆转。

工具要求

Visual Studio

工具安装

广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

git clone https://github.com/obfuscar/obfuscar.git

然后在Visual Studio中打开Obfuscar.sln并编译即可。

工具使用

工具配置

<Module file="$(InPath)\AssemblyX.exe">

  <!-- skip a namespace -->

  <SkipNamespace name="Company.PublicBits" />

 

  <!-- to skip a namespace recursively, just put * on the end -->

  <SkipNamespace name="Company.PublicBits*" />

 

  <!-- skip field by name -->

  <SkipField type="Full.Namespace.And.TypeName"

    attrib="public" name="Fieldname" />

 

  <!-- skip field by regex -->

  <SkipField type="Full.Namespace.And.TypeName"

    attrib="public" rx="Pub.*" />

 

  <!-- skip type...will still obfuscate its methods -->

  <SkipType name="Full.Namespace.And.TypeName2" />

 

  <!-- skip type...will skip its methods next -->

  <SkipType name="Full.Namespace.And.TypeName3" />

  <!-- skip TypeName3's public methods -->

  <SkipMethod type="Full.Namespace.And.TypeName3"

    attrib="public" rx=".*" />

  <!-- skip TypeName3's protected methods -->

  <SkipMethod type="Full.Namespace.And.TypeName3"

    attrib="family" rx=".*" />

 

  <!-- skip type and its methods -->

  <SkipType name="Full.Namespace.And.TypeName4" skipMethods="true" />

  <!-- skip type and its fields -->

  <SkipType name="Full.Namespace.And.TypeName4" skipFields="true" />

  <!-- skip type and its properties -->

  <SkipType name="Full.Namespace.And.TypeName4" skipProperties="true" />

  <!-- skip type and its events -->

  <SkipType name="Full.Namespace.And.TypeName4" skipEvents="true" />

  <!-- skip attributes can be combined (this will skip the methods and fields) -->

  <SkipType name="Full.Namespace.And.TypeName4" skipMethods="true" skipFields="true" />

  <!-- skip the hiding of strings in this type's methods -->

  <SkipType name="Full.Namespace.And.TypeName4" skipStringHiding="true" />

 

  <!-- skip a property in TypeName5 by name -->

  <SkipProperty type="Full.Namespace.And.TypeName5"

    name="Property2" />

  <!-- skip a property in TypeName5 by regex -->

  <SkipProperty type="Full.Namespace.And.TypeName5"

    attrib="public" rx="Something\d" />

 

  <!-- skip an event in TypeName5 by name -->

  <SkipProperty type="Full.Namespace.And.TypeName5"

    name="Event2" />

  <!-- skip an event in TypeName5 by regex -->

  <SkipProperty type="Full.Namespace.And.TypeName5"

    rx="Any.*" />

 

  <!-- avoid the hiding of strings in TypeName6 on all methods -->

  <SkipStringHiding type="Full.Namespace.And.TypeName6" name="*" />

</Module>

基础使用

基本上,Obfuscar 会打乱一组程序集中的元数据。它会根据签名和类型信息将所有内容重命名为可用于识别它们的最小名称集。由于这些新名称比旧名称短,因此它还会显著缩小可执行文件的大小。

该代码可以通过ILSpy反编译为:

public ExampleUI()

{

        this.InitializeComponent();

        this.displayText.Text = new ClassX("Some Text").get_DisplayText();

}

混淆后,代码可以通过ILSpy反编译为:

public A()

{

        this.A();

        this.a.Text = new A.A("Some Text").A();

}

工具运行演示

许可证协议

本项目的开发与发布遵循MIT开源许可协议。

项目地址

Obfuscar:【GitHub传送门

参考资料

https://www.obfuscar.com/

# 代码审计 # .Net # 代码安全 # 代码混淆
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录