From 4e33f48be06dda41af6795b2548572535545dd8d Mon Sep 17 00:00:00 2001
From: Cj <161484149+CJ-SPT@users.noreply.github.com>
Date: Mon, 30 Dec 2024 22:54:38 -0500
Subject: [PATCH] Fix de4dot, change back to .net48, allow to build along side
project. Add post build script to create the cli in a build directory in the
solution directory
---
ReCodeItCLI/ReCodeItCLI.csproj | 41 ++++-
RecodeIt.sln | 22 +++
RecodeItLib/ReCodeItLib.csproj | 165 +-----------------
RecodeItLib/Remapper/DeObfuscator.cs | 46 +----
de4dot/AssemblyData/AssemblyData.csproj | 6 +-
.../AssemblyServer-x64.csproj | 3 +-
de4dot/de4dot-x64/de4dot-x64.csproj | 4 +-
de4dot/de4dot.blocks/de4dot.blocks.csproj | 6 +-
.../NewAppDomainAssemblyServerLoader.cs | 2 +-
de4dot/de4dot.code/de4dot.code.csproj | 3 +-
de4dot/de4dot.cui/de4dot.cui.csproj | 6 +-
de4dot/de4dot.mdecrypt/de4dot.mdecrypt.csproj | 3 +-
12 files changed, 83 insertions(+), 224 deletions(-)
diff --git a/ReCodeItCLI/ReCodeItCLI.csproj b/ReCodeItCLI/ReCodeItCLI.csproj
index b35426c..311345e 100644
--- a/ReCodeItCLI/ReCodeItCLI.csproj
+++ b/ReCodeItCLI/ReCodeItCLI.csproj
@@ -7,10 +7,6 @@
enable
enable
-
-
-
-
@@ -20,4 +16,41 @@
+
+ $(SolutionDir)de4dot\AssemblyServer-x64\AssemblyServer-x64.csproj
+ $(SolutionDir)de4dot\de4dot-x64\de4dot-x64.csproj
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RecodeIt.sln b/RecodeIt.sln
index 69c54ed..0b7b938 100644
--- a/RecodeIt.sln
+++ b/RecodeIt.sln
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyData", "de4dot\Asse
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "de4dot.blocks", "de4dot\de4dot.blocks\de4dot.blocks.csproj", "{8365D905-3BC4-42A0-B072-035598C6AF8C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "de4dot-x64", "de4dot\de4dot-x64\de4dot-x64.csproj", "{3D0F9399-7814-4EB9-8436-D56BA87F874C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -237,6 +239,26 @@ Global
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x64.Build.0 = Release|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.ActiveCfg = Release|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.Build.0 = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.Build.0 = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|x64.Build.0 = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|x86.Build.0 = Debug|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|ARM.ActiveCfg = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|ARM.Build.0 = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|ARM64.Build.0 = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x64.ActiveCfg = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x64.Build.0 = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.ActiveCfg = Release|Any CPU
+ {3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/RecodeItLib/ReCodeItLib.csproj b/RecodeItLib/ReCodeItLib.csproj
index 5e0d7e3..1a20df9 100644
--- a/RecodeItLib/ReCodeItLib.csproj
+++ b/RecodeItLib/ReCodeItLib.csproj
@@ -7,176 +7,13 @@
enable
enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
diff --git a/RecodeItLib/Remapper/DeObfuscator.cs b/RecodeItLib/Remapper/DeObfuscator.cs
index 825a04d..a7a81bc 100644
--- a/RecodeItLib/Remapper/DeObfuscator.cs
+++ b/RecodeItLib/Remapper/DeObfuscator.cs
@@ -9,9 +9,7 @@ namespace ReCodeItLib.Remapper;
public static class Deobfuscator
{
public static void Deobfuscate(string assemblyPath, bool isLauncher = false)
- {
- var executablePath = Path.Combine(DataProvider.DataPath, "De4dot", "de4dot-x64.exe");
-
+ {
string token;
ModuleContext modCtx = ModuleDef.CreateModuleContext();
@@ -57,43 +55,13 @@ public static class Deobfuscator
token = $"0x{(deobfRid.Raw | deobfRid.Rid):x4}";
Console.WriteLine($"Deobfuscation token: {token}");
- string[] dllArgs = [
- "--un-name",
- "!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*",
- assemblyPath,
- "--strtyp",
- "delegate",
- "--strtok",
- $"\"{token}\""
- ];
+ var cmd = isLauncher
+ ? $"--un-name \"!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*$\" \"{assemblyPath}\" --strtok \"{token}\""
+ : $"--un-name \"!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*$\" \"{assemblyPath}\" --strtyp delegate --strtok \"{token}\"";
- string[] launcherArgs = [
- "--un-name",
- "!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*",
- assemblyPath,
- "--strtok",
- $"\"{token}\""
- ];
+ var executablePath = Path.Combine(AppContext.BaseDirectory, "de4dot", "de4dot-x64.exe");
- de4dot.cui.Program.Main(isLauncher ? launcherArgs : dllArgs);
-
- var extName = isLauncher ? "-cleaned.exe" : "-cleaned.dll";
-
- // Fixes "ResolutionScope is null" by rewriting the assembly
- var cleanedDllPath = Path.Combine(Path.GetDirectoryName(assemblyPath), Path.GetFileNameWithoutExtension(assemblyPath) + extName);
-
- ModuleDefMD assemblyRewrite = null;
-
- using (var memoryStream = new MemoryStream(File.ReadAllBytes(cleanedDllPath)))
- {
- assemblyRewrite = ModuleDefMD.Load(memoryStream, modCtx);
-
- if (isLauncher)
- {
- SPTPublicizer.PublicizeClasses(assemblyRewrite, true);
- }
- }
-
- assemblyRewrite.Write(cleanedDllPath);
+ var process = Process.Start(executablePath, cmd);
+ process.WaitForExit();
}
}
\ No newline at end of file
diff --git a/de4dot/AssemblyData/AssemblyData.csproj b/de4dot/AssemblyData/AssemblyData.csproj
index be053ac..164bec3 100644
--- a/de4dot/AssemblyData/AssemblyData.csproj
+++ b/de4dot/AssemblyData/AssemblyData.csproj
@@ -1,9 +1,7 @@
-
- net8.0
-
-
+
+
diff --git a/de4dot/AssemblyServer-x64/AssemblyServer-x64.csproj b/de4dot/AssemblyServer-x64/AssemblyServer-x64.csproj
index fb9f73c..58aea1c 100644
--- a/de4dot/AssemblyServer-x64/AssemblyServer-x64.csproj
+++ b/de4dot/AssemblyServer-x64/AssemblyServer-x64.csproj
@@ -1,9 +1,10 @@
+
+
x64
Exe
- net8.0
diff --git a/de4dot/de4dot-x64/de4dot-x64.csproj b/de4dot/de4dot-x64/de4dot-x64.csproj
index 4fc8ef5..19b2e75 100644
--- a/de4dot/de4dot-x64/de4dot-x64.csproj
+++ b/de4dot/de4dot-x64/de4dot-x64.csproj
@@ -1,9 +1,11 @@
+
+
x64
Exe
- net8.0
+ net48
diff --git a/de4dot/de4dot.blocks/de4dot.blocks.csproj b/de4dot/de4dot.blocks/de4dot.blocks.csproj
index 6e1e27d..b6110e0 100644
--- a/de4dot/de4dot.blocks/de4dot.blocks.csproj
+++ b/de4dot/de4dot.blocks/de4dot.blocks.csproj
@@ -1,9 +1,7 @@
-
- net8.0
-
-
+
+
diff --git a/de4dot/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs b/de4dot/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs
index d1d4a5f..cb18a1b 100644
--- a/de4dot/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs
+++ b/de4dot/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs
@@ -35,7 +35,7 @@ namespace de4dot.code.AssemblyClient {
public override void LoadServer(string filename) {
if (appDomain != null)
throw new ApplicationException("Server is already loaded");
-
+
appDomain = AppDomain.CreateDomain(Utils.RandomName(15, 20));
thread = new Thread(new ThreadStart(() => {
try {
diff --git a/de4dot/de4dot.code/de4dot.code.csproj b/de4dot/de4dot.code/de4dot.code.csproj
index a5d65cc..5741082 100644
--- a/de4dot/de4dot.code/de4dot.code.csproj
+++ b/de4dot/de4dot.code/de4dot.code.csproj
@@ -1,8 +1,9 @@
+
+
true
- net8.0
diff --git a/de4dot/de4dot.cui/de4dot.cui.csproj b/de4dot/de4dot.cui/de4dot.cui.csproj
index dd87fce..aab6ab4 100644
--- a/de4dot/de4dot.cui/de4dot.cui.csproj
+++ b/de4dot/de4dot.cui/de4dot.cui.csproj
@@ -1,9 +1,7 @@
-
- net8.0
-
-
+
+
diff --git a/de4dot/de4dot.mdecrypt/de4dot.mdecrypt.csproj b/de4dot/de4dot.mdecrypt/de4dot.mdecrypt.csproj
index 8898528..7bcc1c7 100644
--- a/de4dot/de4dot.mdecrypt/de4dot.mdecrypt.csproj
+++ b/de4dot/de4dot.mdecrypt/de4dot.mdecrypt.csproj
@@ -1,8 +1,9 @@
+
+
true
- net8.0