Mr.DeMo |
12-11-2015 12:58 AM |
Transfer System in forum.vpscairo.win المفرود الموضوع يتثبت =D
نظـام النقـل بيـن السيـرفرات !
هنخـش ع الاضـأفـات علشـان مبحـبش اكلـم كتيـر
هنعمـل NewFolder سميـة اي حـاجا
واعمـل فيـة كـلآس اسـمو
وحـط جـواه دول
كود PHP:
/* Created By MrMazika */ using Conquer_Online_Server.Database; using Conquer_Online_Server.Client; namespace Conquer_Online_Server { public unsafe class Transfer { public static uint IsOnline, cantrans, ScorpenProject, ScorpenProject1; public static bool DTrans = false; public static void ScorpenWork(string server, GameClient client) {
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("accounts").Where("EntityID", client.Entity.UID)) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { cantrans = reader.ReadUInt32("CanTrans"); } } if (cantrans >= 3) { client.MessageBox("Oooh o.o ! you already transfered (3) times so you can`t transfer more for times.", null, null, 0); return; } else if (Constants.ServerName == server) { client.MessageBox("Ooops O.o ! you already in Server " + server + ".", null, null, 0); return; } else { client.MessageBox("Are you sure you want to transfer to " + server + " Server you have [" + (3 - cantrans) + "] times to transfer", (p) => { if (!client.WarehouseOpen && client.WarehousePW != 0) { client.MessageBox(" Make sure you have entered a correct secondary password in the warehouse!", null, null, 0); return; } else { if (client.Entity.ConquerPoints > 2999) { using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("servers").Where("Name", server)) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { IsOnline = reader.ReadUInt32("Online"); } } if (IsOnline == 1) { using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE)) cmd.Update("accounts").Set("server", server) .Where("EntityID", client.Entity.UID).Execute(); cantrans++; using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE)) cmd.Update("accounts").Set("CanTrans", cantrans) .Where("EntityID", client.Entity.UID).Execute(); client.Entity.ConquerPoints -= 2999; client.MessageBox("transfer to server " + server + " [Successfully].", null, null, 0); DTrans = true; } else { //client.Disconnect(); client.MessageBox("transfer to server " + server + " [Falid].", null, null, 0); return; } } else { client.MessageBox("You don't have 2999 CPs.", null, null, 0); return; } } }); } } public static void StatusServers() { using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("servers").Where("Name", "ScorpenProject")) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { ScorpenProject = reader.ReadUInt32("Online"); } } using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("servers").Where("Name", "ScorpenProject1")) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { ScorpenProject1 = reader.ReadUInt32("Online"); } } } } }
واعمـل كـلآس تـاني بـاسم
وحـط دول جواة .
كود PHP:
http://up.top4top.net/downloadf-top4top_76cf679d3e1-rar.html
وبعدين افتح
وحط فيـة الانبسي دا
كود PHP:
http://up.top4top.net/downloadf-top4top_1764d208dc1-rar.html
وبـعديـن افتـح
وبحـث عـن
وقفـلو من السـالب وحـط الكـود دا
كود PHP:
#region Transfer case 2900: { switch (packet[4]) { case 0: { uint[] array = new uint[] { 37, 43 }; byte[] Buffer = new byte[6 + 8 + 5 * array.Length]; Writer.Ushort((ushort)(Buffer.Length - 8), 0, Buffer); Writer.Ushort(2901, 2, Buffer); Buffer[5] = (byte)array.Length; int offset = 6; for (int i = 0; i < array.Length; i++) { Writer.Uint(array[i], offset, Buffer); offset += 4; Buffer[offset] = 1; offset += 1; } client.Send(Buffer); break; } default: PrintPacket(packet); break; } break; } case 2902: { byte serverid = packet[5]; break; } static void AppendConnect(Connect appendConnect, Client.GameClient client) { if (CrossServer.CrossPool.ContainsKey(appendConnect.Identifier)) { TransferCipher.Key = Encoding.ASCII.GetBytes("6D1B73DA0250473496C2845F91FA2A42"); TransferCipher.Salt = Encoding.ASCII.GetBytes("DDA177642131459FBFBD17D9003678A8"); TransferCipher transferCipher = new TransferCipher("127.0.0.1"); uint[] decrypted = transferCipher.Decrypt(new uint[] { appendConnect.Identifier, appendConnect.Identifier });
lock (LoginSyncRoot) { CrossServer.AppendConnect(appendConnect, client); } } else { if (client.LoggedIn) { client.Disconnect(true); return; } bool doLogin = false; lock (LoginSyncRoot) { Database.AccountTable Account = null; if (Kernel.AwaitingPool.TryGetValue(appendConnect.Identifier, out Account)) { if (!Account.MatchKey(appendConnect.Identifier)) { client.Disconnect(false); return; }
client.Account = Account;
if (Account.EntityID == 0) { client.Socket.OverrideTiming = true; client.Send(new Message("NEW_ROLE", "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); return; } if (Kernel.DisconnectPool.ContainsKey(Account.EntityID)) { client.Send(new Message("Please try again after a minute!", "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); return; } VariableVault variables; Database.EntityVariableTable.Load(client.Account.EntityID, out variables); client.Variables = variables;
if (client["banhours"] == 0) { client["banhours"] = -1; client["banreason"] = "Infinite time."; client["banstamp"] = DateTime.Now.AddYears(100); } if (Account.State == Database.AccountTable.AccountState.Banned) { if (client["banhours"] != -1) { DateTime banStamp = client["banstamp"]; if (DateTime.Now > banStamp.AddDays(((int)client["banhours"]) / 24).AddHours(((int)client["banhours"]) % 24)) Account.State = Database.AccountTable.AccountState.Player; } } string Message = ""; if (Account.State == Database.AccountTable.AccountState.Banned) { DateTime banStamp = client["banstamp"]; banStamp = banStamp.AddHours(client["banhours"]); Message = "You are banned for " + client["banhours"] + " hours [until " + banStamp.ToString("HH:mm MM/dd/yyyy") + "]. Reason: " + client["banreason"]; } else if (Account.State == Database.AccountTable.AccountState.NotActivated) Message = "You cannot login until your account is activated."; Kernel.AwaitingPool.Remove(appendConnect.Identifier); if (Message == string.Empty) // ANSWER_OK { Client.GameClient aClient = null; if (Kernel.GamePool.TryGetValue(Account.EntityID, out aClient)) aClient.Disconnect(); Kernel.GamePool.Remove(Account.EntityID); client.Entity = new Entity(EntityFlag.Monster, false); Kernel.GamePool.Add(Account.EntityID, client); doLogin = true; } else { client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); World.Execute<GameClient>((pClient, time) => { pClient.Disconnect(); }, client, 100); } } } if (doLogin) { client.GetLanguages(appendConnect.Language); DoLogin(client); } } } #endregion
وبحـث عـن
كود PHP:
static void AppendConnect(Connect appendConnect
وبدلـو بدا
كود PHP:
static void AppendConnect(Connect appendConnect, Client.GameClient client) { if (CrossServer.CrossPool.ContainsKey(appendConnect.Identifier)) { TransferCipher.Key = Encoding.ASCII.GetBytes("6D1B73DA0250473496C2845F91FA2A42"); TransferCipher.Salt = Encoding.ASCII.GetBytes("DDA177642131459FBFBD17D9003678A8"); TransferCipher transferCipher = new TransferCipher("127.0.0.1"); uint[] decrypted = transferCipher.Decrypt(new uint[] { appendConnect.Identifier, appendConnect.Identifier });
lock (LoginSyncRoot) { CrossServer.AppendConnect(appendConnect, client); } } else { if (client.LoggedIn) { client.Disconnect(true); return; } bool doLogin = false; lock (LoginSyncRoot) { Database.AccountTable Account = null; if (Kernel.AwaitingPool.TryGetValue(appendConnect.Identifier, out Account)) { if (!Account.MatchKey(appendConnect.Identifier)) { client.Disconnect(false); return; }
client.Account = Account;
if (Account.EntityID == 0) { client.Socket.OverrideTiming = true; client.Send(new Message("NEW_ROLE", "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); return; } if (Kernel.DisconnectPool.ContainsKey(Account.EntityID)) { client.Send(new Message("Please try again after a minute!", "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); return; } VariableVault variables; Database.EntityVariableTable.Load(client.Account.EntityID, out variables); client.Variables = variables;
if (client["banhours"] == 0) { client["banhours"] = -1; client["banreason"] = "Infinite time."; client["banstamp"] = DateTime.Now.AddYears(100); } if (Account.State == Database.AccountTable.AccountState.Banned) { if (client["banhours"] != -1) { DateTime banStamp = client["banstamp"]; if (DateTime.Now > banStamp.AddDays(((int)client["banhours"]) / 24).AddHours(((int)client["banhours"]) % 24)) Account.State = Database.AccountTable.AccountState.Player; } } string Message = ""; if (Account.State == Database.AccountTable.AccountState.Banned) { DateTime banStamp = client["banstamp"]; banStamp = banStamp.AddHours(client["banhours"]); Message = "You are banned for " + client["banhours"] + " hours [until " + banStamp.ToString("HH:mm MM/dd/yyyy") + "]. Reason: " + client["banreason"]; } else if (Account.State == Database.AccountTable.AccountState.NotActivated) Message = "You cannot login until your account is activated."; Kernel.AwaitingPool.Remove(appendConnect.Identifier); if (Message == string.Empty) // ANSWER_OK { Client.GameClient aClient = null; if (Kernel.GamePool.TryGetValue(Account.EntityID, out aClient)) aClient.Disconnect(); Kernel.GamePool.Remove(Account.EntityID); client.Entity = new Entity(EntityFlag.Monster, false); Kernel.GamePool.Add(Account.EntityID, client); doLogin = true; } else { client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog)); World.Execute<GameClient>((pClient, time) => { pClient.Disconnect(); }, client, 100); } } } if (doLogin) { client.GetLanguages(appendConnect.Language); DoLogin(client); } } }
واعمـل كـلآس جـديـد بـأسم
وحـط جـواة دول
كود PHP:
using System; using System.Linq; using System.Text; using System.Drawing; using System.Threading.Tasks; using System.Collections.Generic; using System.Runtime.InteropServices; //MrMazika namespace Conquer_Online_Server.Network { public unsafe static class NativeFunctionCalls { public const string MSVCRT = "msvcrt.dll"; public const string KERNEL32 = "kernel32.dll"; [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern unsafe void* malloc(int size); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern unsafe void* calloc(int size); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern unsafe void free(void* memblock); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memset(void* dst, byte fill, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern int memcmp(void* buf1, void* buf2, int count); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(void* dst, void* src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(void* dst, string src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(byte[] dst, void* src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(void* dst, byte[] src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(byte[] dst, byte[] src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(uint[] dst, uint[] src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void* memcpy(byte[] dst, string src, int length); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern unsafe void* realloc(void* ptr, int size); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern void srand(int seed); [DllImport(MSVCRT, CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern short rand(); } public unsafe static class SeedGenerator { public static byte[] Generate(int seed) { byte[] initializationVector = new byte[0x10]; for (int index = 0; index < 0x10; index++) { seed *= 0x343fd; seed += 0x269ec3; initializationVector[index] = (byte)((seed >> 0x10) & 0x7fff); } return initializationVector; } } public unsafe sealed class RivestCipher5 { private const int KEY_SIZE = 4; private const int SEED_SIZE = 16; private const int SUBSTITUTION_SIZE = 26; private const int BITS_SHIFTED = 32; private static byte[] _initializationVector = { 0x3C, 0xDC, 0xFE, 0xE8, 0xC4, 0x54, 0xD6, 0x7E, 0x16, 0xA6, 0xF8, 0x1A, 0xE8, 0xD0, 0x38, 0xBE }; private uint[] _keyBuffer; private uint[] _substitutionBuffer; public RivestCipher5() { GenerateKeys(_initializationVector); } public RivestCipher5(int seed) { GenerateKeys(SeedGenerator.Generate(seed)); } public void GenerateKeys(byte[] initializationVector) { _keyBuffer = new uint[KEY_SIZE]; _substitutionBuffer = new uint[SUBSTITUTION_SIZE]; fixed (uint* keyBufferPtr = _keyBuffer) NativeFunctionCalls.memcpy((byte*)keyBufferPtr, initializationVector, KEY_SIZE * sizeof(uint));
_substitutionBuffer[0] = 0xB7E15163; for (int index = 1; index < SUBSTITUTION_SIZE; index++) _substitutionBuffer[index] = _substitutionBuffer[index - 1] + 0x9E3779B9;
uint substitutionIndex = 0, keyIndex = 0, x = 0, y = 0; for (int loopControlIndex = 0; loopControlIndex < 3 * SUBSTITUTION_SIZE; loopControlIndex++) { _substitutionBuffer[substitutionIndex] = RotateLeft(_substitutionBuffer[substitutionIndex] + x + y, 3); x = _substitutionBuffer[substitutionIndex]; substitutionIndex = (substitutionIndex + 1) % SUBSTITUTION_SIZE; _keyBuffer[keyIndex] = RotateLeft(_keyBuffer[keyIndex] + x + y, (int)(x + y)); y = _keyBuffer[keyIndex]; keyIndex = (keyIndex + 1) % KEY_SIZE; } } public bool Decrypt(byte[] input) { if (input.Length % 8 != 0) return false; uint* buffer = null; fixed (byte* ptr = input) buffer = (uint*)ptr; int rounds = input.Length / 8; for (int index = 0; index < rounds; index++) { uint left = buffer[2 * index]; uint right = buffer[(2 * index) + 1]; for (int subIndex = 12; subIndex > 0; subIndex--) { right = RotateRight(right - _substitutionBuffer[(2 * subIndex) + 1], (int)left) ^ left; left = RotateRight(left - _substitutionBuffer[2 * subIndex], (int)right) ^ right; } uint resultLeft = left - _substitutionBuffer[0]; uint resultRight = right - _substitutionBuffer[1]; buffer[2 * index] = resultLeft; buffer[(2 * index) + 1] = resultRight; } return true; } public bool Encrypt(byte[] input) { if (input.Length % 8 != 0) return false; uint* buffer = null; fixed (byte* ptr = input) buffer = (uint*)ptr; int rounds = input.Length / 8; for (int index = 0; index < rounds; index++) { uint left = buffer[2 * index] + _substitutionBuffer[0]; uint right = buffer[(2 * index) + 1] + _substitutionBuffer[1]; for (int subIndex = 1; subIndex <= 12; subIndex++) { left = RotateLeft(left ^ right, (int)right) + _substitutionBuffer[2 * subIndex]; right = RotateLeft(right ^ left, (int)left) + _substitutionBuffer[(2 * subIndex) + 1]; } buffer[2 * index] = left; buffer[(2 * index) + 1] = right; } return true; } public uint RotateLeft(uint value, int count) { count %= BITS_SHIFTED; uint high = value >> (BITS_SHIFTED - count); return (value << count) | high; } public uint RotateRight(uint value, int count) { count %= BITS_SHIFTED; uint low = value << (BITS_SHIFTED - count); return (value >> count) | low; } } }
وفتـح
وبحـث عـن
كود PHP:
AuthPort = IniFile.ReadUInt16("configuration", "AuthPort")
حـط دول تحتـو
كود PHP:
TransferCipher.Key = Encoding.ASCII.GetBytes("6D1B73DA0250473496C2845F91FA2A42"); TransferCipher.Salt = Encoding.ASCII.GetBytes("DDA177642131459FBFBD17D9003678A8");
ورفع الملف دا علي القاعدة
كود PHP:
http://up.top4top.net/downloadf-top4top_eeba4d48b31-rar.html
واعمـل DeisgnTable علـي ملف accounts علي النـافي كـات وضيـف السطـرين دول
كود PHP:
Server char 255 0 -1 0 0 0 0 0 utf8 utf8_general_ci 0 0 CanTrans bigint 18 0 -1 0 0 0 0 0 0 0
افتـح
وبحث عـن
كود PHP:
void AuthServer_OnClientReceive
وبدل الاكواد بالكـود دا
كود PHP:
private static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3) { var player = arg3.Connector as Client.AuthClient; player.Cryptographer.Decrypt(buffer, length); player.Queue.Enqueue(buffer, length); while (player.Queue.CanDequeue()) { byte[] packet = player.Queue.Dequeue(); ushort len = BitConverter.ToUInt16(packet, 0); ushort id = BitConverter.ToUInt16(packet, 2); if (len == 312) { player.Info = new Authentication(); player.Info.Deserialize(packet); player.Account = new AccountTable(player.Info.Username); Database.ServerInfo Server = null; Forward Fw = new Forward(); if (Database.Server.Servers.TryGetValue(player.Info.Server, out Server)) { if (!player.Account.exists) { Fw.Type = Forward.ForwardType.WrongAccount; player.Send(Fw); } if (player.Account.Password == player.Info.Password && player.Account.exists) { Fw.Type = Forward.ForwardType.Ready; if (player.Account.EntityID == 0) { using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT)) { cmd.Select("configuration").Where("Server", Constants.ServerName); using (MySqlReader r = new MySqlReader(cmd)) { if (r.Read()) { EntityUID = new Counter(r.ReadUInt32("EntityID")); player.Account.EntityID = EntityUID.Next; using (MySqlCommand cmd2 = new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration") .Set("EntityID", player.Account.EntityID) .Where("Server", "COServer")) cmd2.Execute(); player.Account.Save(); } } } } } else { Fw.Type = Forward.ForwardType.InvalidInfo; } if (IPBan.IsBanned(arg3.IP)) { Fw.Type = Forward.ForwardType.Banned; player.Send(Fw); return; } using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("accounts").Where("Username", player.Account.Username)) using (var reader = new MySqlReader(cmd)) if (reader.Read()) player.Account.ServerFRW = reader.ReadString("Server"); if (player.Account.ServerFRW == "") { player.Account.ServerFRW = player.Info.Server; using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE)) cmd.Update("accounts").Set("Server", player.Account.ServerFRW) .Where("Username", player.Account.Username).Execute(); } lock (SyncLogin) { if (Fw.Type == Forward.ForwardType.Ready) { if (player.Info.Server != player.Account.ServerFRW) { Fw.Type = Forward.ForwardType.WrongAccount; player.Send(Fw); return; } else { uint UID = player.Account.EntityID; int time = Time32.Now.GetHashCode(); Fw.Identifier = player.Account.GenerateKey(); Kernel.AwaitingPool[Fw.Identifier] = player.Account; int oldValue; if (!LoginProtection.TryGetValue(UID, out oldValue)) { LoginProtection[UID] = time; TransferCipher transferCipher = new TransferCipher("6D1B73DA0250473496C2845F91FA2A42", "DDA177642131459FBFBD17D9003678A8", "127.0.0.1"); uint[] encrypted = transferCipher.Encrypt(new uint[] { player.Account.EntityID, (uint)player.Account.State }); Fw.Identifier = encrypted[0]; Fw.Identifier = (uint)encrypted[1]; Fw.IP = Server.IP; Fw.Port = Server.Port; //Console.WriteLine("{0} has been successfully transferred to server {1}! IP:[{2}].", //player.Info.Username, player.Info.Server, player.IP); } else { if (time - oldValue < TimeLimit) { Fw.Type = Forward.ForwardType.InvalidAuthenticationProtocol; player.Send(Fw); return; } else { TransferCipher transferCipher = new TransferCipher("6D1B73DA0250473496C2845F91FA2A42", "DDA177642131459FBFBD17D9003678A8", "127.0.0.1"); uint[] encrypted = transferCipher.Encrypt(new uint[] { player.Account.EntityID, (uint)player.Account.State }); Fw.Identifier = encrypted[0]; Fw.Identifier = (uint)encrypted[1]; Fw.IP = Server.IP; Fw.Port = Server.Port; Fw.Identifier = player.Account.EntityID; Kernel.TransferPool.Remove(player.Account.EntityID); //Console.WriteLine("{0} has been successfully transferred to server {1}! IP:[{2}].", //player.Info.Username, player.Info.Server, player.IP); } } } } player.Send(Fw); } } else { Fw.Type = Forward.ForwardType.ServersNotConfigured; player.Send(Fw); return; } } } }
اعمـل كلاس اسمـو
وحط جواة دول
كود PHP:
using System; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections.Generic; //Created By MrMazika namespace Conquer_Online_Server.Database { public unsafe class ServerInfo { public string Name; public string IP; public ushort Port; public string TransferKey; public string TransferSalt; } public unsafe class Server { public static Dictionary<string, ServerInfo> Servers = new Dictionary<string, ServerInfo>(); public static void Load() { using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("Servers")) using (var reader = cmd.CreateReader()) { while (reader.Read()) { ServerInfo serverinfo = new ServerInfo(); serverinfo.Name = reader.ReadString("Name"); serverinfo.IP = reader.ReadString("IP"); serverinfo.Port = reader.ReadUInt16("Port"); serverinfo.TransferKey = reader.ReadString("TransferKey"); serverinfo.TransferSalt = reader.ReadString("TransferSalt"); Servers.Add(serverinfo.Name, serverinfo); string format = "{0} [{1}:{2}]"; Console.WriteLine(string.Format(format, serverinfo.Name, serverinfo.IP, serverinfo.Port)); } } } } }
سـلآموز عفواً لايمكن عرض الروابط إلا بعد الرد على الموضوع
|