#include #include #include #include #include // GLOBALS httpserver::webserver ws = httpserver::create_webserver(8665) .use_ssl() .https_mem_key("server.key") .https_mem_cert("server.crt"); class command_and_control : public httpserver::http_resource { public: std::vector> retrievecreds(std::string sFile) { std::vector> sCreds; std::vector sUsernames; std::vector sPasswords; std::fstream fCreds; fCreds.open("creds", std::ios::in); char ch; bool bUsername = true; std::string sUsername = ""; std::string sPassword = ""; while (true) { fCreds >> ch; if (fCreds.eof()) { sPasswords.push_back(sPassword); break; } if (ch == ':') { bUsername = false; fCreds >> ch; sUsernames.push_back(sUsername); sUsername = ""; } if (ch == '\n') { bUsername = true; fCreds >> ch; sPasswords.push_back(sPassword); sPassword = ""; } if (bUsername) { sUsername += ch; } else { sPassword += ch; } } sCreds.push_back(sUsernames); sCreds.push_back(sPasswords); return sCreds; } bool verifycreds(std::vector>sCreds, std::string sUsername, std::string sPassword) { for (int iUsernameIndex = 0; iUsernameIndex < sCreds[0].size(); iUsernameIndex++) { if (sCreds[0][iUsernameIndex] == sUsername) { for (int iPasswordIndex = 0; iPasswordIndex < sCreds[1].size(); iPasswordIndex++) { if (sCreds[1][iPasswordIndex] == sPassword) { return true; } } } } return false; } std::vector>sCreds = retrievecreds("creds"); const std::shared_ptr render(const httpserver::http_request& req) { if (verifycreds(sCreds, req.get_user(), req.get_pass())) { return std::shared_ptr(new httpserver::string_response("Authenticated")); } return std::shared_ptr(new httpserver::string_response("Not found")); } }; void startserver() { command_and_control c2; ws.register_resource("/YVDvOraEcGwPAyjuBFzGespbRzifTpi", &c2); ws.start(false); } void prompt() { std::cout << "========== EMPEROR C2 Framework==========" << std::endl; std::cout << R"( _____ ,888888b. .d888888888b _..-'.`*'_,88888b ,'..-..`"ad88888888b. ``-. `*Y888888b. \ `Y888888b. : Y8888888b. : Y88888888b. | _,8ad88888888. : .d88888888888888b. \d888888888888888888 8888;'''`88888888888 888' Y8888888888 `Y8 :8888888888 |` '8888888888 | 8888888888 | 8888888888 | 8888888888 | ,888888888P : ;888888888' \ d88888888' _.>, 888888P' <,--''`.._>8888( `>__...--' `''` )" << std::endl; std::cout << "=========================================" << std::endl; std::string command; while (true) { std::cout << "[EMPEROR]>"; std::cin >> command; if (command == "sessions") { std::cout << "No sessions currently active" << std::endl; } if (command == "q" || command == "quit" || command == "exit") { ws.stop(); break; } } } int main (int argc, char** argv) { startserver(); prompt(); return 0; }