SNMP Enumeration

  • Install ruby-snmp

    gem install snmp

Get Request

Miss configure an SNMP service would gives an attacker a huge mount of information. Let's to see you we can interact with the server to retrieve some info.

require 'snmp'

# Connect to SNMP server
manager = => '')

# General info
puts "SNMP Version: " + manager.config[:version]
puts "Community: " + manager.config[:community]
puts "Write Community: " + manager.config[:WriteCommunity]

# Get hostname, contact and location
hostname = manager.get("sysName.0") {|vb| vb.value.to_s}       # manager.get("sysName.0").varbind_list[0]
contact  = manager.get("sysContact.0") {|vb| vb.value.to_s}    # manager.get("sysContact.0").varbind_list[0]
location = manager.get("sysLocation.0") {|vb| vb.value.to_s}   # manager.get("sysLocation.0").varbind_list[0]

# It would take an array of OIDs
response = manager.get(["sysName.0", "sysContact.0", "sysLocation.0"])
response.each_varbind do |vb|
    puts vb.value.to_s

Note: the OID names are case sensitive

Set Request

Sometimes we get luck and we get the private/management string of SNMP. At this moment we might be able to apply changes on the system, router, switches configurations.

require 'snmp'
include SNMP

# Connect to SNMP server
manager = => '')
# Config our request to OID
varbind ="","Your System Got Hacked"))
# Send your request with varbind our settings
# Check our changes
manager.get("sysName.0") {|vb| vb.value.to_s}


Last updated