[C#] ConfuserEX: Local to Field Protection / Source

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Hard Coder
Banlı Üye
Katılım
2 Tem 2019
Mesajlar
77
Tepki puanı
7
Yaş
26
6 HİZMET YILI
Yeah firend This protection marks the module with a attribute that discourage ILDasm from disassembling it

Source:
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Confuser.Core;
using dnlib.DotNet;
using dnlib.DotNet.Emit;

namespace Confuser.Protections
{
    internal class LocaltoFieldProtection : Protection
    {
        public const string _Id = "local to field";
        public const string _FullId = "Ki.Local2Field";

        public override string Name
        {
            get { return "local to field Protection"; }
        }

        public override string Description
        {
            get { return "This protection marks the module with a attribute that discourage ILDasm from disassembling it."; }
        }

        public override string Id
        {
            get { return _Id; }
        }

        public override string FullId
        {
            get { return _FullId; }
        }

        public override ProtectionPreset Preset
        {
            get { return ProtectionPreset.Minimum; }
        }

        protected override void Initialize(ConfuserContext context)
        {
            //
        }

        protected override void PopulatePipeline(ProtectionPipeline pipeline)
        {
            pipeline.InsertPreStage(PipelineStage.ProcessModule, new localtofieldphase(this));
        }

        class localtofieldphase : ProtectionPhase
        {
            public localtofieldphase(LocaltoFieldProtection parent)
                : base(parent) { }

            public override ProtectionTargets Targets
            {
                get { return ProtectionTargets.Modules; }
            }



            public override string Name
            {
                get { return "Local-to-field executing"; }
            }
            public void ProcessMethod(MethodDef method, ModuleDef modulee)
            {
                var instructions = method.Body.Instructions;
                for (int i = 0; i < instructions.Count; i++)
                {
                    if (instructions[i].Operand is Local local)
                    {
                        FieldDef def = null;
                        if (!convertedLocals.ContainsKey(local))
                        {
                            def = new FieldDefUser("", new FieldSig(local.Type), FieldAttributes.Public | FieldAttributes.Static);
                            modulee.GlobalType.Fields.Add(def);
                            convertedLocals.Add(local, def);
                        }
                        else
                            def = convertedLocals[local];


                        OpCode eq = null;
                        switch (instructions[i].OpCode.Code)
                        {
                            case Code.Ldloc:
                            case Code.Ldloc_S:
                            case Code.Ldloc_0:
                            case Code.Ldloc_1:
                            case Code.Ldloc_2:
                            case Code.Ldloc_3:
                                eq = OpCodes.Ldsfld;
                                break;
                            case Code.Ldloca:
                            case Code.Ldloca_S:
                                eq = OpCodes.Ldsflda;
                                break;
                            case Code.Stloc:
                            case Code.Stloc_0:
                            case Code.Stloc_1:
                            case Code.Stloc_2:
                            case Code.Stloc_3:
                            case Code.Stloc_S:
                                eq = OpCodes.Stsfld;
                                break;
                        }
                        instructions[i].OpCode = eq;
                        instructions[i].Operand = def;

                    }
                }
            }
            Dictionary<Local, FieldDef> convertedLocals = new Dictionary<Local, FieldDef>();
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                foreach (ModuleDef module in parameters.Targets.OfType<ModuleDef>())
                {
                    foreach (var type in module.Types.Where(x => x != module.GlobalType))
                    {
                        foreach (var method in type.Methods.Where(x => x.HasBody && x.Body.HasInstructions && !x.IsConstructor))
                        {
                            convertedLocals = new Dictionary<Local, FieldDef>();
                            ProcessMethod(method, module);
                        }
                    }
                }
            }
        }
    }
}
Not: istek olursa attığım koruma kodları ConfuserEX'e ekli şekilde yayınlıyabilirim kodları bu sayede kodları kullanarak ne işe yaradıgınıda anlarsınız
 
Son düzenleme:
  • Konuyu başlatan
  • Yasaklandı
  • #5
Hard Coder
Banlı Üye
Katılım
2 Tem 2019
Mesajlar
77
Tepki puanı
7
Yaş
26
6 HİZMET YILI
C# Class dll oluştur forum içine open file dialog tarzı artık allah ne verdiyse
forum değil form olacak buu 1
2. hangi form ? ? ?? ConfuserEX.exe kendisi bir hiçdir yanındaki
Bağlantıları görmek için lütfen Giriş Yap
herşeyin başı
Bağlantıları görmek için lütfen Giriş Yap
korumaların olduğu bölüm en ufak yalnış'da tüm proje gg
Bağlantıları görmek için lütfen Giriş Yap
'ye gelirsek buda isimlendirme kısaca RENAME korumasını sağlıyor ve bu dll olmadan Confuser.Protection bir hiçtir
Bağlantıları görmek için lütfen Giriş Yap
ise çoğu koruma Anti Tamper - Anti Debug - Compressor - Constant - Anti Dump kısaca korumaların yarısı bu dll sayesinde çalışıyor korumalar çoğu kodları bu dll üzerinden çekiyor
Bağlantıları görmek için lütfen Giriş Yap
ayak işlerini yapar. KAPİŞ ?
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst