C# ConfuserEX: Anti Process Hacker / Source

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Ultra Üye
Katılım
27 Kas 2017
Mesajlar
1,566
Çözümler
24
Tepki puanı
95
Ödüller
11
Sosyal
8 HİZMET YILI
Confusser.Protection
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using Confuser.Core;
using Confuser.Core.Helpers;
using Confuser.Core.Services;
using Confuser.Renamer;
using dnlib.DotNet;
using dnlib.DotNet.Emit;

namespace Confuser.Protections
{
    // Token: 0x020000A0 RID: 160
    internal class AntiProcessHackerProtection : Protection
    {
        // Token: 0x17000099 RID: 153
        // (get) Token: 0x06000296 RID: 662
        public override string Name
        {
            get
            {
                return "Anti Process Hacker Protection";
            }
        }

        // Token: 0x1700009A RID: 154
        // (get) Token: 0x06000297 RID: 663
        public override string Description
        {
            get
            {
                return "Bu koruma Process Hacker'in açılmasını engeller.";
            }
        }

        // Token: 0x1700009B RID: 155
        // (get) Token: 0x06000298 RID: 664
        public override string Id
        {
            get
            {
                return "Anti ProcessHacker";
            }
        }

        // Token: 0x1700009C RID: 156
        // (get) Token: 0x06000299 RID: 665
        public override string FullId
        {
            get
            {
                return "Ki.AntiProcessHacker";
            }
        }

        // Token: 0x1700009D RID: 157
        // (get) Token: 0x0600029A RID: 666
        public override ProtectionPreset Preset
        {
            get
            {
                return ProtectionPreset.Normal;
            }
        }

        // Token: 0x0600029B RID: 667
        protected override void Initialize(ConfuserContext context)
        {
        }

        // Token: 0x0600029C RID: 668
        protected override void PopulatePipeline(ProtectionPipeline pipeline)
        {
            pipeline.InsertPreStage(PipelineStage.ProcessModule, new AntiProcessHackerProtection.AntiProcessHackerPhase(this));
        }

        // Token: 0x040001D7 RID: 471
        public const string _Id = "Anti ProcessHacker";

        // Token: 0x040001D8 RID: 472
        public const string _FullId = "Ki.AntiProcessHacker";

        // Token: 0x020000A1 RID: 161
        private class AntiProcessHackerPhase : ProtectionPhase
        {
            // Token: 0x0600029E RID: 670
            public AntiProcessHackerPhase(AntiProcessHackerProtection parent) : base(parent)
            {
            }

            // Token: 0x1700009E RID: 158
            // (get) Token: 0x0600029F RID: 671
            public override ProtectionTargets Targets
            {
                get
                {
                    return ProtectionTargets.Modules;
                }
            }

            // Token: 0x1700009F RID: 159
            // (get) Token: 0x060002A0 RID: 672
            public override string Name
            {
                get
                {
                    return "Anti Process Hacker Injection";
                }
            }

            // Token: 0x060002A1 RID: 673
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                TypeDef runtimeType = context.Registry.GetService<IRuntimeService>().GetRuntimeType("Confuser.Runtime.AntiProcessHacker");
                IMarkerService service = context.Registry.GetService<IMarkerService>();
                INameService service2 = context.Registry.GetService<INameService>();
                foreach (ModuleDef moduleDef in parameters.Targets.OfType<ModuleDef>())
                {
                    IEnumerable<IDnlibDef> enumerable = InjectHelper.Inject(runtimeType, moduleDef.GlobalType, moduleDef);
                    MethodDef methodDef = moduleDef.GlobalType.FindStaticConstructor();
                    MethodDef method2 = (MethodDef)enumerable.Single((IDnlibDef method) => method.Name == "Initialize");
                    methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, method2));
                    foreach (IDnlibDef def in enumerable)
                    {
                        service2.MarkHelper(def, service, (Protection)base.Parent);
                    }
                }
            }
        }
    }
}

Confusser.Runtime
C#:
using System;
using System.Diagnostics;
using System.Timers;

