0% found this document useful (0 votes)
4 views6 pages

PRO-C226: Keylogger

The document outlines a class focused on keyloggers, detailing their functionality, legitimate uses, and potential for misuse. It covers the coding process for creating a keylogger using Python, including libraries like smtplib and pynput, and explains how to send captured keystrokes via email. The class also sets the stage for future lessons on viruses.

Uploaded by

luniyalovekush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

PRO-C226: Keylogger

The document outlines a class focused on keyloggers, detailing their functionality, legitimate uses, and potential for misuse. It covers the coding process for creating a keylogger using Python, including libraries like smtplib and pynput, and explains how to send captured keystrokes via email. The class also sets the stage for future lessons on viruses.

Uploaded by

luniyalovekush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PRO-C226

Keylogger

What is our GOAL for this CLASS?


In this class, we have learned about keyloggers and how to send user data to others without
taking permission

What did we ACHIEVE in the class TODAY?


● We understood about Keylogger
● We understood how Keyloggers Work
● We understood the use of SMTP in key loggers

Which CONCEPTS/ CODING BLOCKS did we cover today?

● We used the libraries, smtplib,ssl


● We used key events to capture
PRO-C226

Understanding concepts:

keystroke :
A keystroke is any action you perform on your keyboard. A keystroke is how you
communicate with your computer. Each keystroke transmits a signal to tell your computer
what you want it to do.

keylogger:
Keeping track of keystrokes and making log of all the keys you pressed on your keyboard is
known as “keylogger”

Keyloggers are used for legitimate purposes and can be misused by criminals to steal your
data and data captured by keyloggers can be sent back to attackers via email or uploaded
to predefined websites, databases, or FTP servers.

SMTP Server:
With the smtplib module, you can send email to any Internet machine with an SMTP server.

How did we DO the activities?


1. Make two python files on one “keylogger.py” and second is “sendemail.py”
2. Start with sendemail.py
● Start with sendemail.py
● For sending email we need to use the SMTP library.
● Install smtplib , ssl.
pip install secure-smtplib
pip install ssl

● Import smtplib, ssl

3. Create function sendEmail and pass the argument “message”


PRO-C226

● Initialize variable smtp_server, SMTP service is used to send email from a device or
app using gmail account

● Set the port no 587, which is used for smtp protocol

● Initialize variable “sender_email” which will store email address where you want to
send key logs

● Write down your exact an “original password” of your email id

4. Write Logic to log in to server and send email

● Bind server_address with port

● Using StartTLS, an email client can inform the email server that it wants to
upgrade from an insecure to secure connection using TLS or SSL. SSL context
to secure the connection.

● Using the password provided by sender_email, “serve.login” tries to log into


that particular id

● Using “sendmail” function, it will send an email on mention email addresses -


sender_email, receiver_email, along with key logs, i.e., in form of a message.
PRO-C226

5. Any error that occurs should be passed to an exception and the that should be
printed using print()

6. To control and monitor input devices we need to use pynput library

● Import pynput

● The pynput library has two function keys and listener, listener will listen to all
keys.

● Now we need to import our send_email code too

● import send_email

7. To check what key is pressed we will create a function which will log our pressed
keys

● Print pressed keys

● Make global variables keys & count


PRO-C226

● Using the append() method it will add a new single element in the end of the
previous list which we are saving in the keys array, we are adding into the
array .
● Increment the count by 1

● When the character count is beyond 20, only then it call our function email
which will take all the keys Start counting again from zero

● Send the pressed keys information via email function

8. In the next step, let's create a function email that takes all information about keys
pressed and sends out in the form of a message to the email address we specified.

● Initialize variable message

● For loops is used to sanitize each and every output from the array keys

● Variable “ k “ It will take all the values that is appended in the array

● All key presses separated by an inverted comma are replaced by nothing in


order to make it readable

● If key pressed is space, then put space if any other key is pressed like shift up,
shift down, just print the information and replace it with nothing

● Each key pressed information should be added to the message variable

● Using send_email function message using email


PRO-C226

9. Now we need to check any key released ,On released function will be checking the
key is escaped or not it will return false and stop the listener and close the program

10. Listener will listen key pressed and release key , basically we will call this function
on_press and on_reelease it will record pressed key or release key

What’s NEXT?
In the next class we will learn about virus __________________________

Expand Your Knowledge

You might also like