using Mono.Cecil;
using Mono.Cecil.Cil;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HARObfuscator.Protection
{
    class Stringhider
    {
        static Random rnd = new Random();
        public static void Start(AssemblyDefinition AD)
        {
            foreach (TypeDefinition type in AD.MainModule.Types)   
            {
                foreach (MethodDefinition method in 
type.Methods)                 --line 18
                {
                    if (method.HasBody)
                        for (int i = 0; i < method.Body.Instructions.Count; 
i++)
                        {
                            if (method.Body.Instructions[i].OpCode == 
OpCodes.Ldstr)
                            {
                                ILProcessor ilp = 
method.Body.GetILProcessor();
                                MethodDefinition mdef = new 
MethodDefinition("hider" + rnd.Next(0,80), 
MethodAttributes.Public,AD.MainModule.Import(typeof(string)));
                                
mdef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, 
method.Body.Instructions[i].Operand.ToString()));
                                
mdef.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
                                type.Methods.Add(mdef);
                                
ilp.InsertAfter(method.Body.Instructions[i], 
Instruction.Create(OpCodes.Call, mdef));
                            }
                        }
                }
            }

        }
    }
}

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to