namespace Confuser.Runtime
{
    // Token: 0x0200003A RID: 58
    internal static class AntiProcessHacker
    {
        // Token: 0x060000D0 RID: 208
        private static void Initialize()
        {
            AntiProcessHacker.AntiProcessHacker1();
        }

        // Token: 0x060000D1 RID: 209
        private static void AntiProcessHacker1()
        {
            Timer timer = new Timer();
            timer.Elapsed += AntiProcessHacker.OnTimedEvent;
            timer.Interval = 1.0;
            timer.Enabled = true;
        }

        // Token: 0x060000D2 RID: 210
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            string processName = "ProcessHacker";
            foreach (Process process in Process.GetProcesses())
            {
                if (process.ProcessName == processName)
                {
                    process.Kill();
                }
            }
        }
    }
}
 
Seçkin Üye
Katılım
14 Ara 2019
Mesajlar
325
Çözümler
1
Tepki puanı
18
Ödüller
5
Yaş
28
6 HİZMET YILI
Visual studio ile mi build ediyoruz?
 
Mai Sakurajima
Onaylı Üye
Katılım
26 Şub 2023
Mesajlar
102
Tepki puanı
8
Ödüller
2
Sosyal
3 HİZMET YILI
lan hile yapmak bu kadar mı
 
Uzman Üye
Katılım
13 Ara 2018
Mesajlar
192
Çözümler
1
Tepki puanı
22
Ödüller
8
Yaş
31
7 HİZMET YILI
Bu kod dış DLL’lerin yüklenmesini engeller ve belleğinizi okumaya veya yazmaya çalışan işlemleri tespit eder:

C#:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace AntiCheat
{
    public static class Program
    {
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr GetModuleHandle(string lpModuleName);

        [DllImport("kernel32.dll")]
        private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);

        private delegate bool SetWindowLongDelegate(IntPtr hWnd, int nIndex, int dwNewLong);

        private const int GWL_STYLE = -16;
        private const int WS_SYSMENU = 0x80000;

        [STAThread]
        public static void Main()
        {
            // Dış DLL'lerin yüklenmesini engelleme
            var kernel32 = GetModuleHandle("kernel32.dll");
            var loadLibraryAddress = GetProcAddress(kernel32, "LoadLibraryA");

            uint oldProtect;
            VirtualProtect(loadLibraryAddress, (uint)IntPtr.Size, 0x40 /*PAGE_EXECUTE_READWRITE*/, out oldProtect);
            Marshal.WriteIntPtr(loadLibraryAddress + 2 * IntPtr.Size + 1 * sizeof(int), IntPtr.Zero);
            VirtualProtect(loadLibraryAddress, (uint)IntPtr.Size, oldProtect, out oldProtect);

            // Cheat Engine ve Process Hacker'ı izleme
            var cheatEngine = "cheatengine";
            var processHacker = "processhacker";

            // Arka planda işlemleri izleme
            new System.Threading.Thread(() =>
            {
                while (true)
                {
                    foreach (var process in Process.GetProcesses())
                    {
                        if (process.ProcessName.ToLower().Contains(cheatEngine) || process.ProcessName.ToLower().Contains(processHacker))
                        {
                            MessageBox.Show("Hile yapmak yasaktır!", "Anti-Cheat", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                            Environment.Exit(0);
                        }
                    }

                    System.Threading.Thread.Sleep(1000);
                }
            }).Start();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

Bu kod GetModuleHandle, GetProcAddress ve VirtualProtect gibi Windows API fonksiyonlarını kullanarak dış DLL’lerin yüklenmesini engeller. Kernel32-DLL’deki LoadLibraryA fonksiyonunu boş bir fonksiyonla değiştirir.
 
Onaylı Üye
Katılım
22 Mar 2023
Mesajlar
51
Tepki puanı
2
Ödüller
1
Yaş
27
3 HİZMET YILI
tesekkurler hocam bunu ariyordum bir suredir
 
Tutti mi chiedono perché ho imparato questa lingua
Süper Üye
Katılım
17 Mar 2016
Mesajlar
634
Çözümler
5
Tepki puanı
112
Ödüller
11
10 HİZMET YILI
processName yi direkt == demek yerine contains kullansaydınız daha iyi olabilirdi
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst