Advertisement
stoneharry

Untitled

Jan 24th, 2013
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1.     // Clear the shitty hash (for server)
  2.     string AccountName = (char*)&m_challenge.I;
  3.     if (AccountName.substr(0, 1) == "?")
  4.     {
  5.         if (AccountName.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?") != string::npos)
  6.         {
  7.             LOG_ERROR("[AuthChallenge]: Tried to create account with illegal characters.");
  8.             SendChallengeError(CE_NO_ACCOUNT); //Well fuck you for editing the files!
  9.             return;
  10.         }
  11.  
  12.         int pass_start = AccountName.find("?", 1) + 1;
  13.         if (pass_start < 4) //No username
  14.         {
  15.             LOG_ERROR("[AuthChallenge] Tried to create account with no account name.");
  16.             SendChallengeError(CE_NO_ACCOUNT);
  17.             return;
  18.         }
  19.  
  20.         int pass_end = AccountName.rfind("?");
  21.         if (pass_end <= pass_start) //No password
  22.         {
  23.             LOG_ERROR("[AuthChallenge] Tried to create account with no password.");
  24.             SendChallengeError(CE_NO_ACCOUNT);
  25.             return;
  26.         }
  27.  
  28.         int name_len = pass_start - 2;
  29.         int pass_len = pass_end - pass_start;
  30.         string username = AccountName.substr(1, name_len);
  31.         string password = AccountName.substr(pass_start, pass_len);
  32.  
  33.         m_account = AccountMgr::getSingleton().GetAccount(username);
  34.         if (m_account != 0)
  35.         {
  36.             LOG_ERROR("[AuthChallenge] Account creation failed: account name already taken.");
  37.             SendChallengeError(CE_ACCOUNT_IN_USE);
  38.             return;
  39.         }
  40.  
  41.         string cmd = username + " " + password + " none"; //Prepare command for CreateAccount
  42.         char acct[50];
  43.  
  44.         memcpy(acct, cmd.c_str(), 50); //CreateAccount doesn't take const char*
  45.         LogonConsole::getSingleton().CreateAccount(acct);
  46.         SendChallengeError(CE_SERVER_FULL); //Success!
  47.         LOG_BASIC("[AuthChallenge] Client %s has created an account with name: \"%s\"", GetRemoteIP().c_str(), username.c_str());
  48.         return;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement