Added crypto and compression (xd) to sig file

This commit is contained in:
ineed bots 2023-08-29 20:56:58 -06:00
parent e62e5b1fa1
commit f33ec726fb
3 changed files with 80 additions and 2 deletions

View File

@ -3,18 +3,20 @@
#include <utils/hook.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
#include <utils/cryptography.hpp>
#include <utils/compression.hpp>
#include <json.hpp>
namespace signatures
{
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)
{
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()
@ -151,6 +153,8 @@ namespace signatures
bool process()
{
utils::cryptography::des::set_key("694201337");
handle_funcs();
return process_printf();

View File

@ -667,4 +667,68 @@ namespace utils::cryptography
{
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;
}
}
}

View File

@ -118,4 +118,14 @@ namespace utils::cryptography
std::string get_challenge();
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);
}
}