Skip to content

Repository files navigation

macOS Mouse and Keyboard Sniffer

Overview

This project provides a macOS-based keylogger that captures both keyboard and mouse events. The keylogger is implemented in Objective-C and uses Apple's Carbon and ApplicationServices frameworks to monitor user input. It includes a macOS-specific helper script written in AppleScript to prompt users to grant necessary permissions.

Features

  • Event Capture: Logs keyboard presses and mouse interactions (clicks, drags).
  • Selective Monitoring: Can capture only mouse events (-mouse), only keyboard events (-keyboard), or both.
  • Assistive Access Setup: Includes an AppleScript (mac_change_security_settings.scpt) to guide users through granting necessary permissions in macOS System Preferences.

Requirements

  • macOS: Tested on macOS 10.12 or later.
  • Permissions: Requires "Accessibility" permissions for capturing input.

Building the Project

  1. Using Xcode:
    • Open the project in Xcode.
    • Select Product > Build to compile.
  2. Using clang:
    • Run:
      clang -o sniffMK sniffMK.m -framework Cocoa -framework Carbon

Running the Keylogger

To start the keylogger, run the compiled executable as follows:

  • Mouse-only Events:
    sudo ./sniffMK -mouse
  • Keyboard-only Events:
    sudo ./sniffMK -keyboard
  • Both Events (default):
    sudo ./sniffMK

Note: On first run, macOS may prompt to grant Accessibility permissions. See the AppleScript section below to automate permission setup. Modified from Patrick Wardle's Objective C tutorial.

Permission Automation with AppleScript

The included AppleScript (mac_change_security_settings.scpt) checks if Accessibility permissions are enabled for the keylogger. If permissions are not granted, it guides the user through System Settings to enable them.

To run the script:

  1. Open mac_change_security_settings.scpt in the Script Editor.
  2. Execute the script to prompt permission setup.

Security Disclaimer

This project is for educational or testing purposes. Ensure usage complies with applicable laws and policies.

About

Attempting to build a keylogger

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages