Beispiel #1
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter([
         'show', 'name', 'layer', 'dump', 'layers', 'preconditions',
         'postconditions', 'executions', 'intercept', 'timestamp',
         'version', 'save', 'description', 'spoof', 'clear', 'back'
     ])
     # Initialization of the command history
     history = FileHistory(join(self._polym_path, '.tinterface_history'))
     while True:
         try:
             command = prompt(HTML("<bold>PH:cap/<red>t%d</red> > </bold>" %
                                   self._index),
                              history=history,
                              completer=completer,
                              complete_style=CompleteStyle.READLINE_LIKE,
                              auto_suggest=AutoSuggestFromHistory(),
                              enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         command = command.split(" ")
         if command[0] in self.EXIT:
             self.exit_program()
         elif command[0] in self.RET:
             break
         elif command[0] == "name":
             self._name(command)
         elif command[0] in ["dump", "d"]:
             self._dump(command)
         elif command[0] in ["layer", "l"]:
             self._layer(command)
         elif command[0] in ['precs', 'preconditions']:
             self._conditions(command, 'preconditions')
         elif command[0] in ['posts', 'postconditions']:
             self._conditions(command, 'postconditions')
         elif command[0] in ['execs', 'executions']:
             self._conditions(command, 'executions')
         elif command[0] in ["show", "s"]:
             self._show(command)
         elif command[0] in ["intercept", "i"]:
             self._intercept(command)
         elif command[0] in ["layers", "ls"]:
             self._layers(command)
         elif command[0] == "timestamp":
             print(self._t.timestamp, '\n')
         elif command[0] == "version":
             self._version(command)
         elif command[0] in ['desc', 'description']:
             self._description(command)
         elif command[0] == "save":
             self._save(command)
         elif command[0] in ["spoof"]:
             self._spoof(command)
         elif command[0] == "clear":
             Interface._clear()
         elif command[0] == "":
             continue
         else:
             Interface._wrong_command()
Beispiel #2
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter(['capture', 'spoof', 'clear'])
     history = FileHistory(self._polym_path + '/.minterface_history')
     while True:
         try:
             command = prompt(HTML("<bold><red>PH</red> > </bold>"),
                              history=history,
                              completer=completer,
                              complete_style=CompleteStyle.READLINE_LIKE,
                              auto_suggest=AutoSuggestFromHistory(),
                              enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         command = command.split(" ")
         if command[0] in self.EXIT:
             self.exit_program()
         elif command[0] in ["capture", "c"]:
             self._capture(command)
         elif command[0] in ["spoof", "s"]:
             self._spoof(command)
         elif command[0] == "clear":
             Interface._clear()
         elif command[0] == "":
             continue
         else:
             Interface._wrong_command()
Beispiel #3
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter(['show', 'dissect', 'template', 'wireshark',
                                'clear', 'back'])
     history = FileHistory(self._polym_path + '/.tlinterface_history')
     session = PromptSession(history=history)
     while True:
         try:
             command = session.prompt(HTML("<bold>PH:<red>cap</red> > </bold>"),
                                      completer=completer,
                                      complete_style=CompleteStyle.READLINE_LIKE,
                                      auto_suggest=AutoSuggestFromHistory(),
                                      enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         command = command.split(" ")
         if command[0] in self.EXIT:
             self.exit_program()
         elif command[0] in self.RET:
             break
         elif command[0] in ["show", "s"]:
             self._show(command)
         elif command[0] == "dissect":
             self._dissect(command)
         elif command[0] in ["template", "t"]:
             self._template(command)
         elif command[0] in ["wireshark", "w"]:
             self._wireshark(command)
         elif command[0] == "clear":
             Interface._clear()
         elif command[0] == "":
             continue
         else:
             Interface._wrong_command()
Beispiel #4
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter([
         'value', 'type', 'show', 'name', 'slice', 'size', 'dump', 'clear',
         'back'
     ])
     history = FileHistory(self._polym_path + '/.finterface_history')
     session = PromptSession(history=history)
     while True:
         try:
             command = session.prompt(
                 HTML("<bold>PH:cap/t%d/%s/<red>%s</red> > </bold>" %
                      (self._tindex, self._lname, self._f.name)),
                 completer=completer,
                 complete_style=CompleteStyle.READLINE_LIKE,
                 auto_suggest=AutoSuggestFromHistory(),
                 enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         try:
             command = command.rstrip().split(" ")
             if command[0] in self.EXIT:
                 self.exit_program()
             elif command[0] in self.RET:
                 break
             elif command[0] in ['v', 'value']:
                 self._value(command)
             elif command[0] in ['s', 'show']:
                 self._show(command)
             elif command[0] == 'name':
                 print(self._f.name, '\n')
             elif command[0] == "slice":
                 print(self._f.slice, '\n')
             elif command[0] == "type":
                 self._type(command)
             elif command[0] == "size":
                 print(self._f.size, '\n')
             elif command[0] in ['d', 'dump']:
                 Interface.color_dump(self._f.pkt_raw, self._f.slice.start,
                                      self._f.slice.stop)
             elif command[0] == "clear":
                 Interface._clear()
             elif command[0] == "":
                 continue
             else:
                 Interface._wrong_command()
         except SystemExit:
             raise
         except Exception as e:
             Interface._print_error(
                 "Exception: Error processing the previous command. More info:"
             )
             print(e)
Beispiel #5
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter([
         'value', 'type', 'show', 'name', 'slice', 'custom', 'size', 'dump',
         'clear', 'back'
     ])
     history = FileHistory(self._polym_path + '/.finterface_history')
     while True:
         try:
             command = prompt(
                 HTML("<bold>PH:cap/t%d/%s/<red>%s</red> > </bold>" %
                      (self._tindex, self._lname, self._f.name)),
                 history=history,
                 completer=completer,
                 complete_style=CompleteStyle.READLINE_LIKE,
                 auto_suggest=AutoSuggestFromHistory(),
                 enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         command = command.split(" ")
         if command[0] in self.EXIT:
             self.exit_program()
         elif command[0] in self.RET:
             break
         elif command[0] in ['t', 'type']:
             self._type(command)
         elif command[0] in ['v', 'value']:
             self._value(command)
         elif command[0] in ['s', 'show']:
             self._show(command)
         elif command[0] == 'name':
             self._name(command)
         elif command[0] == "slice":
             print(self._f.slice, '\n')
         elif command[0] == "custom":
             self._custom(command)
         elif command[0] == "size":
             print(self._f.size, '\n')
         elif command[0] in ['d', 'dump']:
             Interface.color_dump(self._f.raw, self._f.slice.start,
                                  self._f.slice.stop)
         elif command[0] == "clear":
             Interface._clear()
         elif command[0] == "":
             continue
         else:
             Interface._wrong_command()
Beispiel #6
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter([
         'show', 'name', 'field', 'fields', 'dump', 'recalculate', 'clear',
         'back'
     ])
     history = FileHistory(self._polym_path + '/.linterface_history')
     while True:
         try:
             command = prompt(
                 HTML("<bold>PH:cap/t%d/<red>%s</red> > </bold>" %
                      (self._tindex, self._l.name)),
                 history=history,
                 completer=completer,
                 complete_style=CompleteStyle.READLINE_LIKE,
                 auto_suggest=AutoSuggestFromHistory(),
                 enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         # Argument parsing
         command = command.split(" ")
         if command[0] in self.EXIT:
             self.exit_program()
         elif command[0] in self.RET:
             break
         elif command[0] in ["s", "show"]:
             self._show(command)
         elif command[0] == "name":
             self._name(command)
         elif command[0] in ["field", "f"]:
             self._field(command)
         elif command[0] in ["fields", "fs"]:
             self._fields(command)
         elif command[0] in ["dump", "d"]:
             self._dump(command)
         elif command[0] in ["recalculate", "r"]:
             self._recalculate(command)
         elif command[0] == "clear":
             Interface._clear()
         elif command[0] == "":
             continue
         else:
             Interface._wrong_command()
Beispiel #7
0
 def run(self):
     """Runs the interface and waits for user input commands."""
     completer = WordCompleter([
         'show', 'name', 'layer', 'dump', 'layers', 'functions',
         'intercept', 'timestamp', 'version', 'save', 'description',
         'spoof', 'clear', 'back'
     ])
     # Initialization of the command history
     history = FileHistory(join(self._polym_path, '.tinterface_history'))
     session = PromptSession(history=history)
     while True:
         try:
             command = session.prompt(
                 HTML("<bold>PH:cap/<red>t%d</red> > </bold>" %
                      self._index),
                 completer=completer,
                 complete_style=CompleteStyle.READLINE_LIKE,
                 auto_suggest=AutoSuggestFromHistory(),
                 enable_history_search=True)
         except KeyboardInterrupt:
             self.exit_program()
             continue
         try:
             command = command.rstrip().split(" ")
             if command[0] in self.EXIT:
                 self.exit_program()
             elif command[0] in self.RET:
                 answer = confirm(
                     "Are you sure you want to leave this interface?\n"
                     "If you have not saved the template you will lose"
                     " the changes")
                 if answer:
                     break
                 print("")
             elif command[0] == "name":
                 self._name(command)
             elif command[0] in ["dump", "d"]:
                 self._dump(command)
             elif command[0] in ["layer", "l"]:
                 self._layer(command)
             elif command[0] in ['funcs', 'functions']:
                 self._function(command)
             elif command[0] in ["show", "s"]:
                 self._show(command)
             elif command[0] in ["intercept", "i"]:
                 self._intercept(command)
             elif command[0] in ["layers", "ls"]:
                 self._layers(command)
             elif command[0] == "timestamp":
                 print(self._t.timestamp, '\n')
             elif command[0] == "version":
                 self._version(command)
             elif command[0] in ['desc', 'description']:
                 self._description(command)
             elif command[0] == "save":
                 self._save(command)
             elif command[0] in ["spoof"]:
                 self._spoof(command)
             elif command[0] == "clear":
                 Interface._clear()
             elif command[0] == "":
                 continue
             else:
                 Interface._wrong_command()
         except SystemExit:
             raise
         except Exception as e:
             Interface._print_error(
                 "Exception: Error processing the previous command. More info:"
             )
             print(e)