diff --git a/Src/Common/FSecure/Slack/SlackApi.cpp b/Src/Common/FSecure/Slack/SlackApi.cpp index 8da3778..1a054dc 100644 --- a/Src/Common/FSecure/Slack/SlackApi.cpp +++ b/Src/Common/FSecure/Slack/SlackApi.cpp @@ -61,7 +61,7 @@ std::map FSecure::Slack::ListChannels() std::map channelMap; std::string url = OBF("https://slack.com/api/conversations.list?exclude_archived=true"); - json response = SendJsonRequest(url, NULL); + json response = GetJsonResponse(url); for (auto &channel : response[OBF("channels")]) { @@ -107,7 +107,7 @@ std::string FSecure::Slack::CreateChannel(std::string const& channelName) std::vector> FSecure::Slack::ReadReplies(std::string const& timestamp) { std::string url = OBF("https://slack.com/api/conversations.replies?channel=") + this->m_Channel + OBF("&ts=") + timestamp; - json output = SendJsonRequest(url, NULL); + json output = GetJsonResponse(url); //This logic is really messy, in reality the checks are over cautious, however there is an edgecase //whereby a message could be created with no replies of the implant that wrote triggers an exception or gets killed. @@ -159,7 +159,7 @@ std::vector FSecure::Slack::GetMessagesByDirection(std::string con url.append(OBF("&cursor=") + cursor); //Actually send the http request and grab the messages - auto resp = SendJsonRequest(url, NULL); + auto resp = GetJsonResponse(url); auto& messages = resp[OBF("messages")]; @@ -247,6 +247,11 @@ json FSecure::Slack::SendJsonRequest(std::string const& url, json const& data) return json::parse(SendHttpRequest(url, ContentType::ApplicationJson, data.dump())); } +json FSecure::Slack::GetJsonResponse(std::string const& url) +{ + return json::parse(SendHttpRequest(url)); +} + void FSecure::Slack::UploadFile(ByteView data, std::string const& ts) { std::string url = OBF_STR("https://slack.com/api/files.upload?") + OBF("&channels=") + this->m_Channel + OBF("&thread_ts=") + ts; diff --git a/Src/Common/FSecure/Slack/SlackApi.h b/Src/Common/FSecure/Slack/SlackApi.h index 7a568d8..bedb4b2 100644 --- a/Src/Common/FSecure/Slack/SlackApi.h +++ b/Src/Common/FSecure/Slack/SlackApi.h @@ -89,6 +89,9 @@ namespace FSecure /// Send http request with json data, uses preset token for authentication json SendJsonRequest(std::string const& url, json const& data); + /// Send http GET request, uses preset token for authentication, expect response of application/json type + json GetJsonResponse(std::string const& url); + /// Use Slack's File API to retrieve files. /// @param url - the url where the file can be retrieved. /// @return - the data within the file.