Beispiel #1
0
def set_launch(host, user, sshkey):
    with settings(host_string = host, user = user, key_filename = sshkey, warn_only = True):
        f = open("data/temp/setweb.sh", "w")
        f.write("cd /usr/share/set/\n")
        f.write('sudo screen -A -m -d -L -S SET /usr/share/set/setoolkit\n')
        f.write("sudo screen -ls")
        f.close()
        file_upload(host, user, "data/temp/setweb.sh", "/tmp/setweb.sh", sshkey)
        screen = run("bash /tmp/setweb.sh")
        sleep(1)
        return screen
Beispiel #2
0
def set_auto(host, user, autofile, sshkey):
    with settings(host_string = host, user = user, key_filename = sshkey, warn_only = True):
        uploaddir = "/tmp/autoset.txt"
        file_upload(host, user, autofile, uploaddir, sshkey)
        f = open("data/temp/setweb.sh", "w")
        f.write("cd /usr/share/set/\n")
        f.write('sudo screen -A -m -d -L -S SET "/usr/share/set/set-automate" "/tmp/autoset.txt"\n')
        f.write("sudo screen -ls")
        f.close()
        file_upload(host, user, "data/temp/setweb.sh", "/tmp/setweb.sh", sshkey)
        screen = run("bash /tmp/setweb.sh")
        sleep(1)
        return screen
Beispiel #3
0
def se_launch(idic, user, sshkey):

    # Parse the config file and unpack user options from autoset menu
    config = src.core.config.get_config()

    while True:
        try:
            sleep(2)
            print yellow("Attempting to establish a connection to %s" % idic["ip"])
            fabfunky.conn_est(idic["ip"], user, sshkey)
            break
        except Exception:
            print red("Instance is still initializing...")
            pass

    apache_status = apache_conf(config["set_config"])

    if apache_status == 'ON':

        if user == 'root':
            rfile = '/%s/set_config' % user
        else:
            rfile = '/home/%s/set_config' % user

        #uploads local SET config file
        fabfunky.file_upload(idic["ip"], user, config["set_config"], rfile, sshkey)
        fabfunky.move(idic["ip"], user, rfile, "/usr/share/set/config/", sshkey)
        print green("\nStarting Apache....")
        fabfunky.apache_start(idic["ip"], user, sshkey)
        print green("Apache Started...")

    else:
        pass

    interactive = menus.inter_shell_menu()

    if interactive is False:

        print green("\nLaunching SET...")
        set_launch(idic["ip"], user, sshkey)
        print green("\nSET Launched on %s") % idic["ip"]

    elif interactive is True:

        print green("\nLaunching SET...")
        screen = set_launch(idic["ip"], user, sshkey)
        print green("\nSET Launched on %s") % idic["ip"]

        screen = screen.strip().split()
        sleep(2)
        if '.SET' in screen[5]:
            print screen[5]
            cmd = 'sudo screen -r %s' % screen[5]
            print red("\nDropping into a SSH session....")
            print green("SET Launched %s") % idic["ip"]
            print yellow("\nRemember if you want to disconnect from the screen session hit CTRL+A+D to detatch and exit...\n")
            sleep(2)
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)
        else:
            cmd = None
            print red("\nDropping into a SSH session....\n")
            print red("No screen session returned.")
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)
Beispiel #4
0
def java_pyi(idic, user, sshkey):

    # Parse the config file and unpack user options from autoset menu
    config = src.core.config.get_config()

    web_clone = menus.autoset_file_menu()
    print green("\nCreating custom SET automation file...")
    autofile = autoset.java_app_pyinject(idic["ip"], web_clone)
    print green("Custom SET automation file created.\n")

    # Attempts to establish an SSH conection to the instance
    while True:
        try:
            sleep(2)
            print yellow("Attempting to establish a connection to %s" % idic["ip"])
            fabfunky.conn_est(idic["ip"], user, sshkey)
            break
        except Exception:
            print red("Instance is still initializing...")
            pass

    # Check apache status within local config file and if set to ON uploads the local config
    apache_status = apache_conf(config["set_config"])

    if apache_status == 'ON':

        if user == 'root':
            rfile = '/%s/set_config' % user
        else:
            rfile = '/home/%s/set_config' % user

        #uploads local SET config file
        fabfunky.file_upload(idic["ip"], user, config["set_config"], rfile, sshkey)
        fabfunky.move(idic["ip"], user, rfile, "/usr/share/set/config/", sshkey)

        print green("\nStarting Apache....")
        fabfunky.apache_start(idic["ip"], user, sshkey)
        print green("Apache Started...")

    else:
        pass

    # Checks to see if the user wants an interactive shell or connect via ssh manually
    interactive = menus.inter_shell_menu()

    if interactive is False:

        print green("\nLaunching SET...")
        set_auto(idic["ip"], user, autofile, sshkey)
        print green("\nSET Launched Java Applet (PyInjector)..... browse to http://%s to test") % idic["ip"]

    elif interactive is True:

        print green("\nLaunching SET...")
        screen = set_auto(idic["ip"], user, autofile, sshkey)

        screen = screen.strip().split()
        sleep(2)
        if '.SET' in screen[5]:
            print screen[5]
            cmd = 'sudo screen -r %s' % screen[5]
            print red("\nDropping into a SSH shell....")
            print green("SET Launched Java Applet (PyInjector)..... browse to http://%s to test") % idic["ip"]
            print yellow("\nRemember if you want to disconnect from the screen session hit CTRL+A+D to detatch and exit...\n")
            sleep(2)
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)
        else:
            cmd = None
            print red("\nDropping into a SSH shell....\n")
            print red("No screen session returned.")
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)
Beispiel #5
0
def se_launch(idic, user, sshkey):

    # Parse the config file and unpack user options from autoset menu
    config = src.core.config.get_config()

    while True:
        try:
            sleep(2)
            print yellow("Attempting to establish a connection to %s" %
                         idic["ip"])
            fabfunky.conn_est(idic["ip"], user, sshkey)
            break
        except Exception:
            print red("Instance is still initializing...")
            pass

    apache_status = apache_conf(config["set_config"])

    if apache_status == 'ON':

        if user == 'root':
            rfile = '/%s/set_config' % user
        else:
            rfile = '/home/%s/set_config' % user

        #uploads local SET config file
        fabfunky.file_upload(idic["ip"], user, config["set_config"], rfile,
                             sshkey)
        fabfunky.move(idic["ip"], user, rfile, "/usr/share/set/config/",
                      sshkey)
        print green("\nStarting Apache....")
        fabfunky.apache_start(idic["ip"], user, sshkey)
        print green("Apache Started...")

    else:
        pass

    interactive = menus.inter_shell_menu()

    if interactive is False:

        print green("\nLaunching SET...")
        set_launch(idic["ip"], user, sshkey)
        print green("\nSET Launched on %s") % idic["ip"]

    elif interactive is True:

        print green("\nLaunching SET...")
        screen = set_launch(idic["ip"], user, sshkey)
        print green("\nSET Launched on %s") % idic["ip"]

        screen = screen.strip().split()
        sleep(2)
        if '.SET' in screen[5]:
            print screen[5]
            cmd = 'sudo screen -r %s' % screen[5]
            print red("\nDropping into a SSH session....")
            print green("SET Launched %s") % idic["ip"]
            print yellow(
                "\nRemember if you want to disconnect from the screen session hit CTRL+A+D to detatch and exit...\n"
            )
            sleep(2)
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)
        else:
            cmd = None
            print red("\nDropping into a SSH session....\n")
            print red("No screen session returned.")
            fabfunky.interactive_shell(idic["ip"], user, cmd, sshkey)