Hide password slightly

This commit is contained in:
Peter Sykora 2018-03-21 00:45:35 +01:00
parent ef8276fe83
commit fe7c1bb368

View File

@ -1,5 +1,7 @@
#include "CCServer.h"
#include "CryptoUtils.h"
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
@ -31,16 +33,14 @@ static constexpr auto APIS_UINT8_MAX = std::numeric_limits<uint8_t>::max();
#define MAXHESLO 225
#define MAX_DEKODHESLO (MAXHESLO-3)
#define KodcharToChar(znak1,znak2,poloha,viet) { \
(znak1)=(-(password[poloha]-APIS_UINT8_MIN)+(~(znak2))-(poloha)-(viet)); \
if((znak1)<APIS_UINT8_MIN) (znak1)=(-(APIS_UINT8_MIN-(znak1)))&APIS_UINT8_MAX; \
}
#define KodcharToChar(znak2,poloha,posun) static_cast<uint8_t>(-(password[poloha])+(~(znak2))-(posun))
namespace
{
static const std::string cryptFileHeader("##CAPISF## Copyright (c) 2003 APIS spol. s r.o. SLOVAKIA~");
static const std::string password("flckdscwjregfvfgbujvbnqajmadmgfjmhfmghplgghesrrhsufservvysfidgfysdnmsybsaftoprecofoplyrmnfsvcapridssedalenttrmfusposvresalbostreqnnapswolnfrdweneplmnzcavsfgusqootrpqaressnvclpacfdrgesklojphsdqtyczvxcbfhtryntinokusgkhjgchtx");
//static const std::string passReal("flckdscwjregfvfgbujvbnqajmadmgfjmhfmghplgghesrrhsufservvysfidgfysdnmsybsaftoprecofoplyrmnfsvcapridssedalenttrmfusposvresalbostreqnnapswolnfrdweneplmnzcavsfgusqootrpqaressnvclpacfdrgesklojphsdqtyczvxcbfhtryntinokusgkhjgchtx");
static const uint8_t passHidden2[] = { 0x89, 0xdb, 0x2c, 0x79, 0xd6, 0xa5, 0x7a, 0x7b, 0x6d, 0xae, 0x67, 0xee, 0xb2, 0x9a, 0x2c, 0xbe, 0xb7, 0xac, 0x6a, 0x56, 0xe8, 0xb2, 0xda, 0xde, 0xaa, 0x79, 0xda, 0xa6, 0xcc, 0x28, 0x96, 0x77, 0xeb, 0x77, 0x07, 0xa7, 0x7a, 0x99, 0x66, 0x9f, 0x37, 0x1a, 0xbe, 0xc7, 0xe0, 0xba, 0xca, 0xa8, 0xa2, 0xda, 0xe9, 0xa9, 0xaa, 0xde, 0xb2, 0xc9, 0xef, 0x72, 0x5a, 0x5a, 0x71, 0xf7, 0x6b, 0x81, 0xeb, 0x24, 0x96, 0x88, 0xe9, 0x86, 0xc7, 0x6a, 0xb7, 0x27, 0x33, 0xbf, 0x17, 0x1b, 0x7e, 0x1b, 0x6b, 0xca, 0x7b, 0x62, 0x9e, 0x89, 0x2e, 0xb2, 0x09, 0x21, 0x8e, 0x07, 0x21, 0xb7, 0x10, 0x34 };
class apis_read_filter
{
@ -71,7 +71,7 @@ public:
int dwPacketPos = ((m_position / MAX_DEKODHESLO) % 29) + 2;
int iPoloha = m_position % MAX_DEKODHESLO;
m_position += result;
m_position += static_cast<size_t>(result);
for (int i = 0; i < result; i++)
{
@ -85,9 +85,17 @@ public:
dwPacketPos = 2;
}
int znak;
KodcharToChar(znak, s[i], iPoloha, dwPacketPos);
s[i] = znak;
static const uint8_t passHidden[] = { 0x7e, 0x57, 0x24, 0x76, 0xc7, 0x30, 0x8e, 0xb7, 0xa0, 0x7e, 0xf7, 0xe0, 0x6e, 0xe8, 0xef, 0x6e, 0x7a, 0x9a, 0x8e, 0x66, 0x9d, 0x9a, 0x07, 0xe3, 0x9a, 0x17, 0xe6, 0x82, 0x1a, 0x65, 0x82, 0x08, 0x5e, 0xb2, 0xba, 0xe1, 0xb2, 0xe7, 0xec, 0x7a, 0xbb, 0xef, 0xca, 0xc7, 0xe2, 0x76, 0x07, 0xf2, 0xb1, 0xd9, 0xe6, 0xb3, 0x26, 0xec, 0x69, 0xfb, 0x68, 0xa6, 0xb7, 0x9c, 0xa1, 0xfa, 0x29, 0x97, 0x2a, 0xe6, 0x9d, 0xfb, 0x2f, 0x71, 0xaa, 0x6b };
if (iPoloha < sizeof(passHidden) * 4 / 3)
{
static const auto password = base64Encode(passHidden, sizeof(passHidden));
s[i] = KodcharToChar(s[i], iPoloha, iPoloha + dwPacketPos);
}
else
{
static const auto password = base64Encode(passHidden2, sizeof(passHidden2));
s[i] = KodcharToChar(s[i], iPoloha - sizeof(passHidden) * 4 / 3, iPoloha + dwPacketPos);
}
++iPoloha;
}
@ -337,7 +345,7 @@ template<
std::ifstream body(path, std::ifstream::binary);
body.seekg(0, std::ios::end);
size_t size = body.tellg();
auto size = static_cast<size_t>(body.tellg());
std::vector<uint8_t> buffer(size, 0);
body.seekg(0);
body.read((char*)buffer.data(), size);