de4dot - Deobfuscator for .NET

Features

Here's a pseudo random list of the things it will do depending on what obfuscator was used to obfuscate an assembly:

  • Inline methods. Some obfuscators move small parts of a method to another static method and calls it.
  • Decrypt strings statically or dynamically
  • Decrypt other constants. Some obfuscators can also encrypt other constants, such as all integers, all doubles, etc.
  • Decrypt methods statically or dynamically
  • Remove proxy methods. Many obfuscators replace most/all call instructions with a call to a delegate. This delegate in turn calls the real method.
  • Rename symbols. Even though most symbols can't be restored, it will rename them to human readable strings. Sometimes, some of the original names can be restored, though.
  • Devirtualize virtualized code
  • Decrypt resources. Many obfuscators have an option to encrypt .NET resources.
  • Decrypt embedded files. Many obfuscators have an option to embed and possibly encrypt/compress other assemblies.
  • Remove tamper detection code
  • Remove anti-debug code
  • Control flow deobfuscation. Many obfuscators modify the IL code so it looks like spaghetti code making it very difficult to understand the code.
  • Restore class fields. Some obfuscators can move fields from one class to some other obfuscator created class.
  • Convert a PE exe to a .NET exe. Some obfuscators wrap a .NET assembly inside a Win32 PE so a .NET decompiler can't read the file.
  • Removes most/all junk classes added by the obfuscator.
  • Fixes some peverify errors. Many of the obfuscators are buggy and create unverifiable code by mistake.
  • Restore the types of method parameters and fields

Supported obfuscators/packers

  • Agile.NET (aka CliSecure)
  • Babel.NET
  • CodeFort
  • CodeVeil
  • CodeWall
  • CryptoObfuscator
  • DeepSea Obfuscator
  • Dotfuscator
  • .NET Reactor
  • Eazfuscator.NET
  • Goliath.NET
  • ILProtector
  • MaxtoCode
  • MPRESS
  • Rummage
  • Skater.NET
  • SmartAssembly
  • Spices.Net
  • Xenocode

Some of the above obfuscators are rarely used (eg. Goliath.NET), so they have had much less testing. Help me out by reporting bugs or problems you find.

Warning

Sometimes the obfuscated assembly and all its dependencies are loaded into memory for execution. Use a safe sandbox environment if you suspect the assembly or assemblies to be malware.

Even if the current version of de4dot doesn't load a certain assembly into memory for execution, a future version might.

How to use de4dot

N00b users

Drag and drop the file(s) onto de4dot.exe and wait a few seconds.

Deobfuscate more than one file at a time

When more than one assembly has been obfuscated, it's very likely that you must deobfuscate them all at the same time unless you disable symbol renaming. The reason is that if assembly A has a reference to class C in assembly B, and you rename symbols only in assembly B, then class C could be renamed to eg. Class0 but the reference in assembly A still references a class called C in assembly B. If you deobfuscate both assemblies at the same time, all references will also be updated.

Find all obfuscated files and deobfuscate them

The following command line will deobfuscate all assemblies that have been obfuscated by a supported obfuscator and save the assemblies to c:\output

de4dot -r c:\input -ru -ro c:\output

-r means recursive search. -ru means it should ignore unknown files. -ro means it should place the output files in the following directory. Typically, you'd first copy c:\input to c:\output, and then run the command. That way all the files will be in c:\output, even non-assemblies and non-processed assemblies. When de4dot is finished, you'd just double click the main assembly in c:\output and it should hopefully start.

Detect obfuscator

Use the -d option to detect the obfuscator without deobfuscating any assembly.

Find all .NET assemblies and detect obfuscator. If it's an unsupported obfuscator or if it's not obfuscated, it will print "Unknown obfuscator".

de4dot -d -r c:\input

Same as above except that it will only show which files have been obfuscated by a supported obfuscator.

de4dot -d -r c:\input -ru

Detect obfuscator

de4dot -d file1.dll file2.dll file3.dll

Preserving metadata tokens

