Skip to content

Commit

Permalink
Merge pull request #1121 from dlundgren/dl/ios-username-detection
Browse files Browse the repository at this point in the history
Allow username detection on older Cisco ios versions
  • Loading branch information
mirceaulinic authored Jul 13, 2020
2 parents d0df828 + 75a4f6f commit 1d9fd36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ def get_users(self):
"""
username_regex = (
r"^username\s+(?P<username>\S+)\s+(?:privilege\s+(?P<priv_level>\S+)"
r"\s+)?(?:secret \d+\s+(?P<pwd_hash>\S+))?$"
r"\s+)?(?:(password|secret) \d+\s+(?P<pwd_hash>\S+))?$"
)
pub_keychain_regex = (
r"^\s+username\s+(?P<username>\S+)(?P<keys>(?:\n\s+key-hash\s+"
Expand All @@ -3120,6 +3120,9 @@ def get_users(self):
users = {}
command = "show run | section username"
output = self._send_command(command)
if "Invalid input detected" in output:
command = "show run | include username"
output = self._send_command(command)
for match in re.finditer(username_regex, output, re.M):
users[match.groupdict()["username"]] = {
"level": int(match.groupdict()["priv_level"])
Expand Down

0 comments on commit 1d9fd36

Please sign in to comment.