mirror of
https://github.com/maxDcb/C2Core
synced 2026-06-08 15:48:01 +00:00
Minor
This commit is contained in:
@@ -19,6 +19,10 @@ public:
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int initConfig(const nlohmann::json &config);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
int setProcessToSpawn(const std::string& processToSpawn)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,11 @@ public:
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string changeDirectory(const std::string& path);
|
||||
|
||||
@@ -15,6 +15,10 @@ public:
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int followUp(const C2Message &c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::pair<int, std::string>> m_instances;
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string coffLoader(std::string& payload, std::string& functionName, std::string& argsCompressed);
|
||||
|
||||
@@ -17,6 +17,10 @@ public:
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int followUp(const C2Message &c2RetMessage);
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_outputfile;
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ public:
|
||||
int initConfig(const nlohmann::json &config);
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_processToSpawn;
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string importTicket(const std::string& ticket);
|
||||
|
||||
@@ -16,9 +16,12 @@ public:
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
|
||||
int recurringExec(C2Message& c2RetMessage);
|
||||
int followUp(const C2Message &c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
bool getIsThreadLaunched()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string listDirectory(const std::string& path);
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string listProcesses();
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string makeToken(const std::string& username, const std::string& domain, const std::string& password);
|
||||
|
||||
@@ -33,8 +33,6 @@ const std::string ListenerPollCmd = "LISP";
|
||||
const std::string LoadC2ModuleCmd = "LM";
|
||||
const std::string UnloadC2ModuleCmd = "ULM";
|
||||
const std::string Socks5Cmd = "SO5";
|
||||
// const std::string GetInfoCmd = "GI";
|
||||
// const std::string PatchMemoryCmd = "PM";
|
||||
const std::string InitCmd = "IN";
|
||||
const std::string RunCmd = "RU";
|
||||
const std::string EndCmd = "EN";
|
||||
@@ -55,9 +53,6 @@ const std::string EndInstruction = "end";
|
||||
const std::string ListenerInstruction = "listener";
|
||||
const std::string LoadModuleInstruction = "loadModule";
|
||||
const std::string UnloadModuleInstruction = "unloadModule";
|
||||
const std::string SocksInstruction = "socks";
|
||||
const std::string GetInfoInstruction = "getInfo";
|
||||
const std::string PatchMemoryInstruction = "patchMemory";
|
||||
|
||||
const std::string StartInstruction = "start";
|
||||
const std::string StopInstruction = "stop";
|
||||
@@ -68,14 +63,11 @@ class CommonCommands
|
||||
public:
|
||||
CommonCommands()
|
||||
{
|
||||
m_commonCommands.push_back(SleepInstruction);
|
||||
m_commonCommands.push_back(EndInstruction);
|
||||
m_commonCommands.push_back(ListenerInstruction);
|
||||
m_commonCommands.push_back(LoadModuleInstruction);
|
||||
m_commonCommands.push_back(UnloadModuleInstruction);
|
||||
m_commonCommands.push_back(SocksInstruction);
|
||||
// m_commonCommands.push_back(GetInfoInstruction);
|
||||
// m_commonCommands.push_back(PatchMemoryInstruction);
|
||||
m_commonCommands.push_back(SleepInstruction);
|
||||
}
|
||||
|
||||
int getNumberOfCommand()
|
||||
@@ -105,13 +97,6 @@ class CommonCommands
|
||||
return LoadModuleInstruction;
|
||||
else if(cmd==UnloadC2ModuleCmd)
|
||||
return UnloadModuleInstruction;
|
||||
else if(cmd==Socks5Cmd)
|
||||
return SocksInstruction;
|
||||
// else if(cmd==GetInfoCmd)
|
||||
// return GetInfoInstruction;
|
||||
// else if(cmd==PatchMemoryCmd)
|
||||
// return PatchMemoryInstruction;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -157,26 +142,6 @@ class CommonCommands
|
||||
output += "exemple:\n";
|
||||
output += " - unloadModule assemblyExec \n";
|
||||
}
|
||||
// else if(cmd==Socks5Cmd)
|
||||
// {
|
||||
// output = "socks: \n";
|
||||
// output += "Start a socks5 server on the TeamServer and tunnel the traffic to the Beacon.\n";
|
||||
// output += "The tunneling is done using the communication protocol of the beacon.\n";
|
||||
// output += "Only one socks5 server can be opened at a time.\n";
|
||||
// output += "exemple:\n";
|
||||
// output += " - socks start 1080 \n";
|
||||
// output += " - socks stop \n";
|
||||
// }
|
||||
// else if(cmd==GetInfoCmd)
|
||||
// {
|
||||
// output = "getInfo: \n";
|
||||
// output += "TODO\n";
|
||||
// }
|
||||
// else if(cmd==PatchMemoryCmd)
|
||||
// {
|
||||
// output = "patchMemory: \n";
|
||||
// output += "TODO\n";
|
||||
// }
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -363,59 +328,6 @@ class CommonCommands
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Socks5
|
||||
//
|
||||
// else if(instruction==SocksInstruction)
|
||||
// {
|
||||
// if(splitedCmd.size()>=2)
|
||||
// {
|
||||
// if(splitedCmd[1]==StartInstruction)
|
||||
// {
|
||||
// if(splitedCmd.size()>=3)
|
||||
// {
|
||||
// int port=-1;
|
||||
// try
|
||||
// {
|
||||
// port = std::atoi(splitedCmd[2].c_str());
|
||||
// }
|
||||
// catch (const std::invalid_argument& ia)
|
||||
// {
|
||||
// std::cerr << "Invalid argument: " << ia.what() << '\n';
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
// c2Message.set_instruction(Socks5Cmd);
|
||||
// c2Message.set_cmd(StartCmd);
|
||||
// c2Message.set_data(splitedCmd[2].data(), splitedCmd[2].size());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::string errorMsg = "socks start: not enough arguments";
|
||||
// c2Message.set_returnvalue(errorMsg);
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// else if(splitedCmd[1]==StopInstruction)
|
||||
// {
|
||||
// c2Message.set_instruction(Socks5Cmd);
|
||||
// c2Message.set_cmd(StopSocksCmd);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::string errorMsg = getHelp(Socks5Cmd);
|
||||
// c2Message.set_returnvalue(errorMsg);
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::string errorMsg = getHelp(instruction);
|
||||
// c2Message.set_returnvalue(errorMsg);
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,15 @@
|
||||
#include <C2Message.hpp>
|
||||
|
||||
|
||||
enum OSCompatibility {
|
||||
OS_NONE = 0,
|
||||
OS_LINUX = 1 << 0, // 0001
|
||||
OS_MAC = 1 << 1, // 0010
|
||||
OS_WINDOWS = 1 << 2, // 0100
|
||||
OS_ALL = OS_LINUX | OS_MAC | OS_WINDOWS
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ModuleCmd
|
||||
//
|
||||
@@ -68,6 +77,7 @@ public:
|
||||
virtual int followUp(const C2Message &c2RetMessage) {return 0;};
|
||||
virtual int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg) {return 0;};
|
||||
virtual int recurringExec (C2Message& c2RetMessage) {return 0;};
|
||||
virtual int osCompatibility () {return OS_NONE;};
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
|
||||
@@ -16,6 +16,10 @@ public:
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
int followUp(const C2Message &c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string execPowershell(const std::string& cmd);
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string printWorkingDirectory();
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string rev2self();
|
||||
|
||||
@@ -18,6 +18,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string execBash(const std::string& cmd);
|
||||
|
||||
@@ -17,6 +17,10 @@ public:
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
int recurringExec(C2Message& c2RetMessage);
|
||||
int followUp(const C2Message &c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ int SpawnAs::init(std::vector<std::string> &splitedCmd, C2Message &c2Message)
|
||||
}
|
||||
|
||||
|
||||
//TODO look at https://github.com/antonioCoco/RunasCs/blob/master/RunasCs.cs
|
||||
int SpawnAs::process(C2Message &c2Message, C2Message &c2RetMessage)
|
||||
{
|
||||
std::string cmd = c2Message.cmd();
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string stealToken(int pid);
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string iterProcess(const std::string& path, int depth);
|
||||
|
||||
@@ -15,6 +15,10 @@ public:
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_LINUX | OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
|
||||
int init(std::vector<std::string>& splitedCmd, C2Message& c2Message);
|
||||
int process(C2Message& c2Message, C2Message& c2RetMessage);
|
||||
int osCompatibility()
|
||||
{
|
||||
return OS_WINDOWS;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user