#include "../Inject.hpp" #include "../../ModuleCmd/Tools.hpp" #ifdef __linux__ #elif _WIN32 #include #endif bool testInject(); int main() { bool res; std::cout << "[+] testInject" << std::endl; res = testInject(); if(res) std::cout << "[+] Sucess" << std::endl; else std::cout << "[-] Failed" << std::endl; return 0; } bool testInject() { std::unique_ptr inject = std::make_unique(); std::string shellCodeFile; { #ifdef _WIN32 shellCodeFile="C:\\Windows\\System32\\calc.exe"; int pid = launchProcess("C:\\Windows\\System32\\notepad.exe"); std::cout << "notepad pid " << pid << std::endl; std::vector splitedCmd; splitedCmd.push_back("inject"); splitedCmd.push_back("-e"); splitedCmd.push_back(shellCodeFile); splitedCmd.push_back(std::to_string(pid)); C2Message c2Message; C2Message c2RetMessage; inject->init(splitedCmd, c2Message); inject->process(c2Message, c2RetMessage); std::string output = "\n\noutput:\n"; output += c2RetMessage.returnvalue(); output += "\n"; std::cout << output << std::endl; HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); if (hProc) { TerminateProcess(hProc, 0); CloseHandle(hProc); } #endif } return true; }