8000 Add support of .Net Core 7.0. by KOLANICH · Pull Request #4 · andywu188/de4dot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support of .Net Core 7.0. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion De4DotCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<De4DotNetFramework Condition=" '$(SolutionName)' == 'de4dot.netframework' ">true</De4DotNetFramework>
<!-- Two different sln files are used because some of the projects are only available when targetting .NET Framework -->
<TargetFrameworks Condition=" '$(De4DotNetFramework)' == 'true' ">net35;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(De4DotNetFramework)' != 'true' ">netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(De4DotNetFramework)' != 'true' ">net7.0</TargetFrameworks>
<Features>strict</Features>
<LangVersion>latest</LangVersion>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ de4dot is an open source (GPLv3) .NET deobfuscator and unpacker written in C#. I

It uses [dnlib](https://github.com/0xd4d/dnlib/) to read and write assemblies so make sure you get it or it won't compile.

***WARNING***: `de4dot` uses `BinaryFormatter` in some backends (`BabelNET` and `CodeVeil`). Code obfuscated with these deobfuscators (or the one, that tricks `de4dot` to detect so) will cause execution of arbitrary code during deobfuscation. For example it may be possible to write code tracking attempts of applying `de4dot`. A more proper solution is needed for deobfuscating such binaries, such as a completely own parser doing the deserialization safely. Read https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide for more info.

Binaries
========

Expand Down
3 changes: 3 additions & 0 deletions de4dot.code/deobfuscators/Babel_NET/ConstantsDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ public void Deobfuscate(Blocks blocks) {

byte[] DecryptArray(byte[] encryptedData, int elemSize) {
var decrypted = resourceDecrypter.Decrypt(encryptedData);
#pragma warning disable SYSLIB0011
#warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
var ary = (Array)new BinaryFormatter().Deserialize(new MemoryStream(decrypted));
#pragma warning restore SYSLIB0011
if (ary is byte[])
return (byte[])ary;
var newAry = new byte[ary.Length * elemSize];
Expand Down
9 changes: 9 additions & 0 deletions de4dot.code/deobfuscators/CodeVeil/ResourceConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,32 @@ class CharArrayResourceData : UserResourceData {
public static readonly string ReflectionTypeName = "System.Char[],mscorlib";
char[] data;
public CharArrayResourceData(UserResourceType type, char[] data) : base(type) => this.data = data;
#pragma warning disable SYSLIB0011
#warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
public override void WriteData(BinaryWriter writer, IFormatter formatter) => formatter.Serialize(writer.BaseStream, data);
#pragma warning restore SYSLIB0011
public override string ToString() => $"char[]: Length: {data.Length}";
}

class IconResourceData : UserResourceData {
public static readonly string ReflectionTypeName = "System.Drawing.Icon,System.Drawing";
Icon icon;
public IconResourceData(UserResourceType type, byte[] data) : base(type) => icon = new Icon(new MemoryStream(data));
#pragma warning disable SYSLIB0011
#warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
public override void WriteData(BinaryWriter writer, IFormatter formatter) => formatter.Serialize(writer.BaseStream, icon);
#pragma warning restore SYSLIB0011
public override string ToString() => $"Icon: {icon}";
}

class ImageResourceData : UserResourceData {
public static readonly string ReflectionTypeName = "System.Drawing.Bitmap,System.Drawing";
Bitmap bitmap;
public ImageResourceData(UserResourceType type, byte[] data) : base(type) => bitmap = new Bitmap(Image.FromStream(new MemoryStream(data)));
#pragma warning disable SYSLIB0011
#warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
public override void WriteData(BinaryWriter writer, IFormatter formatter) => formatter.Serialize(writer.BaseStream, bitmap);
#pragma warning restore SYSLIB0011
public override string ToString() => "Bitmap";
}
}
2 changes: 1 addition & 1 deletion deobfuscator.Template/deobfuscator.Template.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net35;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net48;net7.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\de4dot.snk</AssemblyOriginatorKeyFile>
<Features>strict</Features>
Expand Down
0