diff --git a/cisco-ios.sublime-syntax b/cisco-ios.sublime-syntax index 8d530da..a244d74 100644 --- a/cisco-ios.sublime-syntax +++ b/cisco-ios.sublime-syntax @@ -313,6 +313,17 @@ variables: ) \b ) + number_range_1_1000: | + (?xi) + (?: + \b + (?: + (?:1000)| + (?:\d{2,3})| + (?:[1-9]) + ) + \b + ) number_range_1_10000: | (?xi) (?: @@ -1613,6 +1624,10 @@ contexts: 1: support.constant 2: support.constant + interface_snmp: + - include: snmp_trap_link_status + - include: snmp_if_monitor + snmp: - include: snmp_host - include: snmp_poll @@ -1627,6 +1642,22 @@ contexts: - include: snmp_ip_precedence - include: snmp_packetsize - include: snmp_queue_length + - include: snmp_queue_limit + - include: snmp_source_interface + - include: snmp_system_shutdown + - include: snmp_tftp_server_list + - include: snmp_trap_authentication_unknown_context + - include: snmp_trap_authentication_vrf + - include: snmp_trap_link_ietf + - include: snmp_trap_link_switchover + - include: snmp_trap_retry + - include: snmp_trap_timeout + - include: snmp_trap_timeout_old + - include: snmp_trap_source + - include: snmp_trap_authentication + - include: snmp_usm_cisco + - include: snmp_view + snmp_dscp: - match: | @@ -1642,6 +1673,20 @@ contexts: 3: support.constant 4: constant.numeric + snmp_trap_link_status: + - match: | + (?xi) + \s* + (snmp)\s+ + (trap)\s+ + (link-status) + (\s+permit\s+duplicates)? + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: support.constant + snmp_packetsize: - match: | (?xi) @@ -1654,6 +1699,235 @@ contexts: 2: support.constant 3: constant.numeric + snmp_queue_limit: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (queue-limit)\s+ + ( + (?:dispatcher)| + (?:engine)| + (?:notification-host) + )\s+ + ({{number_range_1_1000}}) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: constant.numeric + + snmp_trap_authentication_vrf: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (authentication)\s+ + (vrf) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: support.constant + + snmp_trap_link_ietf: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (link)\s+ + (ietf) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: support.constant + + snmp_trap_link_switchover: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (link)\s+ + (switchover) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: support.constant + + snmp_trap_retry: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (retry)\s+ + ( + \b + (?: + (?:10)| + (?:\d) + ) + \b + ) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: constant.numeric + + snmp_trap_timeout_old: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap-timeout)\s+ + ({{number_range_1_1000}}) + captures: + 1: support.constant + 2: support.constant + 3: constant.numeric + + snmp_trap_timeout: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (timeout)\s+ + ({{number_range_1_1000}}) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: constant.numeric + + snmp_trap_authentication_unknown_context: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap)\s+ + (authentication)\s+ + (unknown-context) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + 4: support.constant + + snmp_source_interface: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (source-interface)\s+ + ( + (?:traps)| + (?:informs) + )\s+ + ({{interface_names}})\s*({{interface_numbers}}) + captures: + 1: support.constant + 2: support.constant + 3: constant.language + 4: entity.other.attribute-name + 5: constant.numeric + + snmp_trap_source: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap-source)\s+ + ({{interface_names}})\s*({{interface_numbers}}) + captures: + 1: support.constant + 2: support.constant + 3: entity.other.attribute-name + 4: constant.numeric + + snmp_trap_authentication: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (trap-authentication) + captures: + 1: support.constant + 2: support.constant + + snmp_usm_cisco: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (usm)\s+ + (cisco) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + + snmp_view: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (view)\s+ + (\S+)\s+ + ( + (?:[\d\*]+\.)* + [\d\*]+\.? + ) + captures: + 1: support.constant + 2: support.constant + 3: string.unquoted + 4: constant.numeric + + snmp_if_monitor: + - match: | + (?xi) + \s* + (snmp)\s+ + (trap)\s+ + (if-monitor) + captures: + 1: support.constant + 2: support.constant + 3: support.constant + + snmp_tftp_server_list: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (tftp-server-list)\s+ + (?: + (\d+)| + (\S+) + ) + captures: + 1: support.constant + 2: support.constant + 3: constant.numeric + 4: string.unquoted + + snmp_system_shutdown: + - match: | + (?xi) + \s* + (snmp-server)\s+ + (system-shutdown) + captures: + 1: support.constant + 2: support.constant + snmp_queue_length: - match: | (?xi) @@ -3799,6 +4073,7 @@ contexts: - include: interface_ipv6_link_local - include: ip_dhcp_snooping - include: storm_control + - include: interface_snmp - match: | (?xi) ^\s* diff --git a/cisco-nxos.sublime-syntax b/cisco-nxos.sublime-syntax index ba1f8df..abfd19f 100644 --- a/cisco-nxos.sublime-syntax +++ b/cisco-nxos.sublime-syntax @@ -781,16 +781,30 @@ contexts: ^\s* (tacacs-server)\s+ (?: - (?:(key)\s+(\d+)\s+("\S+"))| + (?:(key)\s+ + (?: + (?:(7)\s+(")(\S+)("))| + (?:(5)\s+(")(\S+)("))| + (?:(\d+)\s+("\S+")) + ) + )| (?:(host)\s+({{ip}})) ) captures: 1: support.constant # tacacs-server 2: support.constant # tacacs-server key 3: constant.numeric # tacacs-server key type - 4: string.unquoted # tacacs-server key value - 5: support.constant # tacacs-server host - 6: constant.numeric # tacacs-server host ip + 4: string.quoted + 5: string.unquoted.cisco.password.type.7 + 6: string.quoted + 7: constant.numeric + 8: string.quoted + 9: string.unquoted.cisco.password.type.5 + 10: string.quoted + 11: constant.numeric + 12: string.quoted + 13: support.constant # tacacs-server host + 14: constant.numeric # tacacs-server host ip hostname: - match: ^\s*(hostname)\s*(\S+) diff --git a/cisco/ios/ios.configure_terminal.sublime-completions b/cisco/ios/ios.configure_terminal.sublime-completions index 1721322..cae90e3 100644 --- a/cisco/ios/ios.configure_terminal.sublime-completions +++ b/cisco/ios/ios.configure_terminal.sublime-completions @@ -141,7 +141,57 @@ "trigger": "snmp-server\tqueue-length", "contents": "snmp-server queue-length ${1:10}" }, + { + "trigger": "snmp-server queue-limit\tdispatcher", + "contents": "snmp-server queue-limit dispatcher ${1:100}" + }, + { + "trigger": "snmp-server queue-limit\tengine", + "contents": "snmp-server queue-limit engine ${1:100}" + }, + { + "trigger": "snmp-server queue-limit\tnotification-host", + "contents": "snmp-server queue-limit notification-host ${1:10}" + }, + { + "trigger": "snmp-server source-interface\ttraps", + "contents": "snmp-server source-interface traps ${1:vlan}${2:10}" + }, + { + "trigger": "snmp-server\ttrap-source", + "contents": "snmp-server trap-source ${1:vlan}${2:10}" + }, + { + "trigger": "snmp-server source-interface\tinforms", + "contents": "snmp-server source-interface informs ${1:vlan}${2:10}" + }, + { + "trigger": "snmp-server \ttftp-server-list", + "contents": "snmp-server tftp-server-list ${1:ACL_NAME}" + }, + { + "trigger": "snmp-server trap\tretry", + "contents": "snmp-server trap retry ${1:3}" + }, + { + "trigger": "snmp-server \tview", + "contents": "snmp-server view ${1:NAME} ${2:0.0.0}" + }, + { + "trigger": "snmp-server trap\ttimeout (>= v12.2SR)", + "contents": "snmp-server trap timeout ${1:30}" + }, + { + "trigger": "snmp-server \ttrap-timeout (< v12.2SR)", + "contents": "snmp-server trap-timeout ${1:30}" + }, + "snmp-server system-shutdown", + "snmp-server trap authentication unknown-context", + "snmp-server trap authentication vrf", + "snmp-server trap link ietf", + "snmp-server trap link switchover", "snmp-server manager", + "snmp-server usm cisco", "end", "exit", ] diff --git a/cisco/ios/ios.interface.sublime-completions b/cisco/ios/ios.interface.sublime-completions index 02313e4..5f24300 100644 --- a/cisco/ios/ios.interface.sublime-completions +++ b/cisco/ios/ios.interface.sublime-completions @@ -136,5 +136,14 @@ "trigger": "storm-control\taction trap", "contents": "storm-control action trap" }, + { + "trigger": "snmp\ttrap link-status", + "contents": "snmp trap link-status" + }, + { + "trigger": "snmp trap\tif-monitor", + "contents": "snmp trap if-monitor" + }, + ] } diff --git a/lib/passwords/pw_type7.py b/lib/passwords/pw_type7.py index 2c6af4c..74f3435 100644 --- a/lib/passwords/pw_type7.py +++ b/lib/passwords/pw_type7.py @@ -1,18 +1,48 @@ # Copyright 2017 Glen Harmon import re +import itertools -password_re = re.compile(r'^(?P[01]\d)(?P[0-9a-f]{1,25})', re.I) +ios_password_re = re.compile(r'^(?P[01]\d)(?P\S{1,25})', re.I) TRANSLATION_KEY_MAP = 'dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87' -# Following https://pen-testing.sans.org/resources/papers/gcih/cisco-ios-type-7-password-vulnerability-100566 def decode(password): + if ios_password_re.match(password): + return ios_decode(password) + else: + return nxos_decode(password) + + +def nxos_decode(password): + """ See https://networkengineering.stackexchange.com/questions/27987/tacacs-implentation-server-key-error """ + uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + lowercase = uppercase.lower() + decoded_password = list() + cipher = [3, 22, 4, 5, 18, 0, 21, 5, 18, 3, 10, 5, 16, 22, 4, 16, 24, 17, 12, 5, 21, 18, 5, 22, 19, 7] + for character, key in zip(password, itertools.cycle(cipher)): + if character in lowercase: + decoded = ord(character) - 97 - key + if decoded < 0: + decoded += 26 + decoded += 97 + decoded_password.append(chr(decoded)) + elif character in uppercase: + decoded = ord(character) - 65 - key + if decoded < 0: + decoded += 26 + decoded += 65 + decoded_password.append(chr(decoded)) + else: + decoded_password.append(character) + return ''.join(decoded_password) + + +def ios_decode(password): + """ Following https://pen-testing.sans.org/resources/papers/gcih/cisco-ios-type-7-password-vulnerability-100566 """ decoded_password = '' - if not password_re.match(password): - return 'Invalid Type 7 Password' # Example Password: # Encoded: 044B0A151C36435C0D diff --git a/messages.json b/messages.json index 6ebe714..e927ae8 100644 --- a/messages.json +++ b/messages.json @@ -51,5 +51,6 @@ "2.44.1": "messages/2.44.1.md", "2.45.0": "messages/2.45.0.md", "2.46.0": "messages/2.46.0.md", - "2.47.0": "messages/2.47.0.md" + "2.47.0": "messages/2.47.0.md", + "2.48.0": "messages/2.48.0.md" } \ No newline at end of file diff --git a/messages/2.48.0.md b/messages/2.48.0.md new file mode 100644 index 0000000..6687461 --- /dev/null +++ b/messages/2.48.0.md @@ -0,0 +1,43 @@ +# [2.48.0] - 2020.07.26 + +# Added + +## Cisco NXOS + +* Type 7 Password Decode on tacacs + +## Cisco IOS + +* snmp-server queue-limit [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server source-interface [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server system-shutdown [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server tftp-server-list [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap authentication unknown-context [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap authentication vrf [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap link ietf [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap link switchover [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap retry [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap timeout [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap-source [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap-timeout [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server trap-authentication [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server usm cisco [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp-server view [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp trap if-monitor [#9](https://github.com/heyglen/network_tech/issues/9) + +* snmp trap link-status [#9](https://github.com/heyglen/network_tech/issues/9) diff --git a/tests/syntax_test_cisco_ios.cisco-ios b/tests/syntax_test_cisco_ios.cisco-ios index f1a045d..3c186df 100644 --- a/tests/syntax_test_cisco_ios.cisco-ios +++ b/tests/syntax_test_cisco_ios.cisco-ios @@ -576,6 +576,9 @@ interface range GigabitEthernet1/1-2 switchport port-security violation shutdown switchport port-security violation restrict switchport port-security violation protect + snmp trap link-status + snmp trap link-status permit duplicates + snmp trap if-monitor spanning-tree bpduguard enable spanning-tree bpduguard disable service-policy output SOMETHING @@ -637,6 +640,23 @@ snmp-server manager snmp-server manager session-timeout 600 snmp-server packetsize 484 snmp-server queue-length 10 +snmp-server queue-limit dispatcher 100 +snmp-server queue-limit engine 100 +snmp-server queue-limit notification-host 10 +snmp-server source-interface traps vlan10 +snmp-server system-shutdown +snmp-server tftp-server-list ACL_NAME +snmp-server tftp-server-list 10 +snmp-server trap authentication unknown-context +snmp-server trap authentication vrf +snmp-server trap link ietf +snmp-server trap link switchover +snmp-server trap retry 10 +snmp-server trap timeout 30 +snmp-server trap-source vlan10 +snmp-server trap-timeout 30 +snmp-server trap-authentication +snmp-server usm cisco line con 0 diff --git a/tests/syntax_test_cisco_nxos.cisco-nxos b/tests/syntax_test_cisco_nxos.cisco-nxos index 3e86fa6..d917ce1 100644 --- a/tests/syntax_test_cisco_nxos.cisco-nxos +++ b/tests/syntax_test_cisco_nxos.cisco-nxos @@ -54,6 +54,7 @@ ip route vrf NAME 1.2.3.0/24 vlan1 1.1.1.1 name asdf permanent default interface Ethernet0/1 +tacacs-server key 7 "fewhg" interface Vlan 20 shutdown