mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Implement FDB Checksum
- Added config option `check_fdb` - Added check in WorldServer.cpp - Added raw MD5 function in MD5.cpp and MD5.h
This commit is contained in:
parent
180db5dea5
commit
49c1cb3aff
@ -115,6 +115,14 @@ MD5::MD5(const std::string &text)
|
||||
finalize();
|
||||
}
|
||||
|
||||
// raw md5 construstor
|
||||
MD5::MD5(const char * input, size_type length)
|
||||
{
|
||||
init();
|
||||
update(input, length);
|
||||
finalize();
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
void MD5::init()
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
|
||||
MD5();
|
||||
MD5(const std::string& text);
|
||||
MD5(const char * input, size_type length);
|
||||
void update(const unsigned char *buf, size_type length);
|
||||
void update(const char *buf, size_type length);
|
||||
MD5& finalize();
|
||||
|
@ -838,7 +838,31 @@ void HandlePacket(Packet* packet) {
|
||||
case MSG_WORLD_CLIENT_VALIDATION: {
|
||||
std::string username = PacketUtils::ReadString(0x08, packet, true);
|
||||
std::string sessionKey = PacketUtils::ReadString(74, packet, true);
|
||||
std::string fdbChecksum = PacketUtils::ReadString(packet->length - 33, packet, false);
|
||||
|
||||
if (bool(std::stoi(Game::config->GetValue("check_fdb")))) {
|
||||
std::ifstream fileStream;
|
||||
fileStream.open ("res/CDServer.fdb", std::ios::binary | std::ios::in);
|
||||
fileStream.seekg (0, std::ios::end);
|
||||
uint64_t fileStreamLength = fileStream.tellg();
|
||||
fileStream.seekg (0, std::ios::beg);
|
||||
char * fileStreamData = new char[fileStreamLength + 1];
|
||||
fileStream.read(fileStreamData, fileStreamLength);
|
||||
|
||||
*(fileStreamData + (fileStreamLength + 1)) = 0x00; // null terminate the string
|
||||
|
||||
MD5 md5 = MD5(fileStreamData, fileStreamLength + 1);
|
||||
std::string ourFdbChecksum = md5.hexdigest();
|
||||
|
||||
Game::logger->Log("WorldServer", "Got client checksum %s and we have server checksum %s. \n", fdbChecksum.c_str(), ourFdbChecksum.c_str());
|
||||
|
||||
if (fdbChecksum != ourFdbChecksum) {
|
||||
Game::logger->Log("WorldServer", "Client checksum does not match server checksum.\n");
|
||||
Game::server->Disconnect(packet->systemAddress, SERVER_DISCON_KICK);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Request the session info from Master:
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_SESSION_KEY);
|
||||
|
@ -47,3 +47,6 @@ solo_racing=0
|
||||
|
||||
# Disables the anti-speedhack system. If you get kicked randomly you might want to disable this, as it might just be lag
|
||||
disable_anti_speedhack=0
|
||||
|
||||
# 0 or 1, check server fdb (res/CDServer.fdb) against clients
|
||||
check_fdb=0
|
Loading…
Reference in New Issue
Block a user