I have a docker that run on window for trying programming on linux. But the input (which usually located in /dev/input/evt** in ubuntu) is not at this location. I also tried with the option -it as mentioned in this post: Intercept Keyboard Key presses into a docker container But it still doesn't work. My run arguments for vscode devdockercontainer.json:
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"-it",
"--cpus", //Limit CPU usage
"2.5"
]
My keylogger that works on ubuntu:
int main(int argc, char **argv)
{
int fd, bytes;
struct input_event data;
const char *pDevice = "/dev/input/event4";
// Open Keyboard
fd = open(pDevice, O_RDONLY | O_NONBLOCK);
if (fd == -1)
{
printf("ERROR Opening %s\n", pDevice);
return -1;
}
while (1)
{
// Read Keyboard Data
bytes = read(fd, &data, sizeof(data));
if (bytes > 0)
{
printf("Keypress value=%d, type=%d, code=%d\n",
data.value, data.type, data.code);
}
else
{
sleep(1);
}
}
return 0;
}