Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Snippet] Warrock Ingame register

Status
Not open for further replies.
Newbie Spellweaver
Joined
May 24, 2009
Messages
35
Reaction score
2
Hello everyone,

So I was managed to fix the ingame register. This works for the most databases. ( It is not recommended to use it, because you will be vulnerable for bot attacks... but sometimes you don't have a other choise... I try to get a register limit and add it to it. )

How to install:

Open loginserver source and search for: HANDLE_LOGIN.cs ( At handlers )
Once you've found that, replace the whole code with the code underneath here, and build the project and try it out!

Code:
using System;
using System.Collections.Generic;
using System.Text;

using LoginServer.Manager;
using LoginServer.Networking.Packets;

namespace LoginServer.Networking.Handlers
{
    class HANDLE_LOGIN : PacketHandler
    {
        private enum LoginState { Success = 1, UnknownUser, InvalidPassword, AlreadyLoggedIn, Banned, Unknown };

        public override void Handle(LoginServer.Virtual_Objects.User.virtualUser Connection)
        {
            DateTime current = DateTime.Now;
            int StartTime = int.Parse(String.Format("{0:yyMMddHH}", current));
            Connection.Username = getBlock(2).ToLower();
            string Password = getBlock(3).ToLower();
            try
            {
                LoginState ReturnValue = LoginState.Unknown;
                int UserID = DB.runRead("SELECT id FROM users WHERE username='" + DB.Stripslash(Connection.Username) + "'", null);
                if (UserID > 0)
                {
                    string[] UserData = DB.runReadRow("SELECT id, username, password, salt, online, nickname, rank, firstlogin, bantime FROM users WHERE id=" + UserID.ToString());
                    if (UserData[2].ToLower() == Password.ToLower())
                    {
                        if (BanManager.isBlocked(UserID) == false && RankManager.HasPermision(int.Parse(UserData[6]), "account.authorize"))
                        {
                            if (UserData[4].Equals("1"))
                            {
                                ReturnValue = LoginState.AlreadyLoggedIn;
                                Connection.send(new PACKET_SERVER_LIST(PACKET_SERVER_LIST.errorCodes.AlreadyLoggedIn));
                                Log.WriteLine("Connection from " + Connection.IPAddress + " logged succesfull in as " + UserData[5] + " but the user is already online.");
                            }
                            else
                            {
                                ReturnValue = LoginState.Success;
                                if (UserData[7].Equals("0"))
                                {
                                    Connection.UserID = UserID;
                                    Connection.send(new PACKET_SERVER_LIST(PACKET_SERVER_LIST.errorCodes.Nickname));
                                    Log.WriteLine("Connection from " + Connection.IPAddress + " logged succesfull in as " + UserData[5] + ".");

                                }
                                else
                                {
                                    Connection.send(new PACKET_SERVER_LIST(int.Parse(UserData[0]), UserData[1], Password, UserData[5], Connection.SessionID, int.Parse(UserData[6])));
                                    Log.WriteLine("Connection from " + Connection.IPAddress + " logged succesfull in as " + UserData[5] + ".");
                                }
                                Program._AcceptedLogins++;
                                Program._PlayerCount++;
                            }
                        }
                        else
                        {
                            if (int.Parse(UserData[8]) > StartTime)
                            {
                                ReturnValue = LoginState.Banned;
                                Connection.send(new PACKET_SERVER_LIST(PACKET_SERVER_LIST.errorCodes.Banned));
                                Log.WriteError("Connection from " + Connection.IPAddress + " failed to login because the account " + UserData[1] + " is disabled/banned.");
                            }
                            else
                            {
                                DB.runQuery("UPDATE users SET rank='1', bantime='-1' WHERE id='" + UserData[0] + "'");
                                Connection.send(new PACKET_SERVER_LIST(int.Parse(UserData[0]), UserData[1], Password, UserData[5], Connection.SessionID, int.Parse(UserData[6])));
                                Log.WriteLine("Connection from " + Connection.IPAddress + " logged succesfull in as " + UserData[5] + ".");
                            }
                        }
                    }
                    else
                    {
                        ReturnValue = LoginState.InvalidPassword;
                        Connection.send(new PACKET_SERVER_LIST(PACKET_SERVER_LIST.errorCodes.WrongPW));
                        Log.WriteError("Connection from " + Connection.IPAddress + " failed to login on the account " + UserData[1] + ".");
                    }
                }
                else
                {
                    UserID = -1;
                    ReturnValue = LoginState.UnknownUser;
                    // Default! >> But this didn't work for me DB.runQuery("INSERT INTO users (username, password, dinar, cash) VALUES ('" + Connection.Username + "', '" + Password + "', '35000', '5000')");
                    DB.runQuery("INSERT INTO users (username, password,  nickname, email, EXP, dinar, cash, kills, deaths, lasthwid) VALUES ('" + Connection.Username + "', '" + Password + "', '" + Connection.Username + "', 'autoregister@gmail.com', '1', '35000', '5000', '0', '0', '0')");
                    Connection.send(new PACKET_SERVER_LIST(PACKET_SERVER_LIST.errorCodes.WrongUser));
                }
                //DB.runQuery("INSERT INTO log_authorize (`time`, `userid`, `username`, `password`, `result`, `ip`, `host`) VALUES ('" + Program.UnixTimestamp + "', '" + UserID + "', '" + DB.Stripslash(Connection.Username) + "', '" + DB.Stripslash(Password) + "', '" + ((int)ReturnValue).ToString() + "', '" + Connection.IPAddress + "', '" + Connection.Hostname + "');");
            }
            catch (Exception ex)
            {
                Connection.disconnect();
                Log.WriteError(ex.Message);
            }
        }

        private static String hashMD5(String Input)
        {
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(Input);
            byte[] hash = md5.ComputeHash(inputBytes);

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("x2"));
            }
            return sb.ToString();
        }
    }
}

Kind regards,
Onny.
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
Re: Warrock Ingame register

The start time isn't correct formatted, it should be a UNIX time-stamp this isn't a UNIX time-stamp.
 
Newbie Spellweaver
Joined
Dec 1, 2007
Messages
98
Reaction score
6
Re: Warrock Ingame register

screens? :)
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
Re: Warrock Ingame register

About what? This just creates an account when one doesn't exist. You can't screenshot this.
 
Newbie Spellweaver
Joined
Dec 1, 2007
Messages
98
Reaction score
6
Re: Warrock Ingame register

About what? This just creates an account when one doesn't exist. You can't screenshot this.

ooh sry, i dont know a f*ck about coding these kind of stuff.. php, mysql and gfx is my knowledge.
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
Re: Warrock Ingame register

ooh sry, i dont know a f*ck about coding these kind of stuff.. php, mysql and gfx is my knowledge.

I think you are missing the point, this is just code that inserts another row in the user table if the account doesn't exist.
It isn't even filtered so anyone can easily do an sql injection in the login.
 
Status
Not open for further replies.
Back
Top