MCPcopy
hub / github.com/NullArray/AutoSploit / terminal_main_display

Method terminal_main_display

lib/term/terminal.py:508–748  ·  view source on GitHub ↗
(self, tokens, extra_commands=None, save_history=True)

Source from the content-addressed store, hash-verified

506 lib.output.error(str(e).strip())
507
508 def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
509 # idk what the fuck the problem is but this seems to fix it so...
510 import lib.output
511 """
512 terminal main display
513 """
514 lib.output.warning(
515 "no arguments have been parsed at run time, dropping into terminal session. "
516 "to get help type `help` to quit type `exit/quit` to get help on "
517 "a specific command type `command help`"
518 )
519
520 if extra_commands is not None:
521 for command in extra_commands:
522 self.external_terminal_commands.append(command)
523 self.reflect_memory()
524 while not self.quit_terminal:
525 try:
526 lib.settings.auto_completer(self.internal_terminal_commands)
527 try:
528 choice_type, choice = self.get_choice()
529 if choice_type == "unknown":
530 sims = lib.settings.find_similar(
531 choice,
532 self.internal_terminal_commands,
533 self.external_terminal_commands
534 )
535 if len(sims) != 0:
536 max_sims_display = 7
537 print(
538 "no command '{}' found, but there {} {} similar command{}".format(
539 choice,
540 "are" if len(sims) > 1 else "is",
541 len(sims),
542 "s" if len(sims) > 1 else ""
543 )
544 )
545 if len(sims) > max_sims_display:
546 print("will only display top {} results".format(max_sims_display))
547 for i, cmd in enumerate(sims, start=1):
548 if i == max_sims_display:
549 break
550 print(cmd)
551 print("{}: command not found".format(choice))
552 else:
553 print("{} command not found".format(choice))
554 self.history.append(choice)
555 elif choice_type == "external":
556 self.do_terminal_command(choice)
557 self.history.append(choice)
558 else:
559 try:
560 choice_data_list = choice.split(" ")
561 if choice_data_list[-1] == "":
562 choice_data_list = None
563 except:
564 choice_data_list = None
565 if choice == "?" or choice == "help":

Callers 1

mainFunction · 0.95

Calls 15

reflect_memoryMethod · 0.95
get_choiceMethod · 0.95
do_terminal_commandMethod · 0.95
do_display_usageMethod · 0.95
do_display_externalMethod · 0.95
do_display_historyMethod · 0.95
do_quit_terminalMethod · 0.95
do_view_gatheredMethod · 0.95
do_clean_hostsMethod · 0.95
do_add_single_hostMethod · 0.95
do_exploit_targetsMethod · 0.95

Tested by

no test coverage detected