mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-19 21:22:54 +00:00
Added crypto and compression (xd) to sig file
This commit is contained in:
parent
e62e5b1fa1
commit
f33ec726fb
@ -3,18 +3,20 @@
|
|||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/io.hpp>
|
#include <utils/io.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
#include <utils/cryptography.hpp>
|
||||||
|
#include <utils/compression.hpp>
|
||||||
#include <json.hpp>
|
#include <json.hpp>
|
||||||
|
|
||||||
namespace signatures
|
namespace signatures
|
||||||
{
|
{
|
||||||
std::string read_sigs_file()
|
std::string read_sigs_file()
|
||||||
{
|
{
|
||||||
return utils::io::read_file("t4sp-server-plugin/sigs.json");
|
return utils::compression::zlib::decompress(utils::cryptography::des::decrypt(utils::io::read_file("t4sp-server-plugin/sigs")));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_sigs_file(const std::string& f)
|
bool write_sigs_file(const std::string& f)
|
||||||
{
|
{
|
||||||
return utils::io::write_file("t4sp-server-plugin/sigs.json", f);
|
return utils::io::write_file("t4sp-server-plugin/sigs", utils::cryptography::des::encrypt(utils::compression::zlib::compress(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* get_current_version()
|
const char* get_current_version()
|
||||||
@ -151,6 +153,8 @@ namespace signatures
|
|||||||
|
|
||||||
bool process()
|
bool process()
|
||||||
{
|
{
|
||||||
|
utils::cryptography::des::set_key("694201337");
|
||||||
|
|
||||||
handle_funcs();
|
handle_funcs();
|
||||||
|
|
||||||
return process_printf();
|
return process_printf();
|
||||||
|
@ -667,4 +667,68 @@ namespace utils::cryptography
|
|||||||
{
|
{
|
||||||
prng_.read(data, size);
|
prng_.read(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace des
|
||||||
|
{
|
||||||
|
constexpr int KEYSIZE = 8;
|
||||||
|
constexpr int BLOCKSIZE = 8;
|
||||||
|
constexpr int ROUNDS = 16;
|
||||||
|
|
||||||
|
static unsigned char key[KEYSIZE];
|
||||||
|
|
||||||
|
void set_key(const std::string& k)
|
||||||
|
{
|
||||||
|
memcpy(key, k.c_str(), KEYSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string encrypt(const std::string& in_str)
|
||||||
|
{
|
||||||
|
size_t length = in_str.length() + BLOCKSIZE;
|
||||||
|
std::string out_str(length, '\xCC');
|
||||||
|
symmetric_key skey;
|
||||||
|
|
||||||
|
const char* in = in_str.c_str();
|
||||||
|
char* out = out_str.data();
|
||||||
|
|
||||||
|
des_setup(key, KEYSIZE, ROUNDS, &skey);
|
||||||
|
|
||||||
|
const int n = length / BLOCKSIZE;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
const int offset = i * BLOCKSIZE;
|
||||||
|
const unsigned char *ct = reinterpret_cast<const unsigned char *>(in + offset);
|
||||||
|
unsigned char *pt = reinterpret_cast<unsigned char *>(out + offset);
|
||||||
|
des_ecb_encrypt(ct, pt, &skey);
|
||||||
|
}
|
||||||
|
|
||||||
|
des_done(&skey);
|
||||||
|
return out_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string decrypt(const std::string& in_str)
|
||||||
|
{
|
||||||
|
size_t length = in_str.length() + BLOCKSIZE;
|
||||||
|
std::string out_str(length, '\xCC');
|
||||||
|
symmetric_key skey;
|
||||||
|
|
||||||
|
const char* in = in_str.c_str();
|
||||||
|
char* out = out_str.data();
|
||||||
|
|
||||||
|
des_setup(key, KEYSIZE, ROUNDS, &skey);
|
||||||
|
|
||||||
|
const int n = length / BLOCKSIZE;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
const int offset = i * BLOCKSIZE;
|
||||||
|
const unsigned char *ct = reinterpret_cast<const unsigned char *>(in + offset);
|
||||||
|
unsigned char *pt = reinterpret_cast<unsigned char *>(out + offset);
|
||||||
|
des_ecb_decrypt(ct, pt, &skey);
|
||||||
|
}
|
||||||
|
|
||||||
|
des_done(&skey);
|
||||||
|
return out_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,4 +118,14 @@ namespace utils::cryptography
|
|||||||
std::string get_challenge();
|
std::string get_challenge();
|
||||||
void get_data(void* data, size_t size);
|
void get_data(void* data, size_t size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://gist.github.com/Moligaloo/5944425
|
||||||
|
namespace des
|
||||||
|
{
|
||||||
|
void set_key(const std::string& k);
|
||||||
|
|
||||||
|
std::string encrypt(const std::string& in_str);
|
||||||
|
|
||||||
|
std::string decrypt(const std::string& in_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user