Add additional function to the deobfuscation command
This commit is contained in:
parent
0e53a50977
commit
5c1842daaa
@ -9,9 +9,12 @@ namespace ReCodeIt.Commands;
|
||||
[Command("DeObfuscate", Description = "Generates a de-obfuscated -cleaned dll in the folder your assembly is in")]
|
||||
public class DeObfuscate : ICommand
|
||||
{
|
||||
[CommandParameter(0, IsRequired = true, Description = "The absolute path to your obfuscated assembly file, folder must contain all references to be resolved.")]
|
||||
[CommandParameter(0, IsRequired = true, Description = "The absolute path to your obfuscated assembly or exe file, folder must contain all references to be resolved.")]
|
||||
public string AssemblyPath { get; init; }
|
||||
|
||||
[CommandParameter(1, IsRequired = false, Description = "Is the target the EFT launcher?")]
|
||||
public bool IsLauncher { get; init; } = false;
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
DataProvider.IsCli = true;
|
||||
@ -19,7 +22,7 @@ public class DeObfuscate : ICommand
|
||||
|
||||
Logger.Log("Deobfuscating assembly...");
|
||||
|
||||
Deobfuscator.Deobfuscate(AssemblyPath);
|
||||
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
||||
|
||||
Logger.Log("Complete", ConsoleColor.Green);
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace ReCodeItLib.Remapper;
|
||||
|
||||
public static class Deobfuscator
|
||||
{
|
||||
public static void Deobfuscate(string assemblyPath)
|
||||
public static void Deobfuscate(string assemblyPath, bool isLauncher = false)
|
||||
{
|
||||
var executablePath = Path.Combine(DataProvider.DataPath, "De4dot", "de4dot.exe");
|
||||
|
||||
@ -54,13 +54,18 @@ public static class Deobfuscator
|
||||
token = $"0x{(deobfRid.Raw | deobfRid.Rid):x4}";
|
||||
Console.WriteLine($"Deobfuscation token: {token}");
|
||||
|
||||
var process = Process.Start(executablePath,
|
||||
$"--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}\""
|
||||
: $"--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 process = Process.Start(executablePath, cmd);
|
||||
|
||||
process.WaitForExit();
|
||||
|
||||
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) + "-cleaned.dll");
|
||||
var cleanedDllPath = Path.Combine(Path.GetDirectoryName(assemblyPath), Path.GetFileNameWithoutExtension(assemblyPath) + extName);
|
||||
|
||||
ModuleDefMD assemblyRewrite = null;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user