Esempio n. 1
0
def readline_init(session):
    """
    init readline settings
    """
    cmds_dict = cmds_init(session)
    command_list = []

    for _, percmd in cmds_dict.items():
        command_list += percmd.names

    # add other keywords
    command_list += [
        "/tmp/", "attack", "quit", "reset", "clear", "app:", "port:", "ip:",
        "cidr:", "country:", "city:", "subdivisions:", "device:", "ver:"
    ]
    # add from list_exp
    command_list += run_exploits(do_print=False)

    if not os.path.exists(HISTFILE):
        os.system('touch {}'.format(HISTFILE))
    with open(HISTFILE) as histf:
        for line in histf:
            for item in line.strip().split():
                command_list.append(item)

    # List ./data
    try:
        data_path = os.path.join(os.path.expanduser("~"), ".mec/data")

        for item in os.listdir(data_path):
            command_list.append(item)
    except FileNotFoundError:
        colors.colored_print("[-] Please run install.py first", colors.RED)
        sys.exit(1)

    return list(dict.fromkeys(command_list))
Esempio n. 2
0
File: core.py Progetto: jm33-m0/mec
    def attack(self):
        '''
        handles attack command
        '''
        self.use_proxy = console.yes_no(
            '[?] Do you wish to use proxy_pool/proxychains?')

        if self.use_proxy:
            if shutil.which("proxychains4") is None:
                console.print_error("proxychains4 not found")

                return

        # sleep between two subprocess open
        sleep_seconds = console.input_check("\n[?] Wait how many seconds" +
                                            " before each process launch?\n" +
                                            "    (Set it to 0 when you want to use 100% CPU" +
                                            " / bandwidth\n    Recommened value: 0.1)\n" +
                                            "\n[=] Your input: ",
                                            check_type=float)
        answ = console.input_check(
            '\n[?] Do you wish to use\
            \n\n    [1] built-in exploits\
            \n    [2] or launch your own manually?\
            \n\n[=] Your choice: ',
            choices=['1', '2', 'built-in', 'manually'])

        if answ in ['1', 'built-in']:
            print(
                colors.CYAN +
                colors.BOLD +
                '\n[?] Choose a module from: ' +
                colors.END +
                '\n')
            colors.colored_print(futil.BUILT_IN, colors.GREEN)
            module = console.input_check(
                "[?] Choose your exploit module: ",
                choices=futil.BUILT_IN.split('\n'),
                allow_blank=False)

            try:
                scanner_instance = exploit_exec.EXPLOIT_DICT.get(module)(self)

                if scanner_instance is None:
                    return

                scanner_instance.sleep_seconds = sleep_seconds
                scanner_instance.scan()

                return

            except (EOFError, KeyboardInterrupt, SystemExit):
                return

        # run custom exploits
        print(
            colors.CYAN +
            colors.UNDERLINE +
            colors.BOLD +
            "\nWelcome, in here you can invoke your own exploit\n" +
            colors.END)
        cmd.run_exploits()

        exploit = console.input_check(
            "\n[*] Enter the path (eg. test/test) to your exploit: ",
            choices=futil.list_exp())

        jobs = int(
            console.input_check("[?] How many processes each time? ", check_type=int))

        custom_args = console.input_check(
            "[*] Addtional args for this exploit (other than `-t <target>`): ").strip().split()

        # parse user's exploit name
        exec_path = exploit.split('/')[1:]
        work_path = exploit.split('/')[:-1]
        exec_path = '/'.join(exec_path)
        work_path = '/'.join(work_path)

        # args as parameter for scanner
        scanner_instance = Scanner(work_path, exec_path,
                                   custom_args,
                                   jobs, sleep_seconds, self)
        # start scanner
        scanner_instance.scan()