Sniper.ps Posted July 30, 2015 Posted July 30, 2015 Hello Guys I am gonna to make a simple renamer for .Net Apps .. the problem is : after rename the (modules, types,methods .. etc) the file is not working this is the code which i am using private void button1_Click(object sender, EventArgs e) { Rename(AssemblyDef.Load("C:\\MyApp.exe")); } public void Rename(AssemblyDef AsmDef) { int xMod = 0; int xType = 0; int xMethod = 0; int xParameter = 0; int xField = 0; int xProperty = 0; foreach (ModuleDef ModDef in AsmDef.Modules) { ModDef.Name = "Mod_" + xMod; xMod += 1; foreach (TypeDef TypDef in ModDef.Types) { TypDef.Name = "Type_" + xType; xType += 1; foreach (MethodDef MthdDef in TypDef.Methods) { if (!MthdDef.IsConstructor && !MthdDef.IsRuntimeSpecialName) { MthdDef.Name = "Method_" + xMethod; xMethod += 1; foreach (ParamDef PrmDef in MthdDef.ParamDefs) { PrmDef.Name = "Parameter_" + xParameter; xParameter += 1; } } } foreach (FieldDef FldDef in TypDef.Fields) { FldDef.Name = "Field_" + xField; xField += 1; } foreach (PropertyDef PropDef in TypDef.Properties) { PropDef.Name = "Property_" + xProperty; xProperty += 1; } } } AsmDef.Write("C:\\MyApp11.exe"); } and this is the problem shown by dotNet Tracer v20.0 Thanks for you
hakouabs Posted July 30, 2015 Posted July 30, 2015 private void button1_Click(object sender, EventArgs e) { Rename(AssemblyDef.Load("C:\\MyApp.exe")); } public void Rename(AssemblyDef AsmDef) { int xMod = 0; int xType = 0; int xMethod = 0; int xParameter = 0; int xField = 0; int xProperty = 0; foreach (ModuleDef ModDef in AsmDef.Modules) { ModDef.Name = "Mod_" + xMod.Tostring(); xMod += 1; foreach (TypeDef TypDef in ModDef.Types) { TypDef.Name = "Type_" + xType.Tostring(); xType += 1; foreach (MethodDef MthdDef in TypDef.Methods) { if (!MthdDef.IsSpecialName && !MthdDef.IsRuntimeSpecialName) { MthdDef.Name = "Method_" + xMethod.Tostring(); xMethod += 1; foreach (ParamDef PrmDef in MthdDef.ParamDefs) { PrmDef.Name = "Parameter_" + xParameter.Tostring(); xParameter += 1; } } } foreach (FieldDef FldDef in TypDef.Fields) { FldDef.Name = "Field_" + xField.Tostring(); xField += 1; } foreach (PropertyDef PropDef in TypDef.Properties) { PropDef.Name = "Property_" + xProperty.Tostring(); xProperty += 1; } } } AsmDef.Write("D:\\MyApp11.exe"); }Test............. 1
Sniper.ps Posted July 30, 2015 Author Posted July 30, 2015 (edited) Thank you hakouabs brother .. unfortunately it does not work .. so temporarily i add this condition in "ModDef.Types" loop to ignore the Namespace shown in figure below .. because the problem come from it .. and its work fine if(TypDef.Namespace.EndsWith(".My")) { continue; } i need some solution to rename it also like in "Phoenix Protector" for example like this Edited July 30, 2015 by Sniper.ps
li0nsar3c00l Posted July 30, 2015 Posted July 30, 2015 there is a reason why de4dot's renaming code is a bit longer than these couple lines. If you don't want to use it, which would be the easiest solution, i'd recommend to check the source tho 4
noob.exe Posted July 31, 2015 Posted July 31, 2015 You need to exclude some things, certain symbols can't be renamed, or at least require further modification.For example resourcemanager, p/invokes etc.. 1
Sniper.ps Posted July 31, 2015 Author Posted July 31, 2015 Thank you li0nsar3c00l .. I'll read the de4dot code and learn from it You need to exclude some things, certain symbols can't be renamed, or at least require further modification.For example resourcemanager, p/invokes etc.. Thank you yq8 .. that's what I'll do .. and I'll study some of Obfuscators to know what should i modify .. Thank you again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now