كود:
using SomailProject.Network.Cryptography;
using System;
using System.IO;
using System.Text;
namespace SomailProject.Network.AuthPackets
{
public unsafe class Authentication : Interfaces.IPacket
{
public string Username;
public string Password;
public string Server;
public string MacAddress;
public Authentication()
{
}
public void Deserialize(byte[] buffer)
{
if (buffer.Length == 312)
{
ushort length = BitConverter.ToUInt16(buffer, 0);
if (length == 312)
{
ushort type = BitConverter.ToUInt16(buffer, 2);
byte[] temp = new byte[16];
if (type == 1636)
{
MemoryStream MS = new MemoryStream(buffer);
BinaryReader BR = new BinaryReader(MS);
BR.ReadUInt16();
BR.ReadUInt16();
Username = Encoding.Default.GetString(BR.ReadBytes(32)).Replace("\0", "");
BR.ReadBytes(36);
var PasswordArray = BR.ReadBytes(32);
LoaderEncryption.Decrypt(PasswordArray, 32);
Password = Username;
BR.ReadBytes(32);
Server = Encoding.Default.GetString(BR.ReadBytes(16)).Replace("\0", ""); ;
MacAddress = Encoding.Default.GetString(BR.ReadBytes(12)).Replace("\0", "");
BR.Close();
MS.Close();
}
}
}
// Password == Username
//
}
public byte[] ToArray()
{
throw new NotImplementedException();
}
public void Send(Client.GameState client)
{
throw new NotImplementedException();
}
}
}
namespace SomailProject.Network.Cryptography
{
public class LoaderEncryption
{
private static byte[] Key =
{
180,
152,
187,
196,
231,
208,
204,
120,
177,
164,
184,
77,
9,
125,
114,
49,
9,
191,
20,
122,
9,
39,
123,
17,
115,
222,
188,
120,
109,
9,
65,
206,
85,
10,
29,
215,
143,
108,
231,
114
};
public static void Encrypt(byte[] arr)
{
int length = Key.Length;
for (int i = 0; i < arr.Length; i++)
{
arr[i] ^= Key[i % length];
arr[i] ^= Key[(i + 1) % length];
}
}
public static void Decrypt(byte[] arr, int size)
{
int length = Key.Length;
for (int i = 0; i < size; i++)
{
arr[i] ^= Key[(i + 1) % length];
arr[i] ^= Key[i % length];
}
}
}
}
كود:
// Created by MeGo
// Copyright © 2018 - 2019 TQ Digital
// XMeGo - Project
// XMeGo - 01285338963 // 01068255178
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace XMeGoAntiHackLoR.Packets.Cryptography// متغيرش اسم البروجيكت
{
public class LoaderEncryption
{
private static byte[] Key =
{
4 ,
5 ,
1 ,
3 ,
66 ,
7 ,
77 ,
44 ,
100 ,
228 ,
21 ,
254 ,
234 ,
212 ,
114 ,
141 ,
214 ,
12 ,
55 ,
99 ,
100 ,
7 ,
98 ,
187 ,
190 ,
77 ,
65 ,
55 ,
44 ,
43 ,
21 ,
99
}; // idb
private static byte[] Key2 =
{
6,
4,
1,
7,
2,
33,
77,
66,
65,
44,
21,
254,
43,
212,
90,
44,
214,
12,
56,
99,
67,
7,
87,
99,
0,
77,
43,
11,
44,
22,
21,
99
}; // idb
public static void Encrypt(byte[] arr)
{
int length = Key.Length;
for (int i = 0; i < arr.Length; i++)
{
arr[i] ^= Key[i % length];
arr[i] ^= Key[(i + 1) % length];
}
}
public static void Decrypt(byte[] arr)
{
var len = Encoding.Default.GetString(arr).Replace("\0", "").Length;
for (int i = 0; i < len; ++i)
{
arr[i] ^= Key2[88 * i & 0x1F];
arr[i] ^= Key[32 * i & 0x1C];
}
}
}
}
namespace XMeGoAntiHackLoRx2.Network.Cryptography//متغيرش اسم البروجيكت
{
public class LoaderEncryption
{
private static byte[] Key = { 12, 12, 215, 10, 20, 11, 60, 193, 11, 96, 53, 157, 71, 37, 150, 225, 86, 224, 178, 184, 230, 147, 79, 194, 160, 0, 99, 239, 218, 134, 179, 13, 247, 155, 237, 245, 165, 245, 128, 144 };
public static void Encrypt(byte[] arr)
{
int length = Key.Length;
for (int i = 0; i < arr.Length; i++)
{
arr[i] ^= Key[i % length];
arr[i] ^= Key[(i + 1) % length];
}
}
public static void Decrypt(byte[] arr, int size)
{
int length = Key.Length;
for (int i = 0; i < size; i++)
{
arr[i] ^= Key[(i + 1) % length];
arr[i] ^= Key[i % length];
}
}
}
}
كود:
private static void GameServer_OnClientReceive(byte[] buffer, int length, ClientWrapper obj)
{
if (obj.Connector == null)
{
obj.Disconnect();
}
else
{
GameState connector = obj.Connector as GameState;
if (connector.Exchange)
{
connector.Exchange = false;
connector.Action = (byte)1;
SomailProject.Network.Cryptography.GameCryptography gameCryptography = new SomailProject.Network.Cryptography.GameCryptography(Encoding.Default.GetBytes(Constants.GameCryptographyKey));
byte[] numArray = new byte[length];
Array.Copy((Array)buffer, (Array)numArray, length);
gameCryptography.Decrypt(numArray, length);
bool flag = false;
int offset = 0;
for (int x = 0; x < 80; x++)
{
if (BitConverter.ToInt32(numArray, x) == 128)
{
if (length >= 205)
{
offset = x;
flag = true;
connector.Cryptography.Decrypt(buffer, length - 40);
}
else
{
offset = x;
connector.Cryptography.Decrypt(buffer, length);
}
}
}
int int32 = BitConverter.ToInt32(buffer, offset);
int index1 = offset + 4;
if (int32 != 128)
{
connector.Disconnect(true);
}
else
{
byte[] bytes = new byte[128];
int index2 = 0;
while (index2 < int32)
{
bytes[index2] = buffer[index1];
++index2;
++index1;
}
string PublicKey = Encoding.Default.GetString(bytes);
connector.Cryptography = connector.DHKeyExchange.HandleClientKeyPacket(PublicKey, connector.Cryptography);
if (!flag)
return;
byte[] buffer1 = new byte[40];
Buffer.BlockCopy((Array)buffer, length - 40, (Array)buffer1, 0, 40);
processData(buffer1, 40, connector);
}
}
else
processData(buffer, length, connector);
}
}