Skip to content

Commit

Permalink
Add comments explaining intention behind certain regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maspital committed Jun 29, 2022
1 parent e73941b commit 4cdf575
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/attacks/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def interrupt_handler(self, _signum, _frame):

@contextmanager
def check_printed(self, indicator):
# Removes all ANSI escape sequences to prevent unintended string mismatches when checking for success
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
lp = ListPrinter()
old_printer = self.printer
Expand Down
1 change: 1 addition & 0 deletions src/attacks/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def print_output(self, msg_file, printer):

@staticmethod
def print_windows_output(msg_file, printer):
# Removes certain ANSI escape codes (J, m, H) to prevent the printed console output from being malformed
ansi_escape = re.compile(r'\x1b\[(?:[0-?]*[JmH])')
while not msg_file.channel.exit_status_ready() or msg_file.channel.recv_ready():
printer.print(ansi_escape.sub("", msg_file.readline()))
Expand Down

0 comments on commit 4cdf575

Please sign in to comment.