// Calculate the V8 version string. void Version::GetString(Vector<char> str) { const char* candidate = IsCandidate() ? " (candidate)" : ""; if (GetPatch() > 0) { OS::SNPrintF(str, "%d.%d.%d.%d%s", GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate); } else { OS::SNPrintF(str, "%d.%d.%d%s", GetMajor(), GetMinor(), GetBuild(), candidate); } }
// Calculate the SONAME for the V8 shared library. void Version::GetSONAME(Vector<char> str) { if (soname_ == NULL || *soname_ == '\0') { // Generate generic SONAME if no specific SONAME is defined. const char* candidate = IsCandidate() ? "-candidate" : ""; if (GetPatch() > 0) { OS::SNPrintF(str, "libv8-%d.%d.%d.%d%s.so", GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate); } else { OS::SNPrintF(str, "libv8-%d.%d.%d%s.so", GetMajor(), GetMinor(), GetBuild(), candidate); } } else { // Use specific SONAME. OS::SNPrintF(str, "%s", soname_); } }
CString CInternetExplorerVersion::GetVersionString(void) { CString csVersion; csVersion.Format("%u.%u.%u.%u", GetMajorVersion(), GetMinorVersion(), GetBuild(), GetSubBuild()); return csVersion; }
void AboutOpera::writeVersion( URL& url ) { OP_STATUS rc; OpString tmp; TRAP(rc, g_languageManager->GetStringL(Str::SI_IDSTR_ABT_VER_INFO_STR, tmp)); if (OpStatus::IsSuccess(rc)) outHeading(url, tmp); url.WriteDocumentData(UNI_L(" <dl>")); TRAP(rc, g_languageManager->GetStringL(Str::SI_IDSTR_ABT_VER_STR, tmp)); if (OpStatus::IsSuccess(rc)) { OpString val; rc = GetVersion(&val); if (OpStatus::IsSuccess(rc)) outRow(url, tmp, val); } TRAP(rc, g_languageManager->GetStringL(Str::SI_IDSTR_ABT_BUILD_STR, tmp)); if (OpStatus::IsSuccess(rc)) { OpString val; rc = GetBuild(&val); if (OpStatus::IsSuccess(rc)) outRow(url, tmp, val); } OpString name; rc = getPlatformDetails(name, tmp); if (OpStatus::IsSuccess(rc)) { OpString label; TRAP(rc, g_languageManager->GetStringL(Str::SI_IDSTR_ABT_PLATFORM_STR, label)); if (OpStatus::IsSuccess(rc)) // platform outRow(url, label, name); TRAP(rc, g_languageManager->GetStringL(Str::SI_IDSTR_ABT_WIN_VER, label)); if (OpStatus::IsSuccess(rc)) // platform version outRow(url, label, tmp); } rc = getToolkitDetails(name, tmp); if (OpStatus::IsSuccess(rc)) outRow(url, name, tmp); if (OpStatus::IsSuccess(getJavaVersion( name, tmp ))) outRow(url, name, tmp); url.WriteDocumentData(UNI_L("\n </dl>\n")); }
BOOL CGetPlayerDataCMD::GetData(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_NOPVP_DATA& stPlayerNoPvpData, DT_PLAYER_PVP_DATA& stPlayerPvpData, UINT16& wErrCode) { //CAutoCycle oAutoCycle(__FUNCTION__); wErrCode = FAIL; if(!GetPlayerBase(poDBConn, dwPlayerID, stPlayerNoPvpData)) { wErrCode = GET_NODATA; //USR_INFO(_SDT("[%s: %d]: GetPlayerBase failed! playerid:%d"), MSG_MARK, dwPlayerID); //新增玩家肯定没有 return FALSE; } if(!GetPlayerTodayConsume(poDBConn, dwPlayerID, stPlayerNoPvpData)) { wErrCode = GET_NODATA; //USR_INFO(_SDT("[%s: %d]: GetPlayerBase failed! playerid:%d"), MSG_MARK, dwPlayerID); //新增玩家肯定没有 return FALSE; } if(!GetPlayerExt(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetPlayerExt failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetBag(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetBag failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetBuild(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetBuild failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetHeroBase(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetHeroBase failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetHeroExt(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetBag GetHeroExt! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetInstance(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetInstance failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetTask(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetTask failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetRelationData(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetRelationData failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetEvenData(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetEvenData failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetSendFlowerLog(poDBConn, dwPlayerID, stPlayerNoPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetSendFlowerLog failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } if(!GetPvp(poDBConn, dwPlayerID, stPlayerPvpData)) { SYS_CRITICAL(_SDT("[%s: %d]: GetPvp failed! playerid:%d"), MSG_MARK, dwPlayerID); return FALSE; } wErrCode = SUCCESS; return TRUE; }
void AuthSocket::HandleChallenge() { // No header if(GetReadBuffer()->GetSize() < 4) return; if(sInfoCore.GetRealmMap().empty()) { // If we lack a realm to connect to, block em, it's better then making them sit and get locked into an empty list. SendChallengeError(CE_IPBAN); return; } // Check the rest of the packet is complete. uint8 * ReceiveBuffer = (uint8*)GetReadBuffer()->GetBufferOffset(); uint16 full_size = *(uint16*)&ReceiveBuffer[2]; DEBUG_LOG("AuthChallenge","got header, body is 0x%02X bytes", full_size); if(GetReadBuffer()->GetSize() < uint32(full_size+4)) return; // Copy the data into our cached challenge structure if(full_size > sizeof(sAuthLogonChallenge_C)) { Disconnect(); return; } DEBUG_LOG("AuthChallenge","got full packet."); GetReadBuffer()->Read(&m_challenge, full_size + 4); // Check client build. if(GetBuild() > LogonServer::getSingleton().max_build) { SendChallengeError(CE_WRONG_BUILD_NUMBER); return; } if(GetBuild() < LogonServer::getSingleton().min_build) { // can we patch? char flippedloc[5] = {0,0,0,0,0}; flippedloc[0] = m_challenge.country[3]; flippedloc[1] = m_challenge.country[2]; flippedloc[2] = m_challenge.country[1]; flippedloc[3] = m_challenge.country[0]; m_patch = PatchMgr::getSingleton().FindPatchForClient(GetBuild(), flippedloc); if(m_patch == NULL) { // could not find a valid patch SendChallengeError(CE_WRONG_BUILD_NUMBER); return; } DEBUG_LOG("Patch", "Selected patch %u%s for client.", m_patch->Version,m_patch->Locality); BigNumber unk; unk.SetRand(128); uint8 response[119] = { 0x00, 0x00, 0x00, 0x72, 0x50, 0xa7, 0xc9, 0x27, 0x4a, 0xfa, 0xb8, 0x77, 0x80, 0x70, 0x22, 0xda, 0xb8, 0x3b, 0x06, 0x50, 0x53, 0x4a, 0x16, 0xe2, 0x65, 0xba, 0xe4, 0x43, 0x6f, 0xe3, 0x29, 0x36, 0x18, 0xe3, 0x45, 0x01, 0x07, 0x20, 0x89, 0x4b, 0x64, 0x5e, 0x89, 0xe1, 0x53, 0x5b, 0xbd, 0xad, 0x5b, 0x8b, 0x29, 0x06, 0x50, 0x53, 0x08, 0x01, 0xb1, 0x8e, 0xbf, 0xbf, 0x5e, 0x8f, 0xab, 0x3c, 0x82, 0x87, 0x2a, 0x3e, 0x9b, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x32, 0xa3, 0x49, 0x76, 0x5c, 0x5b, 0x35, 0x9a, 0x93, 0x3c, 0x6f, 0x3c, 0x63, 0x6d, 0xc0, 0x00 }; Send(response, 119); return; } // Check for a possible IP ban on this client. BAN_STATUS ipb = IPBanner::getSingleton().CalculateBanStatus(GetRemoteAddress()); switch(ipb) { case BAN_STATUS_PERMANENT_BAN: SendChallengeError(CE_ACCOUNT_CLOSED); return; case BAN_STATUS_TIME_LEFT_ON_BAN: SendChallengeError(CE_ACCOUNT_FREEZED); return; default: break; } // Null-terminate the account string if(m_challenge.I_len >= 0x50) { Disconnect(); return; } m_challenge.I[m_challenge.I_len] = 0; AccountName = (char*)&m_challenge.I; string::size_type i = AccountName.rfind("#"); if( i != string::npos ) { printf("# ACCOUNTNAME!\n"); return; } // Look up the account information m_account = AccountMgr::getSingleton().GetAccount(AccountName); if(m_account == 0) { DEBUG_LOG("AuthChallenge","Account Name: \"%s\" - Account state: INVALID", AccountName.c_str()); // Non-existant account SendChallengeError(CE_NO_ACCOUNT); return; } // Check that the account isn't banned. if(m_account->Banned == 1) { SendChallengeError(CE_ACCOUNT_CLOSED); Log.Notice("AuthChallenge","Account Name: \"%s\" - Account state: CLOSED", AccountName.c_str()); return; } else if(m_account->Banned > 0) { SendChallengeError(CE_ACCOUNT_FREEZED); Log.Notice("AuthChallenge","Account Name: \"%s\" - Account state: FROZEN (%u)", AccountName.c_str(), m_account->Banned); return; } else Log.Notice("AuthChallenge","Account Name: \"%s\" - Account state: OK", AccountName.c_str()); // update cached locale if(!m_account->forcedLocale) { char temp[4]; temp[0] = m_challenge.country[3]; temp[1] = m_challenge.country[2]; temp[2] = m_challenge.country[1]; temp[3] = m_challenge.country[0]; *(uint32*)&m_account->Locale[0] = *(uint32*)temp; } Sha1Hash sha; //uint32 tc = s.GetNumBytes(); sha.UpdateData( s.AsByteArray(), 32 ); sha.UpdateData( m_account->SrpHash, 20 ); sha.Finalize(); BigNumber x; x.SetBinary( sha.GetDigest(), sha.GetLength() ); v = g.ModExp(x, N); b.SetRand(152); BigNumber gmod = g.ModExp(b, N); B = ((v * 3) + gmod) % N; ASSERT(gmod.GetNumBytes() <= 32); BigNumber unk; unk.SetRand(128); uint8 response[200]; uint32 c = 0; response[c] = 0; c += 1; response[c] = 0; c += 1; response[c] = CE_SUCCESS; c += 1; memcpy(&response[c], B.AsByteArray(), 32); c += 32; response[c] = 1; c += 1; response[c] = g.AsByteArray()[0]; c += 1; response[c] = 32; c += 1; memcpy(&response[c], N.AsByteArray(), 32); c += 32; memcpy(&response[c], s.AsByteArray(), s.GetNumBytes()); c += s.GetNumBytes(); memcpy(&response[c], unk.AsByteArray(), 16); c += 16; response[c] = 0; c += 1; Send(response, c); DEBUG_LOG("AuthSocket","Sending Success Response"); }
void AuthSocket::HandleReconnectProof() { if( m_account == NULL ) return; // Load sessionkey from account database. QueryResult * result = sLogonSQL->Query ("SELECT SessionKey FROM accounts WHERE acct = %u", m_account->AccountId); if(result) { Field * field = result->Fetch(); K.SetHexStr(field[0].GetString ()); delete result; } else { // Disconnect if the sessionkey invalid or not found DEBUG_LOG("AuthReConnectProof","No matching SessionKey found while user %s tried to login.", AccountName.c_str()); Disconnect(); return; } if(GetBuild() <= 6005) { GetReadBuffer()->Remove(GetWriteBuffer()->GetSize()); if(!m_account->SessionKey) { uint8 buffer[4]; buffer[0] = 3; buffer[1] = 0; buffer[2] = 1; buffer[3] = 0; Send(buffer, 4); } else { uint32 x = 3; Send((const uint8*)&x, 4); } return; } if(GetReadBuffer()->GetSize() < sizeof(sAuthLogonProofKey_C)) return; sAuthLogonProofKey_C lp; GetReadBuffer()->Read(&lp, sizeof(sAuthLogonProofKey_C)); BigNumber A; A.SetBinary(lp.R1, 16); Sha1Hash sha; sha.Initialize(); sha.UpdateData(AccountName); sha.UpdateBigNumbers(&A, &rs, &K, 0); sha.Finalize(); if (!memcmp(sha.GetDigest(), lp.R2, SHA_DIGEST_LENGTH)) { ///- Sending response ByteBuffer pkt; pkt << (uint8) 0x03; //ReconnectProof pkt << (uint8) 0x00; pkt << (uint16) 0x00; // 2 bytes zeros Send(pkt.contents(), uint32(pkt.size())); // we're authenticated now :) m_authenticated = true; DEBUG_LOG("AuthReConnectProof","Authentication Success."); } else DEBUG_LOG("AuthReConnectProof","Authentication Failed."); }
void AuthSocket::HandleReconnectChallenge() { // No header if(GetReadBuffer()->GetSize() < 4) return; // Check the rest of the packet is complete. uint8 * ReceiveBuffer = (uint8*)GetReadBuffer()->GetBufferOffset(); uint16 full_size = *(uint16*)&ReceiveBuffer[2]; DEBUG_LOG("ReconnectChallenge","got header, body is 0x%02X bytes", full_size); if(GetReadBuffer()->GetSize() < (uint32)full_size+4) return; // Copy the data into our cached challenge structure if((size_t)(full_size+4) > sizeof(sAuthLogonChallenge_C)) { Disconnect(); return; } DEBUG_LOG("ReconnectChallenge", "got full packet."); memcpy(&m_challenge, ReceiveBuffer, full_size + 4); GetReadBuffer()->Read(&m_challenge, full_size + 4); // Check client build. if(m_challenge.build > LogonServer::getSingleton().max_build || m_challenge.build < LogonServer::getSingleton().min_build) { SendChallengeError(CE_WRONG_BUILD_NUMBER); return; } // Check for a possible IP ban on this client. BAN_STATUS ipb = IPBanner::getSingleton().CalculateBanStatus(GetRemoteAddress()); switch(ipb) { case BAN_STATUS_PERMANENT_BAN: SendChallengeError(CE_ACCOUNT_CLOSED); return; case BAN_STATUS_TIME_LEFT_ON_BAN: SendChallengeError(CE_ACCOUNT_FREEZED); return; default: break; } // Null-terminate the account string if( m_challenge.I_len >= 50 ) { Disconnect(); return; } m_challenge.I[m_challenge.I_len] = 0; // Look up the account information AccountName = (char*)&m_challenge.I; Log.Notice("ReconnectChallenge","Account Name: \"%s\"", AccountName.c_str()); m_account = AccountMgr::getSingleton().GetAccount(AccountName); if(m_account == 0) { DEBUG_LOG("ReconnectChallenge","Invalid account."); // Non-existant account SendChallengeError(CE_NO_ACCOUNT); return; } // Check that the account isn't banned. if(m_account->Banned == 1) { SendChallengeError(CE_ACCOUNT_CLOSED); Log.Notice("ReconnectChallenge","Account banned state = %u", m_account->Banned); return; } else if(m_account->Banned > 0) { SendChallengeError(CE_ACCOUNT_FREEZED); Log.Notice("ReconnectChallenge","Account banned state = %u", m_account->Banned); return; } else DEBUG_LOG("ReconnectChallenge","Account banned state = %u", m_account->Banned); if(!m_account->SessionKey) { SendChallengeError(CE_SERVER_FULL); return; } /** Mangos figured this out, thanks for the structure. */ ///- Sending response if(GetBuild() <= 6005) { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, m_account->SessionKey, 40); uint8 buffer[20]; MD5_Final(buffer, &ctx); ByteBuffer buf; buf << uint16(2); buf.append(buffer, 20); buf << uint64(0); buf << uint64(0); Send(buf.contents(), 34); } else { ByteBuffer pkt; pkt << (uint8) 0x02; //ReconnectChallenge pkt << (uint8) 0x00; rs.SetRand(16*8); pkt.append(rs.AsByteBuffer()); // 16 bytes random pkt << uint64(0x00) << uint64(0x00); // 16 bytes zeros Send(pkt.contents(), uint32(pkt.size())); } }
void AuthSocket::HandleProof() { if(GetReadBuffer()->GetSize() < sizeof(sAuthLogonProof_C)) return; // patch if(m_patch&&!m_account) { //RemoveReadBufferBytes(75,false); GetReadBuffer()->Remove(75); DEBUG_LOG("AuthLogonProof","Intitiating PatchJob"); uint8 bytes[2] = {0x01,0x0a}; Send(bytes,2); PatchMgr::getSingleton().InitiatePatch(m_patch, this); return; } if(!m_account) return; DEBUG_LOG("AuthLogonProof","Interleaving and checking proof..."); sAuthLogonProof_C lp; GetReadBuffer()->Read(&lp, sizeof(sAuthLogonProof_C)); BigNumber A; A.SetBinary(lp.A, 32); Sha1Hash sha; sha.UpdateBigNumbers(&A, &B, 0); sha.Finalize(); BigNumber u; u.SetBinary(sha.GetDigest(), 20); BigNumber S = (A * (v.ModExp(u, N))).ModExp(b, N); uint8 t[32]; uint8 t1[16]; uint8 vK[40]; memcpy(t, S.AsByteArray(), 32); for (int i = 0; i < 16; i++) { t1[i] = t[i*2]; } sha.Initialize(); sha.UpdateData(t1, 16); sha.Finalize(); for (int i = 0; i < 20; i++) { vK[i*2] = sha.GetDigest()[i]; } for (int i = 0; i < 16; i++) { t1[i] = t[i*2+1]; } sha.Initialize(); sha.UpdateData(t1, 16); sha.Finalize(); for (int i = 0; i < 20; i++) { vK[i*2+1] = sha.GetDigest()[i]; } m_sessionkey.SetBinary(vK, 40); uint8 hash[20]; sha.Initialize(); sha.UpdateBigNumbers(&N, NULL); sha.Finalize(); memcpy(hash, sha.GetDigest(), 20); sha.Initialize(); sha.UpdateBigNumbers(&g, NULL); sha.Finalize(); for (int i = 0; i < 20; i++) { hash[i] ^= sha.GetDigest()[i]; } BigNumber t3; t3.SetBinary(hash, 20); sha.Initialize(); sha.UpdateData((const uint8*)m_account->UsernamePtr->c_str(), (int)m_account->UsernamePtr->size()); sha.Finalize(); BigNumber t4; t4.SetBinary(sha.GetDigest(), 20); sha.Initialize(); sha.UpdateBigNumbers(&t3, &t4, &s, &A, &B, &m_sessionkey, NULL); sha.Finalize(); BigNumber M; M.SetBinary(sha.GetDigest(), 20); // Compare M1 values. if(memcmp(lp.M1, M.AsByteArray(), 20) != 0) { // Authentication failed. //SendProofError(4, 0); SendChallengeError(CE_NO_ACCOUNT); DEBUG_LOG("AuthLogonProof","M1 values don't match."); return; } // Store sessionkey m_account->SetSessionKey(m_sessionkey.AsByteArray()); // OUT_DEBUG("========================\nSession key: "); // for(uint32 z = 0; z < 40; ++z) // OUT_DEBUG("%.2X ", m_account->SessionKey[z]); // OUT_DEBUG("\n========================\n"); // let the client know sha.Initialize(); sha.UpdateBigNumbers(&A, &M, &m_sessionkey, 0); sha.Finalize(); if(GetBuild() <= 6005) { sAuthLogonProof_S proof; proof.cmd = 0x01; proof.error = 0; memcpy(proof.M2, sha.GetDigest(), 20); proof.unk2 = 0; SendPacket( (uint8*) &proof, sizeof(proof) ); } else SendProofError(0, sha.GetDigest()); DEBUG_LOG("AuthLogonProof","Authentication Success."); // we're authenticated now :) m_authenticated = true; // Don't update when IP banned, but update anyway if it's an account ban const char* m_sessionkey_hex = m_sessionkey.AsHexStr(); sLogonSQL->Execute("UPDATE accounts SET lastlogin=NOW(), SessionKey = '%s', lastip='%s' WHERE acct=%u;", m_sessionkey_hex, GetIP(), m_account->AccountId); }