Minidump upload
This commit is contained in:
parent
67aade3ef4
commit
ccd465da54
@ -9,24 +9,45 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
void Exception::UploadMinidump(std::string filename)
|
||||
bool Exception::UploadMinidump(std::string filename)
|
||||
{
|
||||
// Utils::WebIO webio("Firefucks", UPLOAD_URL);
|
||||
//
|
||||
// if (Utils::IO::FileExists(filename))
|
||||
// {
|
||||
// std::string buffer = Utils::IO::ReadFile(filename);
|
||||
// std::string result = webio.PostFile(buffer);
|
||||
//
|
||||
// MessageBoxA(0, result.data(), "Minidump", 0);
|
||||
// }
|
||||
Utils::WebIO webio("Firefucks", UPLOAD_URL);
|
||||
|
||||
// mg_mgr mgr;
|
||||
// mg_mgr_init(&mgr, NULL);
|
||||
//
|
||||
// mg_connect_http
|
||||
//
|
||||
// mg_mgr_free(&mgr);
|
||||
if (Utils::IO::FileExists(filename))
|
||||
{
|
||||
std::string buffer = Utils::IO::ReadFile(filename);
|
||||
std::string result = webio.PostFile(buffer);
|
||||
|
||||
std::string errors;
|
||||
json11::Json object = json11::Json::parse(result, errors);
|
||||
|
||||
if (!object.is_object()) return false;
|
||||
|
||||
json11::Json success = object["success"];
|
||||
|
||||
if (!success.is_bool() || !success.bool_value()) return false;
|
||||
|
||||
json11::Json files = object["files"];
|
||||
|
||||
if (!files.is_array()) return false;
|
||||
|
||||
for (auto file : files.array_items())
|
||||
{
|
||||
json11::Json url = file["url"];
|
||||
json11::Json hash = file["hash"];
|
||||
|
||||
if (hash.is_string() && url.is_string())
|
||||
{
|
||||
if (Utils::String::ToLower(Utils::Cryptography::SHA1::Compute(buffer, true)) == Utils::String::ToLower(hash.string_value()))
|
||||
{
|
||||
MessageBoxA(0, url.string_value().data(), 0, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define UPLOAD_URL "https://momo5502.com/test/upload.php"
|
||||
#define UPLOAD_URL "https://reich.io/upload.php"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
@ -12,6 +12,6 @@ namespace Components
|
||||
static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo);
|
||||
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||
|
||||
static void UploadMinidump(std::string filename);
|
||||
static bool UploadMinidump(std::string filename);
|
||||
};
|
||||
}
|
||||
|
@ -185,6 +185,30 @@ namespace Utils
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region SHA1
|
||||
|
||||
std::string SHA1::Compute(std::string data, bool hex)
|
||||
{
|
||||
return SHA1::Compute(reinterpret_cast<const uint8_t*>(data.data()), data.size(), hex);
|
||||
}
|
||||
|
||||
std::string SHA1::Compute(const uint8_t* data, size_t length, bool hex)
|
||||
{
|
||||
uint8_t buffer[20] = { 0 };
|
||||
|
||||
hash_state state;
|
||||
sha1_init(&state);
|
||||
sha1_process(&state, data, length);
|
||||
sha1_done(&state, buffer);
|
||||
|
||||
std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer));
|
||||
if (!hex) return hash;
|
||||
|
||||
return Utils::String::DumpHex(hash, "");
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region SHA256
|
||||
|
||||
std::string SHA256::Compute(std::string data, bool hex)
|
||||
|
@ -300,6 +300,13 @@ namespace Utils
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA1
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA256
|
||||
{
|
||||
public:
|
||||
|
@ -144,15 +144,16 @@ namespace Utils
|
||||
{
|
||||
WebIO::Params headers;
|
||||
|
||||
std::string boundary = "xxxxxxxxx";
|
||||
std::string boundary = "----WebKitFormBoundaryHoLVocRsBxs71fU6";
|
||||
headers["Content-Type"] = "multipart/form-data, boundary=" + boundary;
|
||||
headers["Content-Length"] = fmt::sprintf("%u", data.size());
|
||||
|
||||
std::string body = "--" + boundary + "\r\n";
|
||||
body += "Content-Disposition: form-data; name=\"contents\"; filename=\"minidump.dmp\"\r\n";
|
||||
body += "Content-Disposition: form-data; name=\"files[]\"; filename=\"minidump.dmp\"\r\n";
|
||||
body += "Content-Type: application/octet-stream\r\n\r\n";
|
||||
body += data + "\r\n";
|
||||
body += "--" + boundary + "--";
|
||||
body += "--" + boundary + "--\r\n";
|
||||
|
||||
headers["Content-Length"] = fmt::sprintf("%u", body.size());
|
||||
|
||||
return WebIO::Execute("POST", body, headers);
|
||||
}
|
||||
@ -248,9 +249,9 @@ namespace Utils
|
||||
return "";
|
||||
}
|
||||
|
||||
if (headers.find("Content-type") == headers.end())
|
||||
if (headers.find("Content-Type") == headers.end())
|
||||
{
|
||||
headers["Content-type"] = "application/x-www-form-urlencoded";
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
std::string finalHeaders;
|
||||
|
Loading…
x
Reference in New Issue
Block a user