コード例 #1
0
ファイル: MyWorldDbAccess.cs プロジェクト: hdneo/mxo-hd
        public bool fetchWordList(ref WorldList wl)
        {
            // Doesnt exist by default
            wl.setExistance(false);

            string sqlQuery = "select * from users where username='******' and passwordmd5='"+wl.getPassword()+"';";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr= queryExecuter.ExecuteReader();

            while(dr.Read()){
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int) dr.GetDecimal(0));
                dr.GetBytes(6,0,wl.getPrivateExponent(),0,96);
                dr.GetBytes(5,0,wl.getPublicModulus(),0,96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }

            dr.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance()){
                Output.writeToLogForConsole("[WORLD DB ACCESS] fetchWordList : Player not found on DB with #" + wl.getUsername() + "# and #" + wl.getPassword() + "#");
                conn.Close();
                return false;
            }
            return true;
        }
コード例 #2
0
        public bool fetchWordList(ref WorldList wl)
        {
            conn.Open();
            // Doesnt exist by default
            wl.setExistance(false);

            string sqlQuery = "select * from users where username='******' and passwordmd5='" + wl.getPassword() + "';";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();


            while (dr.Read())
            {
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int)dr.GetDecimal(0));
                dr.GetBytes(6, 0, wl.getPrivateExponent(), 0, 96);
                dr.GetBytes(5, 0, wl.getPublicModulus(), 0, 96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }

            dr.Close();
            conn.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance())
            {
                Output.writeToLogForConsole("[WORLD DB ACCESS] fetchWordList : Player not found on DB with #" + wl.getUsername() + "# and #" + wl.getPassword() + "#");
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: MyAuthDBAccess.cs プロジェクト: hdneo/mxo-hd
        public bool fetchWordList(ref WorldList wl)
        {
            // Doesnt exist by default
            wl.setExistance(false);

            conn.Open();

            string sqlQuery = "SELECT * FROM users WHERE username='******' AND passwordmd5='"+wl.getPassword()+"' LIMIT 1;";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr= queryExecuter.ExecuteReader();

            while(dr.Read()){
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int) dr.GetDecimal(0));
                dr.GetBytes(5,0,wl.getPublicModulus(),0,96);
                dr.GetBytes(6,0,wl.getPrivateExponent(),0,96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }

            dr.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance()){
                String msg = "Player not found on DB with #"+wl.getUsername()+"# and #"+wl.getPassword()+"#";
                Output.WriteLine(msg);
                conn.Close();
                return false;
            }

            // If exist, get the player values

            // Count the values first

            int totalChars = 0;
            string sqlCount = "SELECT charId FROM characters WHERE userId='" + wl.getUserID() + "' AND is_deleted='0' ";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlCount;
            dr= queryExecuter.ExecuteReader();

            while (dr.Read()){
                totalChars++;
            }

            dr.Close();
            wl.getCharPack().setTotalChars(totalChars);

            // Prepare to read characters

            string sqlQueryForChars = "SELECT * FROM characters WHERE userId='" + wl.getUserID() + "' AND is_deleted='0' ";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlQueryForChars;
            dr= queryExecuter.ExecuteReader();

            // Read characters
            while(dr.Read()){

                //totalChars = (int) dr.GetDecimal(8);
                string charName = dr.GetString(4);
                int charId = (int)dr.GetDecimal(0);
                int status = (int)dr.GetDecimal(3);
                int worldId = (int)dr.GetDecimal(2);

                wl.getCharPack().addCharacter(charName,charId,status,worldId);

            }

            dr.Close();

            // Read worlds
            string sqlQueryForWorlds = "SELECT * FROM worlds ORDER BY worldId ASC";
            queryExecuter.CommandText = sqlQueryForWorlds;
            dr= queryExecuter.ExecuteReader();

            while (dr.Read()){

                string worldName = dr.GetString(1);

                int worldId = (int) dr.GetDecimal(0);
                int worldType = (int) dr.GetDecimal(2);
                int worldStatus = (int) dr.GetDecimal(3);
                int worldPopulation = (int) dr.GetDecimal(4);
                wl.getWorldPack().addWorld(worldName,worldId,worldStatus,worldType,worldPopulation);

            }

            dr.Close();

            conn.Close();

            return true;
        }
