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

#define EXPECTED_CLIENT_HEADER 0xDEADBEEF

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

		// Epic direct casts :---DDDD
		m_Header = *reinterpret_cast<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 login, HWID, bans with websockets.

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

			//return RemoteLoginResponse::INVALID_HARDWARE;
		}

		// 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;
		}

		// Assume that they are authorised to use the cheat.
		return RemoteLoginResponse::ACCESS_SPECIAL_USER;
	}

	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;
	}
}