Beispiel #1
0
        private static void GrabPrivateKey(Process proccess)
        {
            Thread.Sleep(1);
            proccess.WaitForInputIdle();

            IntPtr handle = OpenProcess((uint)(ProcessAccessFlags.VMRead | ProcessAccessFlags.QueryInformation), true, (uint)proccess.Id);

            var BaseAddress = (uint)proccess.MainModule.BaseAddress.ToInt32();

            uint mainAdr = 0;

            try
            {
                mainAdr = FindMainAddress(proccess.MainModule.FileName);
            }
            catch { }
            finally
            {
                if (mainAdr != 0)
                {
                    MainPointer = mainAdr;
                    Debug.WriteLine(string.Format("Found MainAddress! {0:X}", MainPointer));
                }
                else
                {
                    Debug.WriteLine("Didn't find MainAddress :(, shutting down...");
                }
            }

            byte[]     buffer  = new byte[0x1000];
            List <int> offsets = new List <int>();

            while (!Terminated)
            {
                Read(handle, GetPointer(handle, BaseAddress + MainPointer, false, 0), buffer);
                for (int i = 0; i < buffer.Length / 4; i++)
                {
                    var dh = BitConverter.ToUInt32(buffer, i * 4);
                    if (CheckPG(handle, dh))
                    {
                        if (!offsets.Contains(i))
                        {
                            if (GetPrivateKey(handle, dh) != null)
                            {
                                GrabberWorkerThreadArgs args = new GrabberWorkerThreadArgs(handle, dh, (byte)offsets.Count);
                                Thread grabberThread         = new Thread(new ParameterizedThreadStart(GrabberThreadWorker));
                                GrabberThreads.Add(grabberThread);
                                grabberThread.Start(args);
                                offsets.Add(i);
                            }
                        }
                    }
                }
                Thread.Sleep(100);
            }
            Terminated = false;
        }
Beispiel #2
0
        private static void GrabberThreadWorker(object pArgs)
        {
            GrabberWorkerThreadArgs args = pArgs as GrabberWorkerThreadArgs;

            try
            {
                Thread.Sleep(10);
                byte[] currentPrivateKey = null;
                while (!Terminated)
                {
                    var newPrivateKey = GetPrivateKey(args.handle, args.DHAddr);
                    if (newPrivateKey == null)
                    {
                        Thread.Sleep(1);
                        continue;
                    }

                    bool changed = true;
                    if (currentPrivateKey != null)
                    {
                        changed = !CompareBytes(currentPrivateKey, newPrivateKey, 128);
                    }

                    if (changed)
                    {
                        Thread.Sleep(10);
                        newPrivateKey = GetPrivateKey(args.handle, args.DHAddr);
                        byte[] key = new byte[newPrivateKey.Length];
                        Buffer.BlockCopy(newPrivateKey, 0, key, 0, newPrivateKey.Length);
                        if (OnKey != null)
                        {
                            OnKey(args.type == 0 ? true : false, key);
                        }

                        Debug.WriteLine(string.Format("{0}PrivateKey:{1}....", args.type == 0 ? "[LoginServer]" : args.type == 1 ? "[GameServer]" : "[Unkown]", BitConverter.ToString(newPrivateKey).Replace('-', ' ').Substring(0, 3 * 8)));
                        currentPrivateKey = newPrivateKey;
                    }
                    Thread.Sleep(1);
                }
            }
            catch (Exception) { }
        }