public GoodChangePassword(EQOAClient ThisClient) { ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(AccountMessageTypes.CHANGE_PASSWORD_RESPONSE)); //Good Password Response ThisClient.ResponsePacket.AddRange(new byte[4]); //4 bytes of padding? ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray((int)1)); //1 is success I believe? 0 is probably failure? Been awhile ThisClient.ResponsePacket.AddRange(new byte[256]); //256 bytes here, assuming a message can go here? Untested SendMessage(ThisClient); }
public void SendMessage(EQOAClient ThisClient) { //Get Packet Length, need to include the 4 bytes for the length also int Length = ThisClient.ResponsePacket.Count + 4; //Add to beginning of List ThisClient.ResponsePacket.InsertRange(0, Utilities.ReturnByteArray(Length)); AsynchronousSocketListener.Send(ThisClient.Handler, ThisClient.ResponsePacket.ToArray()); //Clear messages ThisClient.ClearMessages(); }
public GoodLogin(EQOAClient ThisClient) { ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(AccountMessageTypes.LOGIN_RESPONSE)); //LoginResponse ThisClient.ResponsePacket.AddRange(new byte[72]); //72 bytes of padding ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.AccountID)); //AccountID 4 bytes ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.Result)); //Result 2 bytes ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.AccountStatus)); //acct status 2 bytes ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.Subtime)); //subtime 4 bytes ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.Partime)); //partime 4 bytes ThisClient.ResponsePacket.AddRange(new byte[64]); //64 bytes of padding ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.Subfeatures)); //subfeatures 4 bytes ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(ThisClient.Gamefeatures)); //gamefeatures 4 bytes SendMessage(ThisClient); }
static async public void LoginRequest(EQOAClient ThisClient) { //Get first 2 integers... not sure on their purpose. int Unknown1 = Utilities.ReturnInt(ThisClient.ClientPacket); int Unknown2 = Utilities.ReturnInt(ThisClient.ClientPacket); //Get username //Appears 32 bytes is allocated for username ThisClient.Username = Utilities.ReturnString(ThisClient.ClientPacket, 32); Console.WriteLine($"Username: {ThisClient.Username}"); //Get Encrypted Password //Appears 32 bytes is allocated for encrypted Password ThisClient.EncPassword = Utilities.ReturnString(ThisClient.ClientPacket, 32); Console.WriteLine($"Password: {ThisClient.EncPassword}"); int unknown3 = Utilities.ReturnInt(ThisClient.ClientPacket); //Assuming next 60 bytes are saved for other game types? Unsure but works for now. string GameID = Utilities.ReturnString(ThisClient.ClientPacket, 60); //Do some stuff to verify username and password against database ThisClient.AccountVerified = true; if (ThisClient.AccountVerified == true) { //make packet and send to client for success on authentication //Pretend we are doing work here await Task.Delay(1000); new GoodLogin(ThisClient); } else { //Pretend we are doing work here await Task.Delay(1000); //Client failed to authenticate new BadAttempt(ThisClient); } }
public BadAttempt(EQOAClient ThisClient) { string Response; switch (ThisClient.MessageType) { case AccountMessageTypes.LOGIN_RESPONSE: Response = "Username or Password was incorrect."; break; case AccountMessageTypes.SUBMIT_ACCT_CREATE: Response = "An error occured or username is taken. Please try again and if unsuccessful, try another username. Thank you."; break; case AccountMessageTypes.CHANGE_PASSWORD: Response = "An error occured. Please try again. If this persists try a new password."; break; case AccountMessageTypes.DISABLED_FEATURE: Response = "This option is disabled in order to bring you content faster. If you feel this is an error, please contact the developer team for further assistance."; break; default: Response = "You've managed to do something wrong! Please let the developer team know you received this message."; break; } int StringLength = Response.Length; Console.WriteLine(ThisClient.ResponsePacket); //Response Code ThisClient.ResponsePacket.AddRange(Utilities.ReturnByteArray(AccountMessageTypes.ACCT_CREATE_RESPONSE)); //LoginResponse for (int i = 0; i < 3; i++) { ThisClient.ResponsePacket.AddRange(new byte[4]); } //Add Our message ThisClient.ResponsePacket.AddRange(Encoding.ASCII.GetBytes(Response)); //256 bytes reserved, Add padding for remaining bytes ThisClient.ResponsePacket.AddRange(new byte[256 - StringLength]); //Process Last bit of packet and send SendMessage(ThisClient); }
public static void AcceptCallback(IAsyncResult ar) { // Signal the main thread to continue. allDone.Set(); // Get the socket that handles the client request. Socket listener = (Socket)ar.AsyncState; Socket handler = listener.EndAccept(ar); //Create Client session EQOAClient NewEQOAClient = new EQOAClient((IPEndPoint)handler.RemoteEndPoint, handler); // Create the state object. StateObject state = new StateObject(); state.workSocket = handler; //Add client session state.EQOAStateClient = NewEQOAClient; handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); }
//This happens once you have logged in already, username should be saved to this Client Session static async public void ChangePassword(EQOAClient ThisClient) { Console.WriteLine($"{ThisClient.Username} is attempting to change password...."); int Unknown1 = Utilities.ReturnInt(ThisClient.ClientPacket); int Unknown2 = Utilities.ReturnInt(ThisClient.ClientPacket); // Need to verify old password was correct against database string OldPassword = Utilities.ReturnString(ThisClient.ClientPacket, 32); //Encrypted Old Password //If old Password checks out against database, replace it with new password string NewPassword = Utilities.ReturnString(ThisClient.ClientPacket, 32); //Encrypted New Password Console.WriteLine($"Attempting to change Client Password. Old encrypted Password: {OldPassword}, New Encrypted Password: {NewPassword}"); //Pretend we are doing work here await Task.Delay(1000); //Success new GoodChangePassword(ThisClient); //If Oldpassword verification fails, send failure //new BadAttempt(ThisClient); }
static async public void CreateAccount(EQOAClient ThisClient) { int Header = Utilities.ReturnInt(ThisClient.ClientPacket); //Message header ThisClient.Username = Utilities.ReturnString(ThisClient.ClientPacket, 32); // Username ThisClient.EncPassword = Utilities.ReturnString(ThisClient.ClientPacket, 32); //Encrypted Password //More information to get here possibly... concerns on privacy also? //Name, country, zip birthday //email may be good to gather Console.WriteLine($" Creating account using Username: {ThisClient.Username}"); Console.WriteLine($"Encrypted Password: {ThisClient.EncPassword}"); //Check database for username //If it exists //new BadAttempt(ThisClient); //Pretend we are doing work here await Task.Delay(1000); //If username is free, start saving to database //Should we save connecting ip address and time stamp the login? new GoodCreateAccount(ThisClient); }
public void PreparePacket(EQOAClient ThisClient) { }