Skip to content

Commit

Permalink
Fix network interface processing
Browse files Browse the repository at this point in the history
The SNMP walk operation can return an SNMP::NoSuchInstance class.
The error class must be handled rather than attempting to use it as a
valid value.
  • Loading branch information
mkienow-r7 committed Jul 2, 2019
1 parent d723122 commit 260c369
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions modules/auxiliary/scanner/snmp/snmp_enum.rb
Expand Up @@ -172,10 +172,10 @@ def run_host(ip)

ifindex = index.value
ifdescr = descr.value
ifmac = mac.value.unpack("H2H2H2H2H2H2").join(":")
ifmac = mac.value.to_s =~ /noSuchInstance/ ? 'unknown' : mac.value.unpack("H2H2H2H2H2H2").join(":")
iftype = type.value
ifmtu = mtu.value
ifspeed = speed.value.to_i
ifspeed = speed.value.to_s =~ /noSuchInstance/ ? 'unknown' : speed.value.to_i / 1000000
ifinoc = inoc.value
ifoutoc = outoc.value
ifstatus = status.value
Expand Down Expand Up @@ -260,8 +260,6 @@ def run_host(ip)
ifstatus = "unknown"
end

ifspeed = ifspeed / 1000000

network_interfaces.push({
"Interface" => "[ #{ifstatus} ] #{ifdescr}",
"Id" => ifindex,
Expand Down

0 comments on commit 260c369

Please sign in to comment.