summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e39f0d2)
Put microseconds behind a flag.
This makes it harder to do timing analysis on the log file to try to
turn this into a keylogger.
(More precise timing information is still available to an on-line attack
by watching the flush timings or by watching the CPU usage and run state
of the process.)
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include <sysexits.h>
#include <unistd.h>
#include <sysexits.h>
#include <unistd.h>
+int main (int argc, char **argv)
+ int print_usec = argc > 1 && strcmp(argv[1], "--usec") == 0;
int fd = open("/dev/input/by-path/platform-i8042-serio-0-event-kbd", O_RDONLY);
if (fd < 0) {
err(EX_NOINPUT, "Could not open keyboard event file");
}
int fd = open("/dev/input/by-path/platform-i8042-serio-0-event-kbd", O_RDONLY);
if (fd < 0) {
err(EX_NOINPUT, "Could not open keyboard event file");
}
while (read(fd, &i, sizeof(i)) == sizeof(i)) {
if (i.type == 1 && i.value == 1) {
while (read(fd, &i, sizeof(i)) == sizeof(i)) {
if (i.type == 1 && i.value == 1) {
- printf("%ld.%ld\n", i.time.tv_sec, i.time.tv_usec);
+ if (print_usec) {
+ printf("%ld.%ld\n", i.time.tv_sec, i.time.tv_usec);
+ } else {
+ printf("%ld\n", i.time.tv_sec);
+ }