PRO-C226: Keylogger
PRO-C226: Keylogger
Keylogger
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.
● Initialize variable smtp_server, SMTP service is used to send email from a device or
app using gmail account
● Initialize variable “sender_email” which will store email address where you want to
send key logs
● 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.
5. Any error that occurs should be passed to an exception and the that should be
printed using print()
● Import pynput
● The pynput library has two function keys and listener, listener will listen to all
keys.
● import send_email
7. To check what key is pressed we will create a function which will log our pressed
keys
● 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
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.
● 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
● 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
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 __________________________