From 208827f6360e7874f84355524af37c06f064e7b6 Mon Sep 17 00:00:00 2001 From: "Greg T. Wallace" Date: Tue, 18 Jun 2024 21:30:40 -0400 Subject: [PATCH] ssh: fix shell regex * from ssh videos I found on youtube, the @ symbol might not be present in prompt, so make it optional * fix typo of 0-0 instead of 0-9 (all numbers are possible in the prompt) --- pkg/apcssh/shell_helpers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apcssh/shell_helpers.go b/pkg/apcssh/shell_helpers.go index e2084cb..7c36c60 100644 --- a/pkg/apcssh/shell_helpers.go +++ b/pkg/apcssh/shell_helpers.go @@ -11,8 +11,8 @@ func scanAPCShell(data []byte, atEOF bool) (advance int, token []byte, err error return 0, nil, nil } - // regex for shell prompt (e.g., `apc@apc>`) - re := regexp.MustCompile(`(\r\n|\r|\n)[A-Za-z0-0.]+@[A-Za-z0-0.]+>`) + // regex for shell prompt (e.g., `apc@apc>`, `apc>`, `some@dev>`, `other123>`, etc.) + re := regexp.MustCompile(`(\r\n|\r|\n)([A-Za-z0-9.]+@?)?[A-Za-z0-9.]+>`) // find match for prompt if index := re.FindStringIndex(string(data)); index != nil {