summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-server/Login/RemoteLogin.cpp
blob: 3cc5c77a90b8538468aae8e5d0abe760a71c5972 (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
#include <Login/RemoteLogin.hpp>

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

namespace Login
{
	bool RemoteLoginServer::Start(ByteArray &RawLoginHeader)
	{
		if(RawLoginHeader.empty())
			return false;

		// Epic direct casts :---DDDD
		m_Header = *(RemoteLoginHeader *)&RawLoginHeader[0];
		return true;
	}

	RemoteLoginResponse RemoteLoginServer::GetLoginResponse()
	{
		// The header seems to be wrong, tell the client to update.
		if(m_Header.m_ClientHeader != EXPECTED_CLIENT_HEADER)
			return RemoteLoginResponse::OUTDATED_CLIENT;

		// TODO: Check if the user is banned.
		//return RemoteLoginResponse::USER_BANNED;

		// TODO: Login the user.
		if(strcmp(m_Header.m_Username, "betauser"))
			return RemoteLoginResponse::INVALID_CREDENTIALS;

		if(strcmp(m_Header.m_Password, "betapassword"))
			return RemoteLoginResponse::INVALID_CREDENTIALS;

		// User failed to obtain HWID?
		if(!m_Header.m_HardwareId)
		{
			// TODO: Shadow ban the user.

			return RemoteLoginResponse::INTEGRITY_FAILURE;
		}

		// TODO: Check if the HWID is present in DB.
		if(false)
			return RemoteLoginResponse::INVALID_HARDWARE;

		// TODO: Check if the user has a subscription.
		if(false)
			return RemoteLoginResponse::NO_SUBSCRIPTION;


		// Checksum validation.
		uint8_t Checksum = m_Header.m_IntegrityBit1
					     | m_Header.m_IntegrityBit2
					     | m_Header.m_IntegrityBit3;

		if(Checksum || Checksum != m_Header.m_IntegrityBit4)
		{
			// TODO: Shadow ban the user.

			return RemoteLoginResponse::INTEGRITY_FAILURE;
		}

		// TODO: Check if they have beta access.
		if(true)
			return RemoteLoginResponse::ACCESS_SPECIAL_USER;

		return RemoteLoginResponse::ACCESS_AUTHORISED;
	}

	ByteArray RemoteLoginServer::GetResponse()
	{
		// The way the server handles data transmission is homosexual.
		// That is the only reason this autism is here.
		ByteArray Response;
		Response.push_back(GetLoginResponse());

		return Response;
	}
}