void LogonCommHandler::TestConsoleLogon(string& username, string& password, uint32 requestnum)
{
	string newuser = username;
	string newpass = password;
	string srpstr;

	arcemu_TOUPPER(newuser);
	arcemu_TOUPPER(newpass);

	srpstr = newuser + ":" + newpass;

	// Send request packet to server.
	map<LogonServer*, LogonCommClientSocket*>::iterator itr = logons.begin();
	if(logons.size() == 0 || itr->second == 0)
	{
		// No valid logonserver is connected.
		return;
	}

	Sha1Hash hash;
	hash.UpdateData(srpstr);
	hash.Finalize();

	WorldPacket data(RCMSG_TEST_CONSOLE_LOGIN, 100);
	data << requestnum;
	data << newuser;
	data.append(hash.GetDigest(), 20);

	itr->second->SendPacket(&data, false);
}
Пример #2
0
void LogonCommHandler::Startup()
{
	// Try to connect to all logons.
	LoadRealmConfiguration();

	Log.Notice("LogonCommClient", "Loading forced permission strings...");
	QueryResult * result = CharacterDatabase.Query("SELECT * FROM account_forced_permissions");
	if( result != NULL )
	{
		do 
		{
			string acct = result->Fetch()[0].GetString();
			string perm = result->Fetch()[1].GetString();

			arcemu_TOUPPER(acct);
            forced_permissions.insert(make_pair(acct,perm));

		} while (result->NextRow());
		delete result;
	}

	ThreadPool.ExecuteTask( new LogonCommWatcherThread() );
}
Пример #3
0
void AccountMgr::AddAccount(Field* field)
{
    Account* acct = new Account;
    Sha1Hash hash;
    std::string Username = field[1].GetString();
    std::string EncryptedPassword = field[2].GetString();
    std::string GMFlags = field[3].GetString();

    acct->AccountId = field[0].GetUInt32();
    acct->AccountFlags = field[4].GetUInt8();
    acct->Banned = field[5].GetUInt32();
    if ((uint32)UNIXTIME > acct->Banned && acct->Banned != 0 && acct->Banned != 1)   //1 = perm ban?
    {
        //Accounts should be unbanned once the date is past their set expiry date.
        acct->Banned = 0;
        //me go boom :(
        //printf("Account %s's ban has expired.\n",acct->UsernamePtr->c_str());
        sLogonSQL->Execute("UPDATE accounts SET banned = 0 WHERE acct=%u", acct->AccountId);
    }
    acct->SetGMFlags(GMFlags.c_str());
    acct->Locale[0] = 'e';
    acct->Locale[1] = 'n';
    acct->Locale[2] = 'U';
    acct->Locale[3] = 'S';
    if (strcmp(field[6].GetString(), "enUS"))
    {
        // non-standard language forced
        memcpy(acct->Locale, field[6].GetString(), 4);
        acct->forcedLocale = true;
    }
    else
        acct->forcedLocale = false;

    acct->Muted = field[7].GetUInt32();
    if ((uint32)UNIXTIME > acct->Muted && acct->Muted != 0 && acct->Muted != 1)   //1 = perm ban?
    {
        //Accounts should be unbanned once the date is past their set expiry date.
        acct->Muted = 0;
        //LOG_DEBUG("Account %s's mute has expired.",acct->UsernamePtr->c_str());
        sLogonSQL->Execute("UPDATE accounts SET muted = 0 WHERE acct=%u", acct->AccountId);
    }
    // Convert username to uppercase. this is needed ;)
    arcemu_TOUPPER(Username);

    // prefer encrypted passwords over nonencrypted
    if (EncryptedPassword.size() > 0)
    {
        if (EncryptedPassword.size() == 40)
        {
            BigNumber bn;
            bn.SetHexStr(EncryptedPassword.c_str());
            if (bn.GetNumBytes() < 20)
            {
                // Hacky fix
                memcpy(acct->SrpHash, bn.AsByteArray(), bn.GetNumBytes());
                for (int n = bn.GetNumBytes(); n <= 19; n++)
                    acct->SrpHash[n] = (uint8)0;
                reverse_array(acct->SrpHash, 20);
            }
            else
            {
                memcpy(acct->SrpHash, bn.AsByteArray(), 20);
                reverse_array(acct->SrpHash, 20);
            }
        }
        else
        {
            LOG_ERROR("Account `%s` has incorrect number of bytes in encrypted password! Disabling.", Username.c_str());
            memset(acct->SrpHash, 0, 20);
        }
    }
    else
    {
        // This should never happen...
        LOG_ERROR("Account `%s` has no encrypted password!", Username.c_str());
    }

    AccountDatabase[Username] = acct;
}
Пример #4
0
void AccountMgr::ReloadAccounts(bool silent)
{
    setBusy.Acquire();
    if (!silent) sLog.outString("[AccountMgr] Reloading Accounts...");

    // Load *all* accounts.
    QueryResult* result = sLogonSQL->Query("SELECT acct, login, encrypted_password, gm, flags, banned, forceLanguage, muted FROM accounts");
    Field* field;
    std::string AccountName;
    std::set<std::string> account_list;
    Account* acct;

    if (result)
    {
        do
        {
            field = result->Fetch();
            AccountName = field[1].GetString();

            // transform to uppercase
            arcemu_TOUPPER(AccountName);

            //Use private __GetAccount, for locks
            acct = __GetAccount(AccountName);
            if (acct == 0)
            {
                // New account.
                AddAccount(field);
            }
            else
            {
                // Update the account with possible changed details.
                UpdateAccount(acct, field);
            }

            // add to our "known" list
            account_list.insert(AccountName);

        } while (result->NextRow());

        delete result;
    }

    // check for any purged/deleted accounts
    std::map<std::string, Account*>::iterator itr = AccountDatabase.begin();
    std::map<std::string, Account*>::iterator it2;

    for (; itr != AccountDatabase.end();)
    {
        it2 = itr;
        ++itr;

        if (account_list.find(it2->first) == account_list.end())
        {
            delete it2->second;
            AccountDatabase.erase(it2);
        }
        else
        {
            it2->second->UsernamePtr = (std::string*)&it2->first;
        }
    }

    if (!silent) sLog.outString("[AccountMgr] Found %u accounts.", AccountDatabase.size());
    setBusy.Release();

    IPBanner::getSingleton().Reload();
}