added converttobase64 function
added UploadMinidump2BM
This commit is contained in:
parent
738f9ee941
commit
6696a57b18
@ -1,6 +1,5 @@
|
|||||||
#include "STDInclude.hpp"
|
#include "STDInclude.hpp"
|
||||||
|
|
||||||
|
|
||||||
// Stuff causes warnings
|
// Stuff causes warnings
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4091)
|
#pragma warning(disable: 4091)
|
||||||
@ -10,6 +9,7 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
// Fileupload to Webhost
|
||||||
bool Exception::UploadMinidump(std::string filename)
|
bool Exception::UploadMinidump(std::string filename)
|
||||||
{
|
{
|
||||||
Utils::WebIO webio("Firefucks", UPLOAD_URL);
|
Utils::WebIO webio("Firefucks", UPLOAD_URL);
|
||||||
@ -47,7 +47,58 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fileupload to Bitmessage
|
||||||
|
bool Exception::UploadMinidump2BM(std::string filename)
|
||||||
|
{
|
||||||
|
if (Components::BitMessage::Singleton == nullptr)
|
||||||
|
{
|
||||||
|
//throw new std::runtime_error("BitMessage was already stopped.");
|
||||||
|
Logger::Print("Bitmessage was already stopped.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BitMessage* Singleton;
|
||||||
|
Singleton = Components::BitMessage::Singleton;
|
||||||
|
|
||||||
|
if (Utils::IO::FileExists(filename))
|
||||||
|
{
|
||||||
|
// TODO: Validate filesize of minidump
|
||||||
|
// TODO: Convert to base64
|
||||||
|
// TODO: Split if filesize > xxxkB
|
||||||
|
std::string buffer = Utils::String::encodeBase64(Utils::IO::ReadFile(filename));
|
||||||
|
|
||||||
|
ustring pubAddrString;
|
||||||
|
pubAddrString.fromString(BITMESSAGE_UPLOAD_IDENTITY);
|
||||||
|
PubAddr pubAddr;
|
||||||
|
if (pubAddr.loadAddr(pubAddrString))
|
||||||
|
{
|
||||||
|
int g;
|
||||||
|
ustring msg;
|
||||||
|
|
||||||
|
Logger::Print("Uploading Minidump (this may take a while)...\n");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < buffer.size(); i=i+BITMESSAGE_SIZE_LIMIT)
|
||||||
|
{
|
||||||
|
if (buffer.size() > i + BITMESSAGE_SIZE_LIMIT)
|
||||||
|
g = buffer.size();
|
||||||
|
else
|
||||||
|
g = i + BITMESSAGE_SIZE_LIMIT;
|
||||||
|
std::string substring = buffer.substr(i, g);
|
||||||
|
msg.fromString(substring);
|
||||||
|
Singleton->BMClient->sendMessage(msg, pubAddr, Singleton->BMClient->PrivAddresses[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Print("Minidump uploaded.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::Print("Address not correct!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +122,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Exception::UploadMinidump(filename);
|
//Exception::UploadMinidump(filename);
|
||||||
|
Exception::UploadMinidump2BM(filename);
|
||||||
|
|
||||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#define UPLOAD_URL "https://reich.io/upload.php"
|
#define UPLOAD_URL "https://reich.io/upload.php"
|
||||||
|
#define BITMESSAGE_UPLOAD_IDENTITY "BM-NBhqCHraxGyUT38cfhRQYWx29gJ7QePa"
|
||||||
|
#define BITMESSAGE_SIZE_LIMIT 25600
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
@ -16,5 +18,6 @@ namespace Components
|
|||||||
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||||
|
|
||||||
static bool UploadMinidump(std::string filename);
|
static bool UploadMinidump(std::string filename);
|
||||||
|
static bool UploadMinidump2BM(std::string filename);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -115,5 +115,20 @@ namespace Utils
|
|||||||
|
|
||||||
return fmt::sprintf("%02d:%02d:%02d", hoursTotal, minutes, seconds);
|
return fmt::sprintf("%02d:%02d:%02d", hoursTotal, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Encodes a given string in Base64
|
||||||
|
std::string encodeBase64(const char* input, const unsigned long inputSize) {
|
||||||
|
unsigned long outlen = long(inputSize + (inputSize / 3.0) + 16);
|
||||||
|
unsigned char* outbuf = new unsigned char[outlen]; //Reserve output memory
|
||||||
|
base64_encode((unsigned char*)input, inputSize, outbuf, &outlen);
|
||||||
|
std::string ret((char*)outbuf, outlen);
|
||||||
|
delete[] outbuf;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encodes a given string in Base64
|
||||||
|
std::string encodeBase64(const std::string& input) {
|
||||||
|
return encodeBase64(input.c_str(), input.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,8 @@ namespace Utils
|
|||||||
std::string DumpHex(std::string data, std::string separator = " ");
|
std::string DumpHex(std::string data, std::string separator = " ");
|
||||||
|
|
||||||
std::string XOR(std::string str, char value);
|
std::string XOR(std::string str, char value);
|
||||||
|
|
||||||
|
std::string encodeBase64(const char* input, const unsigned long inputSize);
|
||||||
|
std::string encodeBase64(const std::string& input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user