From 8e3a4b956e8fcc3ec31240d847a7a630eaf2bba2 Mon Sep 17 00:00:00 2001 From: leak Date: Sun, 19 Feb 2012 13:51:16 +0100 Subject: Core/Warden: Base implementation for Warden functionality Note: The default config file action for clients failing the checks can be changed for each check via the characters.warden_action table Credits to TOM_RUS --- .../shared/Cryptography/WardenKeyGeneration.h | 73 ++++++++++++++++++++++ .../Database/Implementation/LoginDatabase.cpp | 2 +- src/server/shared/Logging/Log.cpp | 24 ++++++- src/server/shared/Logging/Log.h | 3 + src/server/shared/Utilities/Util.cpp | 13 ++++ src/server/shared/Utilities/Util.h | 1 + 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 src/server/shared/Cryptography/WardenKeyGeneration.h (limited to 'src/server/shared') diff --git a/src/server/shared/Cryptography/WardenKeyGeneration.h b/src/server/shared/Cryptography/WardenKeyGeneration.h new file mode 100644 index 00000000000..1a0ef5c515c --- /dev/null +++ b/src/server/shared/Cryptography/WardenKeyGeneration.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2008-2011 TrinityCore + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "SHA1.h" + +#ifndef _WARDEN_KEY_GENERATION_H +#define _WARDEN_KEY_GENERATION_H + +class SHA1Randx { +public: + SHA1Randx(uint8 *buff, uint32 size) { + uint32 taken = size/2; + + sh.Initialize(); + sh.UpdateData(buff,taken); + sh.Finalize(); + + memcpy(o1,sh.GetDigest(),20); + + sh.Initialize(); + sh.UpdateData(buff+taken,size-taken); + sh.Finalize(); + + memcpy(o2,sh.GetDigest(),20); + + memset(o0,0x00,20); + + fillUp(); + } + + void generate(uint8 *buf, uint32 sz) { + for(uint32 i=0;i. */ +#include #include "Util.h" #include "utf8.h" #ifdef USE_SFMT_FOR_RNG @@ -529,3 +530,15 @@ void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) result = ss.str(); } +std::string ByteArrayToHexStr(uint8* bytes, uint32 length) +{ + std::ostringstream ss; + for (uint32 i = 0; i < length; ++i) + { + char buffer[4]; + sprintf(buffer, "%02X ", bytes[i]); + ss << buffer; + } + + return ss.str(); +} diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 684b26eea63..4c2c1936993 100755 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -378,6 +378,7 @@ bool IsIPAddress(char const* ipaddress); uint32 CreatePIDFile(const std::string& filename); void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result); +std::string ByteArrayToHexStr(uint8* bytes, uint32 length); #endif //handler for operations on large flags -- cgit v1.2.3