-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyloggerBasicTest.c
45 lines (34 loc) · 946 Bytes
/
keyloggerBasicTest.c
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
#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
int main() {
FILE *logfile;
int key;
// Inicializa a biblioteca ncurses
initscr();
cbreak();
noecho();
// Abre o arquivo de log para escrita
logfile = fopen("log.txt", "w");
if (logfile == NULL) {
printf("Erro ao abrir o arquivo de log.");
endwin();
return 1;
}
printw("Pressione ESC para sair.\n");
refresh();
// Loop infinito para capturar as teclas digitadas
while (1) {
key = getch();
if (key == 27) { // 27 é o código ASCII para ESC
break;
}
fputc(key, logfile); // Grava a tecla no arquivo de log
fflush(logfile); // Limpa o buffer para garantir a escrita imediata
}
fclose(logfile); // Fecha o arquivo de log
// Encerra a biblioteca ncurses
endwin();
printf("Log salvo com sucesso em log.txt.\n");
return 0;
}