Merge branch 'master' into master
This commit is contained in:
commit
46d1122180
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,3 +4,6 @@
|
||||
[submodule "simple-ipc"]
|
||||
path = simple-ipc
|
||||
url = https://github.com/nullifiedcat/simple-ipc
|
||||
[submodule "ucccccp"]
|
||||
path = ucccccp
|
||||
url = https://github.com/nullifiedcat/ucccccp
|
||||
|
2
makefile
2
makefile
@ -10,7 +10,7 @@ CFLAGS=$(COMMON_FLAGS) $(WARNING_FLAGS)
|
||||
CXXFLAGS=-std=gnu++1z $(COMMON_FLAGS) $(WARNING_FLAGS)
|
||||
SDKFOLDER=$(realpath source-sdk-2013/mp/src)
|
||||
SIMPLE_IPC_DIR = $(realpath simple-ipc/src/include)
|
||||
INCLUDES=-isystemsrc/freetype-gl -isystemsrc/imgui -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2 -I$(SIMPLE_IPC_DIR) -isystem$(SDKFOLDER)/public -isystem$(SDKFOLDER)/mathlib -isystem$(SDKFOLDER)/common -isystem$(SDKFOLDER)/public/tier1 -isystem$(SDKFOLDER)/public/tier0 -isystem$(SDKFOLDER)
|
||||
INCLUDES=-Iucccccp -isystemsrc/freetype-gl -isystemsrc/imgui -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2 -I$(SIMPLE_IPC_DIR) -isystem$(SDKFOLDER)/public -isystem$(SDKFOLDER)/mathlib -isystem$(SDKFOLDER)/common -isystem$(SDKFOLDER)/public/tier1 -isystem$(SDKFOLDER)/public/tier0 -isystem$(SDKFOLDER)
|
||||
LIB_DIR=lib
|
||||
LDFLAGS=-m32 -fno-gnu-unique -D_GLIBCXX_USE_CXX11_ABI=0 -shared -L$(realpath $(LIB_DIR))
|
||||
LDLIBS=-static -lc -lstdc++ -ltier0 -lvstdlib -l:libSDL2-2.0.so.0 -static -lGLEW -lfreetype -lpthread
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
#include "hoovy.hpp"
|
||||
#include "enums.h"
|
||||
#include "projlogging.hpp"
|
||||
#include "utfccp_commands.hpp"
|
||||
#include "ucccccp_cmds.hpp"
|
||||
#include "velocity.hpp"
|
||||
#include "angles.hpp"
|
||||
#include "entityhitboxcache.hpp"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "../common.h"
|
||||
#include "../netmessage.h"
|
||||
#include "../hack.h"
|
||||
#include "../utfccp.hpp"
|
||||
#include "ucccccp.hpp"
|
||||
#include "hookedmethods.h"
|
||||
|
||||
static CatVar no_invisibility(CV_SWITCH, "no_invis", "0", "Remove Invisibility", "Useful with chams!");
|
||||
@ -151,7 +151,7 @@ bool SendNetMsg_hook(void* _this, INetMessage& msg, bool bForceReliable = false,
|
||||
std::string msg(str.substr(offset));
|
||||
msg = msg.substr(0, msg.length() - 2);
|
||||
if (msg.find("!!") == 0) {
|
||||
msg = utfccp::encrypt(msg.substr(2));
|
||||
msg = ucccccp::encrypt(msg.substr(2));
|
||||
str = str.substr(0, offset) + msg + "\"\"";
|
||||
crpt = true;
|
||||
}
|
||||
@ -349,8 +349,8 @@ bool DispatchUserMessage_hook(void* _this, int type, bf_read& buf) {
|
||||
}
|
||||
if (crypt_chat) {
|
||||
if (message.find("!!") == 0) {
|
||||
if (utfccp::validate(message)) {
|
||||
PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(), utfccp::decrypt(message).c_str());
|
||||
if (ucccccp::validate(message)) {
|
||||
PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(), ucccccp::decrypt(message).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
src/ucccccp_cmds.cpp
Normal file
22
src/ucccccp_cmds.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* utfccp_commands.cpp
|
||||
*
|
||||
* Created on: Jul 1, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "ucccccp.hpp"
|
||||
#include "common.h"
|
||||
#include "ucccccp_cmds.hpp"
|
||||
|
||||
CatCommand utfccp_encrypt("ucccccp_encrypt", "Encrypt a message", [](const CCommand& args) {
|
||||
logging::Info("%s", ucccccp::encrypt(std::string(args.ArgS())).c_str());
|
||||
});
|
||||
|
||||
CatCommand utfccp_decrypt("ucccccp_decrypt", "Decrypt a message", [](const CCommand& args) {
|
||||
if (ucccccp::validate(std::string(args.ArgS()))) {
|
||||
logging::Info("%s", ucccccp::decrypt(std::string(args.ArgS())).c_str());
|
||||
} else {
|
||||
logging::Info("Invalid input data!");
|
||||
}
|
||||
});
|
@ -9,5 +9,5 @@
|
||||
|
||||
class CatCommand;
|
||||
|
||||
extern CatCommand utfccp_encrypt;
|
||||
extern CatCommand utfccp_decrypt;
|
||||
extern CatCommand ucccccp_encrypt;
|
||||
extern CatCommand ucccccp_decrypt;
|
100
src/utfccp.hpp
100
src/utfccp.hpp
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* utfccp.hpp
|
||||
*
|
||||
* Created on: Jul 1, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "base64.h"
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
* To send message, call utfccp::encrypt on text of the message and send the result to chat
|
||||
* When receiving a message, call utfccp::validate, and if it succeeds, call utfccp::decrypt and show the result
|
||||
*
|
||||
* To include this to your project, add this file and base64.h to your source and include this file.
|
||||
*
|
||||
* General structure of message:
|
||||
* !![version][data]
|
||||
* version: char from base64 alphabet
|
||||
* data: depends on version
|
||||
*
|
||||
* Versions:
|
||||
* A:
|
||||
* !!A[data][checksum]
|
||||
* data = base64(crappy_xorstring(input))
|
||||
* checksum = crappy_checksum(input)
|
||||
*/
|
||||
|
||||
namespace utfccp {
|
||||
|
||||
inline std::string crappy_checksum(const std::string& in) {
|
||||
int s = 0, ss = 0;
|
||||
for (int i = 0; i < in.length(); i += 2) {
|
||||
s += (int)in[i];
|
||||
if (i < in.length() - 1)
|
||||
ss += (int)in[i + 1] * (int)in[i + 1];
|
||||
}
|
||||
return { kBase64Alphabet[s % 64], kBase64Alphabet[ss % 64] };
|
||||
}
|
||||
|
||||
inline std::string crappy_xorstring(const std::string& in) {
|
||||
std::string out;
|
||||
for (int i = 0; i < in.length(); i++) {
|
||||
// 696969th prime, 13371337th prime
|
||||
out.push_back(in[i] ^ ((10522103 * in.length()) + i * 244053389 % 256));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* validate
|
||||
* A
|
||||
*/
|
||||
inline bool validate(const std::string& in) {
|
||||
if (in.length() < 4) return false;
|
||||
if (in[0] != '!' || in[1] != '!') return false;
|
||||
switch (in[2]) {
|
||||
case 'A':
|
||||
return crappy_checksum(in.substr(3, in.length() - 5)) == in.substr(in.length() - 2);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* decrypt
|
||||
* A
|
||||
*/
|
||||
inline std::string decrypt(const std::string& in) {
|
||||
switch (in[2]) {
|
||||
case 'A': {
|
||||
std::string b64;
|
||||
Base64::Decode(in.substr(3, in.length() - 5), &b64);
|
||||
return crappy_xorstring(b64);
|
||||
}
|
||||
default:
|
||||
return "Unsupported version";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* encrypt
|
||||
* falls back to A if version is invalid
|
||||
* A
|
||||
*/
|
||||
inline std::string encrypt(const std::string& in, char version = 'A') {
|
||||
switch (version) {
|
||||
default:
|
||||
case 'A': {
|
||||
std::string b64;
|
||||
Base64::Encode(crappy_xorstring(in), &b64);
|
||||
return "!!A" + b64 + crappy_checksum(b64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* utfccp_commands.cpp
|
||||
*
|
||||
* Created on: Jul 1, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "utfccp_commands.hpp"
|
||||
#include "utfccp.hpp"
|
||||
#include "common.h"
|
||||
|
||||
CatCommand utfccp_encrypt("utfccp_encrypt", "Encrypt a message", [](const CCommand& args) {
|
||||
logging::Info("%s", utfccp::encrypt(std::string(args.ArgS())).c_str());
|
||||
});
|
||||
|
||||
CatCommand utfccp_decrypt("utfccp_decrypt", "Decrypt a message", [](const CCommand& args) {
|
||||
if (utfccp::validate(std::string(args.ArgS()))) {
|
||||
logging::Info("%s", utfccp::decrypt(std::string(args.ArgS())).c_str());
|
||||
} else {
|
||||
logging::Info("Invalid input data!");
|
||||
}
|
||||
});
|
1
ucccccp
Submodule
1
ucccccp
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5b577a66da2e64726385cd28150123896cc1badf
|
Reference in New Issue
Block a user