public void Execute(PandaState pandaState, PandaContext pandaContext) { CFHelper cFHelper = new CFHelper(); foreach (TypeDef type in pandaContext.moduleDef.Types) { foreach (MethodDef method in type.Methods) { if (method.HasBody && method.Body.Instructions.Count > 0 && !method.IsConstructor) { if (!cFHelper.HasUnsafeInstructions(method)) { if (DnlibUtils.Simplify(method)) { Blocks blocks = cFHelper.GetBlocks(method); if (blocks.blocks.Count != 1) { switch (pandaState) { case PandaState.Basic: toDoSwitcher(cFHelper, method, blocks, pandaContext); break; case PandaState.Normal: toDoBody(cFHelper, method, blocks, pandaContext); break; } } DnlibUtils.Optimize(method); } } } } } }
public void Execute(PandaContext panda) { INTMHelper IMHelper = new INTMHelper(); foreach (TypeDef type in panda.moduleDef.Types) { foreach (MethodDef method in type.Methods) { if (ObfuscationUtils.ObfuscationMethodUtil.canObfuscate(method)) { for (int i = 0; i < method.Body.Instructions.Count; i++) { Instruction instruction = method.Body.Instructions[i]; if (instruction.Operand is int) { List <Instruction> instructions = IMHelper.Calc(Convert.ToInt32(instruction.Operand)); instruction.OpCode = OpCodes.Nop; foreach (Instruction instr in instructions) { method.Body.Instructions.Insert(i + 1, instr); i++; } } } } } } }
public void Add(Panda panda) { using (var ctx = new PandaContext(_dbHelper)) { ctx.Pandas.Add(panda); ctx.SaveChanges(); } }
public void Encoding(PandaContext pandaContext) { StringHelper stringHelper = new StringHelper(); MethodDef DecryptMethod = stringHelper.Inject(pandaContext.moduleDef); foreach (TypeDef type in pandaContext.moduleDef.Types) { foreach (MethodDef method in type.Methods) { if (method.Body == null) { continue; } if (method == DecryptMethod) { continue; } for (int i = 0; i < method.Body.Instructions.Count(); i++) { if (method.Body.Instructions[i].OpCode == OpCodes.Ldstr) { string oldStr = method.Body.Instructions[i].Operand.ToString(); method.Body.Instructions[i].Operand = stringHelper.Encrypt(oldStr); method.Body.Instructions.Insert(i + 1, new Instruction(OpCodes.Call, DecryptMethod)); i++; } } } } }
public void Encoding(PandaContext pandaContext) { foreach (TypeDef type in pandaContext.moduleDef.Types) { foreach (MethodDef method in type.Methods) { if (method.Body == null) { continue; } for (int i = 0; i < method.Body.Instructions.Count(); i++) { if (method.Body.Instructions[i].OpCode == OpCodes.Ldstr) { String oldString = method.Body.Instructions[i].Operand.ToString(); String newString = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(oldString)); method.Body.Instructions[i].OpCode = OpCodes.Nop; method.Body.Instructions.Insert(i + 1, new Instruction(OpCodes.Call, pandaContext.moduleDef.Import(typeof(System.Text.Encoding).GetMethod("get_UTF8", new Type[] { })))); method.Body.Instructions.Insert(i + 2, new Instruction(OpCodes.Ldstr, newString)); method.Body.Instructions.Insert(i + 3, new Instruction(OpCodes.Call, pandaContext.moduleDef.Import(typeof(System.Convert).GetMethod("FromBase64String", new Type[] { typeof(string) })))); method.Body.Instructions.Insert(i + 4, new Instruction(OpCodes.Callvirt, pandaContext.moduleDef.Import(typeof(System.Text.Encoding).GetMethod("GetString", new Type[] { typeof(byte[]) })))); i += 4; } } DnlibUtils.Optimize(method); } } }
public NormalStringEncoding(PandaContext pandaContext) { if (pandaContext != null) { Encoding(pandaContext); } new ArgumentNullException("PandaContext cannot be null!"); }
public void Delete(string name) { using (var ctx = new PandaContext(_dbHelper)) { var panda = ctx.Pandas.Single(p => p.Name == name); ctx.Remove(panda); ctx.SaveChanges(); } }
public ControlFlow(PandaState pandaState, PandaContext pandaContext) { if (pandaContext != null) { Execute(pandaState, pandaContext); } new ArgumentNullException("pandaContext cannot be null"); }
public void toDoBody(CFHelper cFHelper, MethodDef method, Blocks blocks, PandaContext pandaContext) { blocks.Scramble(out blocks); method.Body.Instructions.Clear(); Local local = new Local(pandaContext.moduleDef.CorLibTypes.Int32); method.Body.Variables.Add(local); Instruction target = Instruction.Create(OpCodes.Nop); Instruction instr = Instruction.Create(OpCodes.Br, target); foreach (Instruction instruction in cFHelper.Calc(0)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local)); method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, instr)); method.Body.Instructions.Add(target); foreach (Block block in blocks.blocks) { if (block != blocks.getBlock((blocks.blocks.Count - 1))) { method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local)); foreach (Instruction instruction in cFHelper.Calc(block.ID)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq)); Instruction instruction4 = Instruction.Create(OpCodes.Nop); method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instruction4)); foreach (Instruction instruction in block.instructions) { method.Body.Instructions.Add(instruction); } foreach (Instruction instruction in cFHelper.Calc(block.nextBlock)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local)); method.Body.Instructions.Add(instruction4); } } method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local)); foreach (Instruction instruction in cFHelper.Calc(blocks.blocks.Count - 1)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq)); method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instr)); method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.getBlock((blocks.blocks.Count - 1)).instructions[0])); method.Body.Instructions.Add(instr); foreach (Instruction lastBlock in blocks.getBlock((blocks.blocks.Count - 1)).instructions) { method.Body.Instructions.Add(lastBlock); } }
public void toDoSwitcher(CFHelper cFHelper, MethodDef method, Blocks blocks, PandaContext pandaContext) { List <Instruction> instructionsOperand = new List <Instruction>(); method.Body.Instructions.Clear(); Local local = new Local(pandaContext.moduleDef.CorLibTypes.Int32); method.Body.Variables.Add(local); foreach (Instruction instruction in cFHelper.Calc(0)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local)); Instruction target = Instruction.Create(OpCodes.Nop); method.Body.Instructions.Add(target); method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local)); Instruction targetSwitch = Instruction.Create(OpCodes.Switch, instructionsOperand); method.Body.Instructions.Add(targetSwitch); method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.getBlock((blocks.blocks.Count - 1)).instructions[blocks.getBlock((blocks.blocks.Count - 1)).instructions.Count - 1])); foreach (Block block in blocks.blocks) { if (block != blocks.getBlock((blocks.blocks.Count - 1))) { Instruction instr = Instruction.Create(OpCodes.Stloc, local); instructionsOperand.Add(block.instructions[0]); Instruction instruction4 = Instruction.Create(OpCodes.Nop); foreach (Instruction instruction in block.instructions) { method.Body.Instructions.Add(instruction); } foreach (Instruction instruction in cFHelper.Calc(block.nextBlock)) { method.Body.Instructions.Add(instruction); } method.Body.Instructions.Add(instr); method.Body.Instructions.Add(instruction4); method.Body.Instructions.Add(new Instruction(OpCodes.Br, target)); method.Body.Instructions.Add(instruction4); } } method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.getBlock((blocks.blocks.Count - 1)).instructions[0])); method.Body.Instructions.Add(new Instruction(OpCodes.Br, target)); foreach (Instruction lastBlock in blocks.getBlock((blocks.blocks.Count - 1)).instructions) { method.Body.Instructions.Add(lastBlock); } instructionsOperand.Add(blocks.getBlock((blocks.blocks.Count - 1)).instructions[0]); targetSwitch.Operand = instructionsOperand; }
public void reNew() { darkTextBox1.Text = ""; darkSectionPanel2.Enabled = false; nameLbl.Text = "Name: "; idLbl.Text = "Id: "; DescLbl.Text = "Description: "; authorLbl.Text = "Author: "; pandaContext = null; pandaEngine = null; }
public void Melting(PandaContext pandaContext) { foreach (TypeDef type in pandaContext.moduleDef.Types.ToArray()) { foreach (MethodDef method in type.Methods.ToArray()) { StringOutliner(method); IntegerOutliner(method); } } }
public override void Execute(PandaState pandaState, PandaContext pandaContext) { switch (pandaState) { case PandaState.Basic: new BasicStringEncoding(pandaContext); break; case PandaState.Normal: new NormalStringEncoding(pandaContext); break; } }
public ReferenceProxy(PandaState pandaState, PandaContext pandaContext) { switch (pandaState) { case PandaState.Basic: new RPBasic().Excute(pandaContext); break; case PandaState.Normal: new RPNormal().Excute(pandaContext); break; } }
public override void Execute(PandaState pandaState, PandaContext pandaContext) { switch (pandaState) { case PandaState.Basic: new IntMath(pandaContext); break; case PandaState.Normal: for (int i = 0; i < 1; i++) { new IntMath(pandaContext); } break; } }
private void darkButton1_Click(object sender, EventArgs e) { OpenFileDialog op = new OpenFileDialog(); if (op.ShowDialog() == DialogResult.OK) { darkTextBox1.Text = op.FileName; try { pandaContext = new PandaContext(op.FileName); pandaModuleManager = new PandaModuleManager(); pandaEngine = new PandaEngine(pandaContext); darkSectionPanel2.Enabled = true; }catch (Exception) { darkSectionPanel2.Enabled = false; } } }
public override void Execute(PandaState pandaState, PandaContext pandaContext) { new ReferenceProxy(pandaState, pandaContext); }
public addForm(PandaContext pandaContext, mainForm mainForm) { this.main = mainForm; this.pandaContext = pandaContext; InitializeComponent(); }
public override void Execute(PandaState pandaState, PandaContext pandaContext) { new ConstantMelting(pandaContext); }
public DishController(PandaContext dbcontext) { context = dbcontext; }
public ConstantMelting(PandaContext pandaContext) { Melting(pandaContext); }
public BaseController() { this.db = new PandaContext(); }
public List <Panda> FetchAll() { using (var ctx = new PandaContext(_dbHelper)) { return(ctx.Pandas.ToList()); } }
public Panda Fetch(string name) { using (var ctx = new PandaContext(_dbHelper)) { return(ctx.Pandas.SingleOrDefault(p => p.Name == name)); } }
public UserService(PandaContext context) { this.context = context; }
public PandaController(PandaContext context) { _context = context; }
public void Excute(PandaContext pandaContext) { RPHelper rPHelper = new RPHelper(); DnlibUtils.fixProxy(pandaContext.moduleDef); foreach (TypeDef type in pandaContext.moduleDef.Types.ToArray()) { foreach (MethodDef method in type.Methods.ToArray()) { if (usedMethods.Contains(method)) { continue; } if (ObfuscationUtils.ObfuscationMethodUtil.canObfuscate(method)) { foreach (Instruction instruction in method.Body.Instructions.ToArray()) { if (instruction.OpCode == OpCodes.Newobj) { IMethodDefOrRef methodDefOrRef = instruction.Operand as IMethodDefOrRef; if (methodDefOrRef.IsMethodSpec) { continue; } if (methodDefOrRef == null) { continue; } MethodDef methodDef = rPHelper.GenerateMethod(methodDefOrRef, method); if (methodDef == null) { continue; } method.DeclaringType.Methods.Add(methodDef); usedMethods.Add(methodDef); instruction.OpCode = OpCodes.Call; instruction.Operand = methodDef; usedMethods.Add(methodDef); } else if (instruction.OpCode == OpCodes.Stfld) { FieldDef targetField = instruction.Operand as FieldDef; if (targetField == null) { continue; } CilBody body = new CilBody(); body.Instructions.Add(OpCodes.Nop.ToInstruction()); body.Instructions.Add(OpCodes.Ldarg_0.ToInstruction()); body.Instructions.Add(OpCodes.Ldarg_1.ToInstruction()); body.Instructions.Add(OpCodes.Stfld.ToInstruction(targetField)); body.Instructions.Add(OpCodes.Ret.ToInstruction()); var sig = MethodSig.CreateInstance(pandaContext.moduleDef.CorLibTypes.Void, targetField.FieldSig.GetFieldType()); sig.HasThis = true; MethodDefUser methodDefUser = new MethodDefUser(generator.Generate <string>(GeneratorType.String, 10), sig) { Body = body, IsHideBySig = true }; usedMethods.Add(methodDefUser); method.DeclaringType.Methods.Add(methodDefUser); instruction.Operand = methodDefUser; instruction.OpCode = OpCodes.Call; } } } } } }
public UserService(PandaContext context, IHashService hashService) { this.context = context; this.hashService = hashService; }
public override void Register(PandaContext pandaContext) { pandaContext.register.RegisterModule(this); }
public override void Execute(PandaState pandaState, PandaContext pandaContext) { new ControlFlow(pandaState, pandaContext); }