Esempio n. 1
0
File: main.py Progetto: jm33-m0/mec
def main():
    '''
    handles user interface
    '''
    colors.colored_print("[*] Default target list is ./data/ip_list.txt",
                         colors.CYAN)
    SESSION.ip_list = SESSION.init_dir + '/data/ip_list.txt'

    futil.write_file(text=f"{os.getpid()}", filepath=SESSION.pidfile)

    while True:
        try:
            if os.getcwd() != core.MECROOT:
                os.chdir(core.MECROOT)
            input_cmd = rlinit.prompt(session=SESSION)

            try:
                cmd.cmd_handler(SESSION, input_cmd)
            except (KeyboardInterrupt, EOFError, SystemExit):
                sys.exit(0)

        except FileNotFoundError:
            console.print_error(f"[-] {core.MECROOT} not found???")
            sys.exit(1)

        except KeyboardInterrupt:
            answ = console.yes_no("\n[?] Are you sure to exit?")

            if answ:
                futil.check_kill_process('ss-proxy')
                sys.exit(0)
            else:
                continue
Esempio n. 2
0
def cmd_handler(session, user_cmd):
    '''
    handles user input in console
    '''
    if user_cmd == '':
        return

    # parse user_cmd
    try:
        split_cmd = str(user_cmd).lower().strip().split()
        user_cmd = split_cmd[0]
        args = split_cmd[1:]
    except IndexError:
        return

    if user_cmd in ('q', 'quit'):
        futil.check_kill_process('ss-proxy')
        sys.exit(0)

    elif user_cmd in ('x', 'reset'):
        os.system("reset")

    elif user_cmd in ('c', 'clear'):
        os.system("clear")

    elif user_cmd in ("attack", "e"):
        session.attack()

    else:
        # COMMANDS
        cmds_init(session)
        cmd_obj = COMMANDS.get(user_cmd, None)
        if cmd_obj is not None:
            cmd_obj.run(args)
            return

        # shell command
        try:
            print(colors.BLUE + colors.BOLD + "[*] Exec: " + colors.END,
                  colors.GREEN + user_cmd, colors.END)
            os.system(user_cmd)
        except (EOFError, KeyboardInterrupt, SystemExit):
            return
Esempio n. 3
0
def main():
    '''
    handles user interface
    '''
    rlinit.CMD_LIST = rlinit.readline_init(SESSION)

    answ = str(
        input(colors.CYAN + '[?] Use ip_list.txt as target list? [y/n] ' +
              colors.END)).strip()

    if answ.lower() == 'n':
        os.system("ls ~/.mec/data")
        SESSION.ip_list = SESSION.init_dir + '/data/' + \
            console.input_check(
                '[=] Choose your target IP list, eg. ip_list.txt ',
                choices=os.listdir(core.MECROOT + '/data'))

    while True:
        try:
            input_cmd = input(colors.CYAN + colors.BOLD + "\nmec > " +
                              colors.END)

            try:
                cmd.cmd_handler(SESSION, input_cmd)
            except (KeyboardInterrupt, EOFError, SystemExit):
                sys.exit(0)

        except KeyboardInterrupt:

            try:
                answ = input("\n[?] Are you sure to exit? [y/n] ")
            except KeyboardInterrupt:
                print("\n[-] Okay okay, exiting immediately...")
                futil.check_kill_process('ss-proxy')
                sys.exit(0)

            if answ.lower() == 'y':
                futil.check_kill_process('ss-proxy')
                sys.exit(0)
            else:
                continue
Esempio n. 4
0
File: cmd.py Progetto: m4rm0k/mec
def run_quit(**kwargs):
    """
    Quit mec
    """
    futil.check_kill_process('ss-proxy')
    sys.exit(0)