summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Login/RemoteLogin.cpp
blob: 7942c3b80806a390b80ec30c2df87a6bb41d94e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <Login/RemoteLogin.hpp>

// Change this whenever a major client update is made.
// NOTE: You must change this on the server as well.
#define CURRENT_CLIENT_HEADER 0x62746324

namespace Login
{
	void RemoteLoginTransaction::Start(const char *Username, const char *Password)
	{
		VMProtectBeginUltra("LoginTransactionStart");

		// Initialise the header with the client header.
		m_Header.m_ClientHeader = CURRENT_CLIENT_HEADER;

		// Initialise the header with the username and password.
		strcpy_s< 128 >(m_Header.m_Username, Username);
		strcpy_s< 128 >(m_Header.m_Password, Password);

		// Initialise the header with the Hardware ID.
		Security::HardwareIdentifier HardwareId = Protection->GetHardwareId();

		WRAP_IF_DEBUG(
			printf("[DEBUG] LoginTransactionStart\n");
			printf("[DEBUG] Processor count: %d\n", HardwareId.m_CpuCount);
			printf("[DEBUG] Processor architecture: %d\n", HardwareId.m_CpuArchitecture);
			printf("[DEBUG] Hard-drive Serial: %llx\n", HardwareId.m_HardDiskSerialHash);

			for(int i = 0; i < 4; ++i)
				printf("[DEBUG] Safety check #%d: %s\n", i, HardwareId.m_SpecialMode[i] ? "TRUE" : "FALSE");
		);

		m_Header.m_HardwareId = fnv::hash_runtime_data((void *)(&HardwareId), sizeof Security::HardwareIdentifier);

		// TODO: Verify integrity of system.
		// 0 for integrity passed, random bit for failure
		m_Header.m_IntegrityBit1 = HardwareId.m_SpecialMode[Security::DEBUGGING_MODE]; 
		m_Header.m_IntegrityBit2 = HardwareId.m_SpecialMode[Security::TEST_BUILD_MODE];
		m_Header.m_IntegrityBit3 = HardwareId.m_SpecialMode[Security::TEST_SIGN_MODE];

		// The checksum bit, the server will check this first to detect possible tampering.
		m_Header.m_IntegrityBit4 = m_Header.m_IntegrityBit1
								 | m_Header.m_IntegrityBit2
								 | m_Header.m_IntegrityBit3;
	
		VMProtectEnd();
	}

	// TODO: Hardware ID check.

	bool RemoteLoginTransaction::TranslateResponse(ByteArray &RawResponse)
	{
		RemoteLoginResponse ServerResponse = *(RemoteLoginResponse *)&RawResponse[0];

		switch(ServerResponse)
		{
			case RemoteLoginResponse::ACCESS_SPECIAL_USER:
				// Allow the user to load special access cheats.
				UserInterface->m_Data.m_SpecialAccess = true;
			case RemoteLoginResponse::ACCESS_AUTHORISED:
				return true;
			case RemoteLoginResponse::OUTDATED_CLIENT:
				INFO_ASSERT(STR("[000A:%llx] Your client is outdated.\nPlease download the latest client at 'moneybot.cc'."), m_Header.m_HardwareId ^ ServerResponse);
				break;
			case RemoteLoginResponse::USER_BANNED:
				INFO_ASSERT(STR("[000D:%llx] Your account is banned.\nPlease contact 'admin@moneybot.cc' for additional information."), m_Header.m_HardwareId ^ ServerResponse);
				break;
			case RemoteLoginResponse::INVALID_HARDWARE:
				INFO_ASSERT(STR("[000D:%llx] Your Hardware-ID is incorrect!\nPlease contact a staff member."), m_Header.m_HardwareId ^ ServerResponse);
				break;
			case RemoteLoginResponse::INVALID_CREDENTIALS:
				INFO_ASSERT(STR("[000C:%llx] Your credentials are invalid. Please check your spelling and try again."), m_Header.m_HardwareId ^ ServerResponse);
				break;
			case RemoteLoginResponse::INTEGRITY_FAILURE:
			case RemoteLoginResponse::NO_SUBSCRIPTION:
				INFO_ASSERT(STR("[0005:%llx] No active subscription found."), m_Header.m_HardwareId ^ ServerResponse);
				break;
		}

		return false;
	}
}