Skip to content

Commit

Permalink
BugFix
Browse files Browse the repository at this point in the history
  • Loading branch information
TobitoFatitoRE committed Sep 21, 2019
1 parent bfaf274 commit fbddd83
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .idea/.idea.ArchangelUnCloaker/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 27 additions & 28 deletions ArchangelUnCloaker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,30 @@ public static void Main(string[] args){
Console.WriteLine($"Found {MethodFields.Count} obfuscated fields and deobfuscated them.");

int replacedmethods = 0;
foreach (var type in Module.Types)
foreach (var method in type.Methods){
if (method.HasBody && method.Body.HasInstructions)
foreach (var instr in method.Body.Instructions)
if (instr.OpCode == OpCodes.Ldsfld)
try{
var op = (FieldDef) instr.Operand;
var d = MethodFields[op];
if (d == null)
continue;
method.FreeMethodBody();
method.Body = d.Body;
replacedmethods++;
goto GetOut;
}
catch{
}

GetOut: ;
foreach (var type in Module.GetTypes()){
foreach (var method in type.Methods){
if (method.HasBody && method.Body.HasInstructions)
foreach (var instr in method.Body.Instructions)
if (instr.OpCode == OpCodes.Ldsfld)
try{

var op = (FieldDef) instr.Operand;
var d = MethodFields[op];
if (d == null)
continue;
method.FreeMethodBody();
method.Body = d.Body;
replacedmethods++;
goto GetOut;
}
catch{
}

GetOut: ;
}
}


Console.WriteLine($"Successfully Replaced {replacedmethods} out of {MethodFields.Count} methods.");
if (replacedmethods != MethodFields.Count){
Console.ForegroundColor = ConsoleColor.Red;
Expand All @@ -84,7 +88,6 @@ public static void Main(string[] args){
Importer importer = new Importer(Module);
IMethod Method;
Method = importer.Import(invokemethod);
// method.Body.Instructions.Add(new Instruction(opc,method.Module.Import(Method)));
var mainmdtok = asm.EntryPoint.MetadataToken;
foreach (var type in Module.Types){
foreach (var method in type.Methods){
Expand All @@ -94,14 +97,10 @@ public static void Main(string[] args){
}
}
}







// Module.Types.Remove(specific); Maybe shouldn't remove, you decide.
else{
Module.Types.Remove(specific);
//Maybe shouldn't remove, you decide.
}
Save(Module, args[0]);
Console.WriteLine("Successfully Saved!");
Console.ReadLine();
Expand Down

0 comments on commit fbddd83

Please sign in to comment.