forked from Mirrors/openclonk
Remove C4ConfigShareware to reduce OpenSSL dependency
Conflicts: src/config/C4ConfigShareware.cpp src/config/C4ConfigShareware.h
parent
0e65c78185
commit
a135349703
|
@ -183,8 +183,6 @@ set(OC_CLONK_SOURCES
|
||||||
src/C4Version.h
|
src/C4Version.h
|
||||||
src/config/C4Config.cpp
|
src/config/C4Config.cpp
|
||||||
src/config/C4Config.h
|
src/config/C4Config.h
|
||||||
src/config/C4ConfigShareware.cpp
|
|
||||||
src/config/C4ConfigShareware.h
|
|
||||||
src/config/C4Constants.h
|
src/config/C4Constants.h
|
||||||
src/config/C4Reloc.cpp
|
src/config/C4Reloc.cpp
|
||||||
src/config/C4Reloc.h
|
src/config/C4Reloc.h
|
||||||
|
|
|
@ -173,8 +173,6 @@ src/C4Version.h.in \
|
||||||
src/C4WinMain.cpp \
|
src/C4WinMain.cpp \
|
||||||
src/config/C4Config.cpp \
|
src/config/C4Config.cpp \
|
||||||
src/config/C4Config.h \
|
src/config/C4Config.h \
|
||||||
src/config/C4ConfigShareware.cpp \
|
|
||||||
src/config/C4ConfigShareware.h \
|
|
||||||
src/config/C4Constants.h \
|
src/config/C4Constants.h \
|
||||||
src/config/C4Reloc.cpp \
|
src/config/C4Reloc.cpp \
|
||||||
src/config/C4Reloc.h \
|
src/config/C4Reloc.h \
|
||||||
|
|
|
@ -611,7 +611,6 @@ IDS_ERR_TITLE=Fehler
|
||||||
IDS_ERR_UNKNOWNCMD=Unbekannter Befehl: "%s" - Befehl /help für eine Liste gültiger Befehle
|
IDS_ERR_UNKNOWNCMD=Unbekannter Befehl: "%s" - Befehl /help für eine Liste gültiger Befehle
|
||||||
IDS_ERR_HELPCMD=Grundlegende Befehle im IRC-Chat:|/join [Chatraum] - Neuen Chatraum betreten|/part - Diesen Chatraum verlassen|/notice [Benutzer] [Nachricht] - Sende eine Nachricht an den Benutzer|/query [Benutzer] - Öffne ein neues Chatfenster für einen privaten Dialog mit dem Benutzer|/msg [Benutzer] [Nachricht] - Dasselbe wie /query, nur dass bereits die erste Nachrich geschickt wird|/nick [Neuer Spitzname] - Wähle einen neuen Spitznamen|/quit - Chat ganz verlassen|/raw - Raw-Kommando senden
|
IDS_ERR_HELPCMD=Grundlegende Befehle im IRC-Chat:|/join [Chatraum] - Neuen Chatraum betreten|/part - Diesen Chatraum verlassen|/notice [Benutzer] [Nachricht] - Sende eine Nachricht an den Benutzer|/query [Benutzer] - Öffne ein neues Chatfenster für einen privaten Dialog mit dem Benutzer|/msg [Benutzer] [Nachricht] - Dasselbe wie /query, nur dass bereits die erste Nachrich geschickt wird|/nick [Neuer Spitzname] - Wähle einen neuen Spitznamen|/quit - Chat ganz verlassen|/raw - Raw-Kommando senden
|
||||||
IDS_ERR_USERCANCEL=Benutzerabbruch
|
IDS_ERR_USERCANCEL=Benutzerabbruch
|
||||||
IDS_ERR_WARNINGYOUWERETRYINGTOSEN=ACHTUNG: Du hast versucht, Deinen persönlichen WebCode an eine unbekannte Person zu versenden. Dieser Code darf unter keinen Umständen an andere Personen weiter gegeben werden, da diese damit Deine persönliche Online-Konten stehlen könnten.||Clonk-Administratoren würden Dich nie nach Deinem WebCode oder anderen Passwörtern fragen.
|
|
||||||
IDS_ERR_WRITENEWTITLE=Fehler beim Speichern des neuen Titels in Datei "%s": %s
|
IDS_ERR_WRITENEWTITLE=Fehler beim Speichern des neuen Titels in Datei "%s": %s
|
||||||
IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN=Du wurdest per Abstimmung aus dem Spiel entfernt. (%s)
|
IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN=Du wurdest per Abstimmung aus dem Spiel entfernt. (%s)
|
||||||
IDS_ERR_YOUSURRENDEREDTHELEAGUEGA=Du hast das Ligaspiel aufgegeben.
|
IDS_ERR_YOUSURRENDEREDTHELEAGUEGA=Du hast das Ligaspiel aufgegeben.
|
||||||
|
|
|
@ -610,7 +610,6 @@ IDS_ERR_TITLE=Error
|
||||||
IDS_ERR_UNKNOWNCMD=Unknown command: "%s" - type /help to get a list of valid commands
|
IDS_ERR_UNKNOWNCMD=Unknown command: "%s" - type /help to get a list of valid commands
|
||||||
IDS_ERR_HELPCMD=Basic commands in the IRC-chat:|/join [channel] - Enter a new chat room|/part - Leave this chat room|/notice [user] [message] - Send a message to the user|/query [user] - Open a new chat window to chat for chatting with the user|/msg [user] [message] - The same as /query, only that the first message is already sent|/nick [new nick name] - Choose a new nick name|/quit - Exit the chat|/raw - Send a raw command
|
IDS_ERR_HELPCMD=Basic commands in the IRC-chat:|/join [channel] - Enter a new chat room|/part - Leave this chat room|/notice [user] [message] - Send a message to the user|/query [user] - Open a new chat window to chat for chatting with the user|/msg [user] [message] - The same as /query, only that the first message is already sent|/nick [new nick name] - Choose a new nick name|/quit - Exit the chat|/raw - Send a raw command
|
||||||
IDS_ERR_USERCANCEL=User abort
|
IDS_ERR_USERCANCEL=User abort
|
||||||
IDS_ERR_WARNINGYOUWERETRYINGTOSEN=WARNING: you were trying to send your secret WebCode to a stranger on the internet. You should NEVER give your WebCode to anyone, because they could use it to steal your online accounts!||Clonk administrators will never ask you for any passwords or your WebCode.
|
|
||||||
IDS_ERR_WRITENEWTITLE=Error writing new title for file "%s": %s
|
IDS_ERR_WRITENEWTITLE=Error writing new title for file "%s": %s
|
||||||
IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN=You have been removed by vote. (%s)
|
IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN=You have been removed by vote. (%s)
|
||||||
IDS_ERR_YOUSURRENDEREDTHELEAGUEGA=You have surrendered the league game.
|
IDS_ERR_YOUSURRENDEREDTHELEAGUEGA=You have surrendered the league game.
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#ifndef INC_C4Application
|
#ifndef INC_C4Application
|
||||||
#define INC_C4Application
|
#define INC_C4Application
|
||||||
|
|
||||||
#include <C4ConfigShareware.h>
|
|
||||||
#include <C4Group.h>
|
#include <C4Group.h>
|
||||||
#include <C4MusicSystem.h>
|
#include <C4MusicSystem.h>
|
||||||
#include <C4SoundSystem.h>
|
#include <C4SoundSystem.h>
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "StdResStr2.h"
|
#include "StdResStr2.h"
|
||||||
#include "C4Log.h"
|
#include "C4Log.h"
|
||||||
#include "C4Reloc.h"
|
#include "C4Reloc.h"
|
||||||
|
#include "C4Config.h"
|
||||||
|
|
||||||
#include "C4Game.h"
|
#include "C4Game.h"
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include <C4Group.h>
|
#include <C4Group.h>
|
||||||
#include <C4Version.h>
|
#include <C4Version.h>
|
||||||
#include <C4Update.h>
|
#include <C4Update.h>
|
||||||
#include <C4ConfigShareware.h>
|
|
||||||
#include <StdRegistry.h>
|
#include <StdRegistry.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <C4windowswrapper.h>
|
#include <C4windowswrapper.h>
|
||||||
|
@ -463,10 +462,6 @@ int main(int argc, char *argv[])
|
||||||
// Program info
|
// Program info
|
||||||
LogF("OpenClonk C4Group %s", C4VERSION);
|
LogF("OpenClonk C4Group %s", C4VERSION);
|
||||||
|
|
||||||
// Registration check
|
|
||||||
/* Config.Init();
|
|
||||||
Config.Load(false);*/
|
|
||||||
|
|
||||||
// Init C4Group
|
// Init C4Group
|
||||||
C4Group_SetSortList(C4CFN_FLS);
|
C4Group_SetSortList(C4CFN_FLS);
|
||||||
|
|
||||||
|
|
|
@ -800,3 +800,5 @@ void C4Config::ExpandEnvironmentVariables(char *strPath, size_t iMaxLen)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C4Config Config;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "C4Constants.h"
|
#include "C4Constants.h"
|
||||||
#include "C4InputValidation.h"
|
#include "C4InputValidation.h"
|
||||||
|
#include "C4PlayerControl.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#define C4DEFAULT_FONT_NAME "Endeavour"
|
#define C4DEFAULT_FONT_NAME "Endeavour"
|
||||||
|
@ -288,6 +289,6 @@ public:
|
||||||
static void ExpandEnvironmentVariables(char *strPath, size_t iMaxLen);
|
static void ExpandEnvironmentVariables(char *strPath, size_t iMaxLen);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <C4ConfigShareware.h>
|
extern C4Config Config;
|
||||||
|
|
||||||
#endif // INC_C4Config
|
#endif // INC_C4Config
|
||||||
|
|
|
@ -1,513 +0,0 @@
|
||||||
/*
|
|
||||||
* OpenClonk, http://www.openclonk.org
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003-2004, 2007-2008 Matthes Bender
|
|
||||||
* Copyright (c) 2004-2005, 2007, 2009 Günther Brammer
|
|
||||||
* Copyright (c) 2007 Julian Raschke
|
|
||||||
* Copyright (c) 2007 Peter Wortmann
|
|
||||||
* Copyright (c) 2009 Nicolas Hake
|
|
||||||
* Copyright (c) 2010 Benjamin Herr
|
|
||||||
* Copyright (c) 2010 Sven Eberhardt
|
|
||||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
||||||
*
|
|
||||||
* Portions might be copyrighted by other authors who have contributed
|
|
||||||
* to OpenClonk.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
* See isc_license.txt for full license and disclaimer.
|
|
||||||
*
|
|
||||||
* "Clonk" is a registered trademark of Matthes Bender.
|
|
||||||
* See clonk_trademark_license.txt for full license.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <C4Include.h>
|
|
||||||
#include <C4ConfigShareware.h>
|
|
||||||
#include <C4SecurityCertificates.h>
|
|
||||||
#include <C4Log.h>
|
|
||||||
#include <C4Gui.h>
|
|
||||||
|
|
||||||
#include <StdFile.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_IO_H
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
// this disables registration checking!
|
|
||||||
#ifdef _WIN32
|
|
||||||
//#define C4CHECKMEMLEAKS 1
|
|
||||||
#else
|
|
||||||
// Do not disable registration checking
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <openssl/md5.h>
|
|
||||||
|
|
||||||
#ifndef C4CHECKMEMLEAKS
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/objects.h>
|
|
||||||
#include <openssl/x509.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/pem.h>
|
|
||||||
|
|
||||||
// OpenSSL / Key file handling helpers
|
|
||||||
|
|
||||||
// Loads a public key from memory. The parameter provided must point to a certificate in memory.
|
|
||||||
// If generated by certscramble.pl, the certificate needs to be de-base64ed and de-XORed first.
|
|
||||||
// The loaded public key has to be cleared using clearPublicKey after use.
|
|
||||||
|
|
||||||
EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR = false, const char *strXOR = 0)
|
|
||||||
{
|
|
||||||
const int maxKeyDataLen = 2048;
|
|
||||||
unsigned char keyData[maxKeyDataLen + 1];
|
|
||||||
unsigned int keyDataLen;
|
|
||||||
memset(keyData, 0, maxKeyDataLen + 1);
|
|
||||||
|
|
||||||
// De-base64 certificate
|
|
||||||
if (deBase64)
|
|
||||||
{
|
|
||||||
// The man page says that the data memKey points to will not be modified by this
|
|
||||||
BIO* memBio = BIO_new_mem_buf(const_cast<char *>(memKey), strlen(memKey));
|
|
||||||
BIO* b64Bio = BIO_new(BIO_f_base64());
|
|
||||||
BIO* bio = BIO_push(b64Bio, memBio);
|
|
||||||
(void) BIO_flush(bio);
|
|
||||||
keyDataLen = BIO_read(bio, keyData, maxKeyDataLen * 2);
|
|
||||||
BIO_free_all(bio);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
keyDataLen = strlen(memKey);
|
|
||||||
memcpy(keyData, memKey, keyDataLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-XOR certificate
|
|
||||||
if (deXOR)
|
|
||||||
{
|
|
||||||
int xorStrLen = strlen(strXOR);
|
|
||||||
for (unsigned int i = 0; i < keyDataLen; i++)
|
|
||||||
keyData[i] = keyData[i] ^ strXOR[i % xorStrLen];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load public key from certificate
|
|
||||||
BIO* mbio = BIO_new_mem_buf(keyData, -1);
|
|
||||||
X509* cert = PEM_read_bio_X509(mbio, NULL, NULL, NULL);
|
|
||||||
if (!cert) return 0;
|
|
||||||
BIO_free(mbio);
|
|
||||||
EVP_PKEY* pubKey = X509_get_pubkey(cert);
|
|
||||||
X509_free(cert);
|
|
||||||
|
|
||||||
// Return public key
|
|
||||||
return pubKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearPublicKey(EVP_PKEY* pubKey)
|
|
||||||
{
|
|
||||||
EVP_PKEY_free(pubKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifies the specified block of data using the public key provided.
|
|
||||||
// The block of data is assumed to include a base64-ed signature separated
|
|
||||||
// from data by a double-linefeed delimier.
|
|
||||||
|
|
||||||
int verifyData(char *data, unsigned int dataLen, EVP_PKEY* pubKey)
|
|
||||||
{
|
|
||||||
// Invalid parameters
|
|
||||||
if (!data || !dataLen || !pubKey)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// Find delimiter in data
|
|
||||||
char* pDelimiter = 0;
|
|
||||||
for (char* pBack = data + dataLen - 4; pBack >= data; pBack--)
|
|
||||||
if (memcmp(pBack, "\r\n\r\n", 4) == 0)
|
|
||||||
{
|
|
||||||
pDelimiter = pBack;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!pDelimiter) return -1; //return error("No delimiter found in data to verify.");
|
|
||||||
unsigned int dataOnlyLen = pDelimiter - data;
|
|
||||||
|
|
||||||
// De-base64 signature on registration key
|
|
||||||
unsigned char* b64Sig = (unsigned char*) pDelimiter + 4;
|
|
||||||
unsigned int b64SigLen = dataLen - dataOnlyLen - 4;
|
|
||||||
BIO* memBio = BIO_new_mem_buf(b64Sig, b64SigLen);
|
|
||||||
BIO* b64Bio = BIO_new(BIO_f_base64());
|
|
||||||
BIO* bio = BIO_push(b64Bio, memBio);
|
|
||||||
(void) BIO_flush(bio);
|
|
||||||
const int MAXSIGLEN = 1024;
|
|
||||||
unsigned char sig[MAXSIGLEN] = "";
|
|
||||||
unsigned int sigLen = BIO_read(bio, sig, MAXSIGLEN * 2);
|
|
||||||
BIO_free_all(bio);
|
|
||||||
|
|
||||||
// Verify signature
|
|
||||||
EVP_MD_CTX digest;
|
|
||||||
EVP_VerifyInit(&digest, EVP_sha1());
|
|
||||||
EVP_VerifyUpdate(&digest, data, dataOnlyLen);
|
|
||||||
int err = EVP_VerifyFinal(&digest, sig, sigLen, pubKey);
|
|
||||||
if (err != 1)
|
|
||||||
return -1;
|
|
||||||
EVP_MD_CTX_cleanup(&digest);
|
|
||||||
|
|
||||||
// Data is valid
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows clipboard handling
|
|
||||||
|
|
||||||
bool getClipboardText(char *pBuffer, int iBufferSize)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (!IsClipboardFormatAvailable(CF_TEXT)) return false;
|
|
||||||
if (!OpenClipboard(NULL)) return false;
|
|
||||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
|
||||||
LPVOID pData = GlobalLock(hData);
|
|
||||||
strncpy(pBuffer, (const char*) pData, iBufferSize); pBuffer[iBufferSize] = 0;
|
|
||||||
GlobalUnlock(pData);
|
|
||||||
CloseClipboard();
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif // C4CHECKMEMLEAKS
|
|
||||||
|
|
||||||
// Old-style string scrambling
|
|
||||||
|
|
||||||
#define ScrambleDefaultKey "_D.lp/8f3_ 3 ] =h16%2"
|
|
||||||
|
|
||||||
const char ScrambleMark = '£',
|
|
||||||
ScrambleRangeLow = '0',
|
|
||||||
ScrambleRangeHi = 'z';
|
|
||||||
|
|
||||||
void ScrambleString(char *szString, int iLen, const char *szKey)
|
|
||||||
{
|
|
||||||
if (!szString || !szKey) return;
|
|
||||||
char *cpString = szString;
|
|
||||||
const char *cpKey = szKey;
|
|
||||||
int iChar,iEscSequence=0;
|
|
||||||
if (iLen<0) iLen=SLen(szString);
|
|
||||||
while (iLen>0)
|
|
||||||
{
|
|
||||||
// Detect character escape sequences
|
|
||||||
if (*cpString=='\\') iEscSequence=2;
|
|
||||||
// Process character
|
|
||||||
if (!iEscSequence)
|
|
||||||
{
|
|
||||||
// Scramble range
|
|
||||||
if (Inside(*cpString,ScrambleRangeLow,ScrambleRangeHi))
|
|
||||||
{
|
|
||||||
// Shift character
|
|
||||||
iChar= ((int) *cpString) + (BoundBy(*cpKey,ScrambleRangeLow,ScrambleRangeHi)-ScrambleRangeLow);
|
|
||||||
if (iChar>ScrambleRangeHi) iChar-=(ScrambleRangeHi-ScrambleRangeLow+1);
|
|
||||||
*cpString = (char) iChar;
|
|
||||||
// Advance key
|
|
||||||
cpKey++; if (!(*cpKey)) cpKey=szKey;
|
|
||||||
}
|
|
||||||
// Postconvert backslash
|
|
||||||
if (*cpString=='\\') *cpString='ø';
|
|
||||||
}
|
|
||||||
// Advance
|
|
||||||
cpString++; iLen--; if (iEscSequence) iEscSequence--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnscrambleString(char *szString/*, int iLen, const char *szKey*/)
|
|
||||||
{
|
|
||||||
int iLen=-1;
|
|
||||||
const char *szKey = ScrambleDefaultKey;
|
|
||||||
|
|
||||||
if (!szString || !szKey) return;
|
|
||||||
char *cpString = szString;
|
|
||||||
const char *cpKey = szKey;
|
|
||||||
int iChar,iEscSequence=0;
|
|
||||||
if (iLen<0) iLen=SLen(szString);
|
|
||||||
while (iLen>0)
|
|
||||||
{
|
|
||||||
// Detect character escape sequences
|
|
||||||
if (*cpString=='\\') iEscSequence=2;
|
|
||||||
// Process character
|
|
||||||
if (!iEscSequence)
|
|
||||||
{
|
|
||||||
// Preconvert backslash
|
|
||||||
if (*cpString=='ø') *cpString='\\';
|
|
||||||
// Scramble range
|
|
||||||
if (Inside(*cpString,ScrambleRangeLow,ScrambleRangeHi))
|
|
||||||
{
|
|
||||||
// Unshift character
|
|
||||||
iChar= ((int) *cpString) - (BoundBy(*cpKey,ScrambleRangeLow,ScrambleRangeHi)-ScrambleRangeLow);
|
|
||||||
if (iChar<ScrambleRangeLow) iChar+=(ScrambleRangeHi-ScrambleRangeLow+1);
|
|
||||||
*cpString = (char) iChar;
|
|
||||||
// Advance key
|
|
||||||
cpKey++; if (!(*cpKey)) cpKey=szKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cpString++; iLen--; if (iEscSequence) iEscSequence--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define IDS_SEC_FREEFOLDERMAKER "£6ydHdln zhWijn"
|
|
||||||
#define IDS_SEC_FREEFOLDERS "£8>t`giiW.fcf>ECs;.P5l;OS>sV.X4nqNIyeoCrq.P5l;YS;lUh.c<Q>6afeU.cAS<SenIys.TtfC8dTs.f4H;QfogmkG.w4W0Mq^vMoqs.E4s"
|
|
||||||
|
|
||||||
const char *LoadSecStr(const char *szString)
|
|
||||||
{
|
|
||||||
static char szBuf[1024+1];
|
|
||||||
SCopy(szString,szBuf);
|
|
||||||
UnscrambleString(szBuf);
|
|
||||||
return szBuf+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
C4ConfigShareware::C4ConfigShareware()
|
|
||||||
{
|
|
||||||
RegistrationValid = false;
|
|
||||||
RegData[0] = 0;
|
|
||||||
KeyFile[0] = 0;
|
|
||||||
InvalidKeyFile[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
C4ConfigShareware::~C4ConfigShareware()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4ConfigShareware::Default()
|
|
||||||
{
|
|
||||||
RegistrationValid = false;
|
|
||||||
*RegData = 0;
|
|
||||||
*KeyFile = 0;
|
|
||||||
*InvalidKeyFile = 0;
|
|
||||||
C4Config::Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::Load(bool forceWorkingDirectory, const char *szCustomFile)
|
|
||||||
{
|
|
||||||
// Load standard config
|
|
||||||
if (!C4Config::Load(forceWorkingDirectory, szCustomFile)) return false;
|
|
||||||
// Load registration
|
|
||||||
LoadRegistration();
|
|
||||||
// Done
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::Save()
|
|
||||||
{
|
|
||||||
// Save standard config
|
|
||||||
if (!C4Config::Save()) return false;
|
|
||||||
// Done
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::Registered()
|
|
||||||
{
|
|
||||||
return RegistrationValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::LoadRegistration()
|
|
||||||
{
|
|
||||||
// Reset error message(s)
|
|
||||||
RegistrationError.Clear();
|
|
||||||
|
|
||||||
// First look in configured KeyPath
|
|
||||||
if (Security.KeyPath[0])
|
|
||||||
{
|
|
||||||
char searchPath[_MAX_PATH] = "";
|
|
||||||
SCopy(GetKeyPath(), searchPath);
|
|
||||||
for (DirectoryIterator i(searchPath); *i; ++i)
|
|
||||||
if (WildcardMatch("*.c4k", *i))
|
|
||||||
{
|
|
||||||
if (LoadRegistration(*i))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
SCopy(*i, InvalidKeyFile, CFG_MaxString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then look in ExePath
|
|
||||||
for (DirectoryIterator i(General.ExePath.getData()); *i; ++i)
|
|
||||||
if (WildcardMatch("*.c4k", *i))
|
|
||||||
{
|
|
||||||
if (LoadRegistration(*i))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
SCopy(*i, InvalidKeyFile, CFG_MaxString);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No key file found
|
|
||||||
return HandleError("No valid key file found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::LoadRegistration(const char *keyFile)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef C4CHECKMEMLEAKS
|
|
||||||
// Set registered flag
|
|
||||||
RegistrationValid = true;
|
|
||||||
SCopy("Debug User", General.Name);
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Clear registered flag, general name, and key file names
|
|
||||||
RegistrationValid = false;
|
|
||||||
General.Name[0] = 0;
|
|
||||||
KeyFile[0] = 0;
|
|
||||||
InvalidKeyFile[0] = 0;
|
|
||||||
|
|
||||||
// Load registration key
|
|
||||||
char* delim = 0;
|
|
||||||
int regKeyLen = 0;
|
|
||||||
FILE* fh = fopen(keyFile, "rb");
|
|
||||||
if (!fh)
|
|
||||||
return HandleError("Cannot open key file.");
|
|
||||||
regKeyLen = fread(RegData, 1, MaxRegDataLen, fh);
|
|
||||||
fclose(fh);
|
|
||||||
delim = strstr(RegData, "\r\n\r\n");
|
|
||||||
if (!delim)
|
|
||||||
return HandleError("Invalid key data (no delimiter).");
|
|
||||||
|
|
||||||
// Load public key from memory
|
|
||||||
EVP_PKEY* pubKey = loadPublicKey(Cert_Reg_XOR_Base64, true, true, XOR_Cert_Reg);
|
|
||||||
if (!pubKey)
|
|
||||||
return HandleError("Internal error on public key.");
|
|
||||||
|
|
||||||
// Verify registration data
|
|
||||||
if (verifyData(RegData, regKeyLen, pubKey) != 0)
|
|
||||||
{
|
|
||||||
clearPublicKey(pubKey);
|
|
||||||
return HandleError("Registration key not valid.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear public key
|
|
||||||
clearPublicKey(pubKey);
|
|
||||||
|
|
||||||
// Cuid blacklist (this will ban a certain player-id forever)
|
|
||||||
int i;
|
|
||||||
const char *BlackCuid[] = { "16206436", "36689615", "15315029", "13109693", "17584580", "14718309",
|
|
||||||
"10851931", "13295768", "15786864", "13769103",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
for (i = 0; BlackCuid[i]; i++)
|
|
||||||
if (SEqual2(SSearch(RegData, "Cuid="), BlackCuid[i]))
|
|
||||||
return HandleError("Invalid User-Id.");
|
|
||||||
|
|
||||||
// Cuid-Webcode blacklist (this will only ban a key with a given cuid-webcode combination, allowing to create a new key without assigning a new cuid)
|
|
||||||
const char *BlackCuidWebCode[] = { "16826502", "398ED5F7",
|
|
||||||
NULL, NULL
|
|
||||||
};
|
|
||||||
for (i = 0; BlackCuidWebCode[i]; i += 2)
|
|
||||||
if (SEqual2(SSearch(RegData, "Cuid="), BlackCuidWebCode[i]) && SEqual2(SSearch(RegData, "WebCode="), BlackCuidWebCode[i + 1]))
|
|
||||||
return HandleError("Invalid User-Id/WebCode.");
|
|
||||||
|
|
||||||
// Now truncate the signature from the registration key
|
|
||||||
*delim = 0;
|
|
||||||
|
|
||||||
// Set registered flag
|
|
||||||
RegistrationValid = true;
|
|
||||||
// Store valid keyfile name
|
|
||||||
SCopy(keyFile, KeyFile);
|
|
||||||
// Overwrite general config name (will be empty if not registered)
|
|
||||||
SAppend(GetRegistrationData("FirstName"), General.Name, CFG_MaxString);
|
|
||||||
SAppend(" ", General.Name, CFG_MaxString);
|
|
||||||
SAppend(GetRegistrationData("LastName"), General.Name, CFG_MaxString);
|
|
||||||
|
|
||||||
// Success
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::HandleError(const char *strMessage)
|
|
||||||
{
|
|
||||||
RegData[0] = 0;
|
|
||||||
Log(strMessage);
|
|
||||||
if (RegistrationError.getLength()) RegistrationError.Append(" ");
|
|
||||||
RegistrationError.Append(strMessage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* C4ConfigShareware::GetRegistrationError()
|
|
||||||
{
|
|
||||||
return RegistrationError.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* C4ConfigShareware::GetKeyFilename()
|
|
||||||
{
|
|
||||||
return KeyFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* C4ConfigShareware::GetInvalidKeyFilename()
|
|
||||||
{
|
|
||||||
return InvalidKeyFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* C4ConfigShareware::GetKeyPath()
|
|
||||||
{
|
|
||||||
// Returns the configured key path with environment variables expanded and terminating slash
|
|
||||||
static char strKeyPath[_MAX_PATH + 1];
|
|
||||||
if (!Security.KeyPath[0]) return "";
|
|
||||||
SCopy(Security.KeyPath, strKeyPath);
|
|
||||||
ExpandEnvironmentVariables(strKeyPath, _MAX_PATH);
|
|
||||||
AppendBackslash(strKeyPath);
|
|
||||||
return strKeyPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
StdStrBuf C4ConfigShareware::GetKeyMD5()
|
|
||||||
{
|
|
||||||
if (!Registered()) return StdStrBuf();
|
|
||||||
// Calculate MD5 of full key data
|
|
||||||
BYTE Digest[MD5_DIGEST_LENGTH];
|
|
||||||
MD5(reinterpret_cast<BYTE *>(RegData), SLen(RegData), Digest);
|
|
||||||
// Convert to hex
|
|
||||||
StdStrBuf HexDigest;
|
|
||||||
for (int i = 0; i < MD5_DIGEST_LENGTH; i++)
|
|
||||||
HexDigest.AppendFormat("%02x", Digest[i]);
|
|
||||||
// Done
|
|
||||||
return HexDigest;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* C4ConfigShareware::GetRegistrationData(const char *strField)
|
|
||||||
{
|
|
||||||
// Notice: GetRegistrationData() is used by LoadRegistration even if the registered flag is not yet set.
|
|
||||||
static char strReturnValue[CFG_MaxString + 1];
|
|
||||||
// Find field in registration key
|
|
||||||
char strFieldMask[128 + 1 + 1];
|
|
||||||
strncpy(strFieldMask, strField, 128); strFieldMask[128] = 0;
|
|
||||||
strcat(strFieldMask, "=");
|
|
||||||
const char *pKeyField = strstr(RegData, strFieldMask);
|
|
||||||
// Field not found, key might be empty
|
|
||||||
if (!pKeyField) return "";
|
|
||||||
// Advance to value
|
|
||||||
pKeyField += strlen(strFieldMask);
|
|
||||||
// Get field value
|
|
||||||
size_t iValueLen = 256;
|
|
||||||
const char *pFieldEnd = strstr(pKeyField, "\x0d");
|
|
||||||
if (pFieldEnd) iValueLen = pFieldEnd - pKeyField;
|
|
||||||
iValueLen = Min<size_t>(iValueLen, CFG_MaxString);
|
|
||||||
strncpy(strReturnValue, pKeyField, iValueLen); strReturnValue[iValueLen] = 0;
|
|
||||||
return strReturnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4ConfigShareware::ClearRegistrationError()
|
|
||||||
{
|
|
||||||
// Reset error message(s)
|
|
||||||
RegistrationError.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4ConfigShareware::IsConfidentialData(const char *szInput)
|
|
||||||
{
|
|
||||||
// safety
|
|
||||||
if (!szInput) return false;
|
|
||||||
// unreg users don't have confidential data
|
|
||||||
if (!Config.Registered()) return false;
|
|
||||||
// shouldn't send the webcode!
|
|
||||||
const char *szWebCode = GetRegistrationData("WebCode");
|
|
||||||
if (szWebCode && *szWebCode) if (SSearchNoCase(szInput, szWebCode))
|
|
||||||
{
|
|
||||||
/* if (fShowWarningMessage && ::pGUI)
|
|
||||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// all OK
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
C4ConfigShareware Config;
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* OpenClonk, http://www.openclonk.org
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003, 2007 Matthes Bender
|
|
||||||
* Copyright (c) 2005 Günther Brammer
|
|
||||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
||||||
*
|
|
||||||
* Portions might be copyrighted by other authors who have contributed
|
|
||||||
* to OpenClonk.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
* See isc_license.txt for full license and disclaimer.
|
|
||||||
*
|
|
||||||
* "Clonk" is a registered trademark of Matthes Bender.
|
|
||||||
* See clonk_trademark_license.txt for full license.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef C4CONFIGSHAREWARE_H_INC
|
|
||||||
#define C4CONFIGSHAREWARE_H_INC
|
|
||||||
|
|
||||||
#include <C4Config.h>
|
|
||||||
#include <C4Group.h>
|
|
||||||
|
|
||||||
const int MaxRegDataLen = 4096;
|
|
||||||
const char szInvalidKeyData[] = "r>iU218f3_030\r\n0ipX>ZeuX\r\nZichtVLpI=WeUt\r\nYNtzNcQy=EZs1\r\nAhVsloP=PYptk TE0e\r\n5Vtms5_0:-0^-0>\r\nDfhCqHy=27CIxFpB\r\n\r\nnxSR+?bD50+H[:fEnyW^UcASVTSR9n>Oez`2qHN3YWbz8P;SSqkvXtXMM6Z1UQNT\r\nrpFHRy/6pZ2T6E1iGF1Dt\370Ofw7f\370bUvuM3_jl8TsxWN8;d0kCj3v/JRWBO/Gvxpx\r\nTrBomp81>gkZoddjFcyTwx[J/dNIKEzt]Tj5em=]60w@\r\n";
|
|
||||||
|
|
||||||
void UnscrambleString(char *szString);
|
|
||||||
|
|
||||||
class C4ConfigShareware: public C4Config
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
C4ConfigShareware();
|
|
||||||
~C4ConfigShareware();
|
|
||||||
protected:
|
|
||||||
bool RegistrationValid;
|
|
||||||
char RegData[MaxRegDataLen + 1];
|
|
||||||
char KeyFile[CFG_MaxString + 1];
|
|
||||||
char InvalidKeyFile[CFG_MaxString + 1];
|
|
||||||
public:
|
|
||||||
void Default();
|
|
||||||
bool Save();
|
|
||||||
bool Load(bool forceWorkingDirectory=true, const char *szCustomFile=NULL);
|
|
||||||
public:
|
|
||||||
void ClearRegistrationError();
|
|
||||||
bool Registered();
|
|
||||||
bool LoadRegistration();
|
|
||||||
bool LoadRegistration(const char *szFrom);
|
|
||||||
const char* GetRegistrationData(const char* strField);
|
|
||||||
const char* GetRegistrationError();
|
|
||||||
const char* GetKeyFilename();
|
|
||||||
const char* GetInvalidKeyFilename();
|
|
||||||
const char* GetKeyPath();
|
|
||||||
StdStrBuf GetKeyMD5();
|
|
||||||
// checks for phising attacks: Return true if input contains user's webcode
|
|
||||||
bool IsConfidentialData(const char *szInput);
|
|
||||||
protected:
|
|
||||||
StdStrBuf RegistrationError;
|
|
||||||
bool HandleError(const char *strMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern C4ConfigShareware Config;
|
|
||||||
#endif // C4CONFIGSHAREWARE_H_INC
|
|
|
@ -833,12 +833,6 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
|
||||||
}
|
}
|
||||||
// safety
|
// safety
|
||||||
if (!szInput || !*szInput || !pChatSheet) return fResult;
|
if (!szInput || !*szInput || !pChatSheet) return fResult;
|
||||||
// check confidential data
|
|
||||||
if (Config.IsConfidentialData(szInput))
|
|
||||||
{
|
|
||||||
pChatSheet->DoError(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
|
||||||
return fResult;
|
|
||||||
}
|
|
||||||
// command?
|
// command?
|
||||||
if (*szInput == '/' && !SEqual2NoCase(szInput + 1, "me "))
|
if (*szInput == '/' && !SEqual2NoCase(szInput + 1, "me "))
|
||||||
{
|
{
|
||||||
|
|
|
@ -447,12 +447,6 @@ namespace C4GameLobby
|
||||||
// because those might kill the edit field
|
// because those might kill the edit field
|
||||||
::MessageInput.StoreBackBuffer(szInputText);
|
::MessageInput.StoreBackBuffer(szInputText);
|
||||||
bool fProcessed = false;
|
bool fProcessed = false;
|
||||||
// check confidential data
|
|
||||||
if (Config.IsConfidentialData(szInputText))
|
|
||||||
{
|
|
||||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
|
||||||
fProcessed = true;
|
|
||||||
}
|
|
||||||
// CAUTION when implementing special commands (like /quit) here:
|
// CAUTION when implementing special commands (like /quit) here:
|
||||||
// those must not be executed when text is pasted, because that could crash the GUI system
|
// those must not be executed when text is pasted, because that could crash the GUI system
|
||||||
// when there are additional lines to paste, but the edit field is destructed by the command
|
// when there are additional lines to paste, but the edit field is destructed by the command
|
||||||
|
|
|
@ -133,12 +133,6 @@ C4GUI::Edit::InputResult C4ChatInputDialog::OnChatInput(C4GUI::Edit *edt, bool f
|
||||||
char *szInputText = const_cast<char *>(pEdt->GetText());
|
char *szInputText = const_cast<char *>(pEdt->GetText());
|
||||||
// Store to back buffer
|
// Store to back buffer
|
||||||
::MessageInput.StoreBackBuffer(szInputText);
|
::MessageInput.StoreBackBuffer(szInputText);
|
||||||
// check confidential data - even for object input (script triggered), webcode should not be pasted here
|
|
||||||
if (Config.IsConfidentialData(szInputText))
|
|
||||||
{
|
|
||||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
|
||||||
szInputText = const_cast<char *>("");
|
|
||||||
}
|
|
||||||
// script queried input?
|
// script queried input?
|
||||||
if (fObjInput)
|
if (fObjInput)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,9 +49,7 @@ IMPLEMENT_LOGF(DebugLogF)
|
||||||
IMPLEMENT_LOGF(LogF)
|
IMPLEMENT_LOGF(LogF)
|
||||||
IMPLEMENT_LOGF(LogSilentF)
|
IMPLEMENT_LOGF(LogSilentF)
|
||||||
|
|
||||||
C4ConfigShareware Config;
|
C4Config Config;
|
||||||
C4ConfigShareware::C4ConfigShareware() {}
|
|
||||||
C4ConfigShareware::~C4ConfigShareware() {}
|
|
||||||
C4Config::C4Config() {}
|
C4Config::C4Config() {}
|
||||||
C4Config::~C4Config() {}
|
C4Config::~C4Config() {}
|
||||||
const char * C4Config::AtRelativePath(char const*s) {return s;}
|
const char * C4Config::AtRelativePath(char const*s) {return s;}
|
||||||
|
|
Loading…
Reference in New Issue