Class: Dap::Filter::FilterDecodeSNMPGetReply

Inherits:
Object
  • Object
show all
Includes:
BaseDecoder
Defined in:
lib/dap/filter/udp.rb

Overview

Decode a SNMP GET probe response ( zmap: snmp1_161.pkt )

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from BaseDecoder

#process

Methods included from Base

#initialize, #process

Instance Method Details

#decode(data) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/dap/filter/udp.rb', line 125

def decode(data)
  asn = OpenSSL::ASN1.decode(data) rescue nil
  return if not asn

  snmp_error = asn.value[0].value rescue nil
  snmp_comm  = asn.value[1].value rescue nil
  snmp_data  = asn.value[2].value[3].value[0] rescue nil
  snmp_oid   = snmp_data.value[0].value rescue nil
  snmp_info  = snmp_data.value[1].value rescue nil

  return if not (snmp_error and snmp_comm and snmp_data and snmp_oid and snmp_info)
  snmp_info = snmp_info.to_s.gsub(/\s+/, ' ').gsub(/[\x00-\x1f]/, ' ')

  return if not snmp_info
  { 'snmp_value' => snmp_info }
end