Forum Thread: Keylogger?

If I write a keylogger in python and it is meant to run on a windows computer will it still run on a imac computer....I am stuck between almost being positive that it won't but I am not sure....and if not what modules will I need to make it run on a mac computer??? thank you

Join the Next Reality AR Community

Get the latest in AR — delivered straight to your inbox.

4 Responses

Windows uses the PE file format which is not supported by Mac's OS. You will need to compile it to a suitable binary format which OS X can use.

But python is an interpreted language, not compiled. However, it still would most likely not work because the feasible way of collecting keylogging would be to use a python module designed specifically for an OS's interface, and certainly Windows and OS X have completely different APIs for keyboard/HID events.

BUUTTT.... what OP could do is to write a function that collects keystrokes by first determining which OS is being used and then based on that information, proceed to use the appropriate API to capture keyboard events. For example, you could have something like this:

import os

def get_key():
if == 'darwin': # darwin is the OS that OS X is built on
* put code here for recording keystrokes in OS X *
elif == 'nt' # windows
* put code here for recording keystrokes in Windows *

I assumed he was building an executable for Windows using py2exe or similar.

Share Your Thoughts

  • Hot
  • Active