コード例 #4
0
ファイル: AuthServer.cs プロジェクト: vitalyo7/mxo-hd
        public byte[] processHandleAuth_Request(byte[] data)
        {
            // RSA version check
            byte[] neededRSAV = { 0x04, 0x00, 0x00, 0x00 };
            byte[] packetRSAV = new byte[4];

            // In this packet, RSA starts at offset 3
            ArrayUtils.copy(data, 3, packetRSAV, 0, 4);

            if (!ArrayUtils.equal(neededRSAV, packetRSAV))
            {
                throw new AuthException("Invalid RSA version");
            }

            // Get RSA encrypted blob from the data
            byte [] blob = new byte[128];

            ArrayUtils.copy(data, 44, blob, 0, 128);

            Output.OptWriteLine("-> Encrypted blob received.");

            // Get RSA decrypted blob
            byte[] decryptedBlob = rsa.decryptWithPrivkey(blob);


            Output.OptWriteLine("-> Blob decoded.");



            // Copy the Auth TF key from decoded blob.

            byte [] tfKey = new byte[16];
            ArrayUtils.copy(decryptedBlob, 7, tfKey, 0, 16);

            tf.setIV(blankIV);
            tf.setKey(tfKey);

            // Create the challenge

            challenge = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

            byte[] criptedChallenge = new byte[16];
            tf.encrypt(challenge, criptedChallenge);

            md5edChallenge = md5.digest(challenge);             // Rajko said this

            Output.OptWriteLine(" --> Client TF key: " + StringUtils.bytesToString(tfKey));
            Output.OptWriteLine(" --> MD5(challenge): " + StringUtils.bytesToString(md5edChallenge));
            Output.OptWriteLine(" --> Twofished(challenge): " + StringUtils.bytesToString(criptedChallenge));

            // Copy the encrypted thing to the global variable "Challenge"
            ArrayUtils.copy(criptedChallenge, 0, challenge, 0, 16);

            int nameLength = decryptedBlob.Length - 30;

            byte[] nameB = new byte[nameLength];
            ArrayUtils.copy(decryptedBlob, 29, nameB, 0, nameLength);

            // Set WorldList username
            wl.setUsername(StringUtils.charBytesToString(nameB));

            Output.OptWriteLine("-> User login: " + wl.getUsername());

            byte[] a = new byte [18];
            a[0] = 0x11;             // Size
            a[1] = 0x09;             // Answer opcode
            ArrayUtils.copy(criptedChallenge, 0, a, 2, 16);

            return(a);
        }
コード例 #5
0
ファイル: MyAuthDBAccess.cs プロジェクト: vitalyo7/mxo-hd
        public bool fetchWordList(ref WorldList wl)
        {
            // Doesnt exist by default
            wl.setExistance(false);

            conn.Open();

            string sqlQuery = "SELECT * FROM users WHERE username='******' AND passwordmd5='" + wl.getPassword() + "' LIMIT 1;";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();



            while (dr.Read())
            {
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int)dr.GetDecimal(0));
                dr.GetBytes(5, 0, wl.getPublicModulus(), 0, 96);
                dr.GetBytes(6, 0, wl.getPrivateExponent(), 0, 96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }



            dr.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance())
            {
                String msg = "Player not found on DB with #" + wl.getUsername() + "# and #" + wl.getPassword() + "#";
                Output.WriteLine(msg);
                conn.Close();
                return(false);
            }

            // If exist, get the player values


            // Count the values first

            int    totalChars = 0;
            string sqlCount   = "SELECT charId FROM characters WHERE userId='" + wl.getUserID() + "' AND is_deleted='0' ";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlCount;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                totalChars++;
            }

            dr.Close();
            wl.getCharPack().setTotalChars(totalChars);

            // Prepare to read characters

            string sqlQueryForChars = "SELECT * FROM characters WHERE userId='" + wl.getUserID() + "' AND is_deleted='0' ";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQueryForChars;
            dr = queryExecuter.ExecuteReader();

            // Read characters
            while (dr.Read())
            {
                //totalChars = (int) dr.GetDecimal(8);
                string charName = dr.GetString(4);
                int    charId   = (int)dr.GetDecimal(0);
                int    status   = (int)dr.GetDecimal(3);
                int    worldId  = (int)dr.GetDecimal(2);

                wl.getCharPack().addCharacter(charName, charId, status, worldId);
            }

            dr.Close();


            // Read worlds
            string sqlQueryForWorlds = "SELECT * FROM worlds ORDER BY worldId ASC";

            queryExecuter.CommandText = sqlQueryForWorlds;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                string worldName = dr.GetString(1);

                int worldId         = (int)dr.GetDecimal(0);
                int worldType       = (int)dr.GetDecimal(2);
                int worldStatus     = (int)dr.GetDecimal(3);
                int worldPopulation = (int)dr.GetDecimal(4);
                wl.getWorldPack().addWorld(worldName, worldId, worldStatus, worldType, worldPopulation);
            }

            dr.Close();

            conn.Close();

            return(true);
        }