Sometimes in rare cases, you'd want to preserve the metadata tokens. Use --preserve-tokens or --preserve-table. Also consider using --keep-types since it won't remove any types and methods added by the obfuscator. Another useful option is--dont-create-params. If used, the renamer won't create Param rows for method parameters that don't have a Param row. That way the ParamPtr table won't be added to your assemblies. Peverify has a bug and doesn't support it (you'll see lots of "errors").

The #Strings, #US and #Blob heaps can also be preserved by using --preserve-strings--preserve-us, and --preserve-blob respectively. Of these three, --preserve-us is the most useful one since ldstr instruction andmodule.ResolveString() directly reference the #US heap.

--preserve-sig-data should be used if the obfuscator adds extra data at the end of signatures that it uses for its own purpose, eg. as decryption keys. Confuser is one obfuscator that does this.

--preserve-tokens preserves all important tokens but will also enable --preserve-us--preserve-blob and --preserve-sig-data.

If it's detected as an unknown (unsupported) obfuscator (or if you force it with -p un), all tokens are preserved, including the #US heap and any extra data at the end of signatures. Also, no obfuscator types, fields or methods are removed.

Preserve all important tokens, #US, #Blob, extra sig data.

de4dot --preserve-tokens file1.dll

Preserve all important tokens, #US, #Blob, extra sig data and don't remove types/fields added by the obfuscator

de4dot --keep-types --preserve-tokens file1.dll

Preserve all important tokens, #US, #Blob, extra sig data and don't create extra Param rows to prevent the ParamPtr table from being created.

de4dot --dont-create-params --preserve-tokens file1.dll

Preserve all important tokens except the Param tokens.

de4dot --preserve-table all,-pd file1.dll

Dynamically decrypting strings

Although de4dot supports a lot of obfuscators, there's still some it doesn't support. To decrypt strings, you'll first need to figure out which method or methods decrypt strings. To get the method token of these string decrypters, you can use ILDASM with the 'show metadata tokens' option enabled. A method token is a 32-bit number and begins with 06, eg. 06012345.

This command will load assembly file1.dll into memory by calling Assembly.Load(). When it detects calls to the two string decrypters (06012345 and 060ABCDE), it will call them by creating a dynamic method, and save the result (the decrypted string). The call to the string decrypter will be removed and the decrypted string will be in its place.

de4dot file1.dll --strtyp delegate --strtok 06012345 --strtok 060ABCDE

Since the assembly is loaded and executed, make sure you run this in a sandbox if you suspect the file to be malware.

Forcing detection of a certain obfuscator

de4dot isn't perfect. If it fails to detect an obfuscator, you can use the -p option to force it to assume it's been obfuscated by it.

Force SmartAssembly

de4dot file1.dll -p sa

Force unsupported obfuscator

de4dot file1.dll -p un

For other obfuscator types, see the help screen.

Disabling symbol renaming

Renaming symbols isn't as easy as renaming A to B when reflection is involved. de4dot currently doesn't support renaming XAML so if you suspect that it uses WPF (or if it's a Silverlight app) you should disable renaming if the assembly fails to run.

de4dot --dont-rename file1.dll file2.dll

--keep-names can also be used to tell de4dot not to rename certain symbols, eg. "don't rename fields".

Rename everything that should be renamed except properties, events and methods.

de4dot --keep-names pem file1.dll

Using a different rename regex

The default regexes should be enough, except possibly the one that is used when an unsupported obfuscator is detected. To see all default regexes, start de4dot without any arguments and it will list all options and all default values.

Eg., currently the following is the default regex used when Dotfuscator is detected

!^[a-z][a-z0-9]{0,2}$&!^A_[0-9]+$&^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$

As you can see, it's not just one regex, it's more than one. Each one is separated by & and each regex can be negated by using! in front of it. To show it more clearly, these regexes are used:

(negated) ^[a-z][a-z0-9]{0,2}$
(negated) ^A_[0-9]+$
^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$

To change the regex(es), you must know the short type name of the obfuscator (see help screen). Eg. it's sa if it's SmartAssembly, and un if it's an unsupported/unknown obfuscator. The option to use is --TYPE-name (eg. --sa-name for SmartAssembly and --un-name for unknown/unsupported obfuscators):

de4dot --un-name "^[a-zA-Z]\w*$" file1.dll

Other options

Start de4dot without any arguments and it will show all options.

Examples

Show help:

de4dot -h

Deobfuscate a few files:

de4dot file1.exe file2.dll file3.exe

Deobfuscate all files found:

de4dot -r c:\path1 -ro c:\out

Detect obfuscator recursively:

de4dot -d -r c:\path1

Deobfuscate and get a detailed log of what was changed:

de4dot -v file1.exe file2.dll file3.exe > log.txt

Deobfuscate and override string decrypter detection, finding and using all static methods with string and int args that return a string. A dynamic method is created and used to call the string decrypter method(s). Make sure you don't include any non-string decrypter methods or you will get an exception:

de4dot --default-strtyp delegate --default-strtok "(System.String, System.Int32)" file1.exe file2.dll

Same as above but use a metadata token:

de4dot --default-strtyp delegate file1.exe --strtok 06000123 file2.dll --strtok 06004567 --strtok 06009ABC

Don't remove obfuscator types, methods, etc:

de4dot --keep-types file1.exe

转载于:https://www.cnblogs.com/wuchitao/p/6506570.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: de4dot-3.0.3是一款用于反混淆和反编译.NET程序的工具。该工具可以帮助开发人员分析和了解加密或混淆过的代码。它能够识别和还原出使用各种混淆技术(如虚拟机、控制流平坦化等)进行保护的程序。 de4dot-3.0.3具有简单易用的图形用户界面和命令行界面,用户可以根据需要选择适合自己的方式进行操作。它可以应用于各种类型的.NET程序,无论是开源项目还是商业软件。 通过使用de4dot-3.0.3,用户可以还原出被混淆过的代码的原始形式,以便更好地理解其功能和逻辑。这对于软件安全研究人员、代码审计人员以及对某个特定程序感兴趣的人来说非常有帮助。 同时,de4dot-3.0.3还提供了一些高级功能,比如支持多种混淆技术的解除,可以提取出原始的字符串、方法名称和其他关键信息。它还可以生成可读性更高的反编译代码,使得代码分析更加方便和简单。 总之,de4dot-3.0.3是一款功能强大的.NET程序反混淆和反编译工具,它可以帮助开发人员分析和还原出加密或混淆的代码,提供更好的代码理解和分析能力。它适用于各种.NET程序,无论是学习、研究还是审计都有很大的价值。 ### 回答2: de4dot-3.0.3 是一款开源的.NET反混淆工具。它可以用于还原经过混淆处理的.NET程序,使程序的代码恢复到更容易理解和分析的状态。 de4dot-3.0.3具有以下几个主要特点: 1. 完整的.NET支持:de4dot-3.0.3支持所有版本的.NET框架,并且可以处理各种类型的混淆技术,包括字符串加密、控制流优化和反调试等。 2. 用户友好的界面:de4dot-3.0.3提供了一个简单易用的命令行界面,让用户可以方便地进行操作。用户只需输入指定的命令,工具就会根据用户的要求对程序进行反混淆。 3. 高效的反混淆算法:de4dot-3.0.3使用了先进的反混淆算法,可以在较短的时间内还原大部分混淆效果。它能够自动检测和处理各种类型的混淆,使程序的原始结构和逻辑得以恢复。 4. 强大的插件系统:de4dot-3.0.3提供了一个插件系统,使用户可以根据自己的需求进行扩展。用户可以编写自己的插件来处理特定类型的混淆,或者使用其他人开发的插件来增强反混淆的效果。 总之,de4dot-3.0.3是一款功能强大的.NET反混淆工具,可以帮助用户还原经过混淆处理的程序,使其代码恢复到易于理解和分析的状态。无论是初学者还是专业开发人员,都可以通过使用de4dot-3.0.3来提高对.NET程序的理解和研究水平。 ### 回答3: de4dot-3.0.3 是一个脱壳工具,具体是一种用于去除各种保护机制的反汇编工具。它可以用来分析和逆向工程,在通过分析二进制文件中的代码找出关键信息时非常有用。 de4dot-3.0.3 是一个开源工具,它可以在Windows、Linux和Mac等操作系统上使用。使用它可以去除应用程序或库中的加密和保护措施,以便进一步分析程序的逻辑和运行过程。 de4dot-3.0.3 具有很强的适应性,可以去除多种保护机制,包括混淆、加密、壳等等。它支持多种二进制格式,如PE、ELF和Mach-O,可以处理多种CPU架构,如x86、ARM和MIPS等。 使用de4dot-3.0.3,我们可以对受到保护的二进制文件进行解除保护并还原成原始的代码,这对于软件逆向工程而言非常有用。无论是进行恶意软件分析,还是对商业软件进行安全性评估,de4dot-3.0.3都是一个必备的工具。 总结来说,de4dot-3.0.3是一个功能强大的脱壳工具,可以用于去除各种保护机制,方便进行反编译和逆向工程分析。它是开源软件,支持多种操作系统和二进制格式,适用于多种CPU架构。无论是安全专家还是研究人员,都可以利用de4dot-3.0.3工具来进行二进制分析与逆向工程。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值