Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provided is a suite of applications used to implement SNMP v1, SNMP v… #462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HarshMehta112
Copy link

SNMP Packet Capturing Tool

The snmp packet capturing is fully written in Go. it provides same output as NetSNMP gives for Get and Walk. It supports IPv4 and IPv6, using SNMPv1, SNMPv2c or SNMPv3. Builds are tested against linux/amd64.

Overview

This tool works as follows:

  1. if user provide the OID in the command line arguments then it will check provided OID is singular or Tabular based on that it will fire Get or Walk request on the particular OID.

  2. if user does not provide the OID then it will get the default OID [EX. .1.3.6.1.2.1.1.2.0] and it will fire the Get reuqest on this OID.

  3. User can also provide the multiple OIDs in the Get request and it will gives the result of each OID seperated by new line.

snmp packet capturing has the following SNMP functions:

  • Get (single or multiple OIDs)
  • Walk - retrieves a subtree of values using GETNEXT.

snmp packet capturing has the following functions with Configurable parameter:

  • -t --> to specify timeout (int)
    Default value = 2 second

  • -r --> to specify retry count (int)
    Default value = 6

  • -exp --> to specify the exponantial timeout (bool)
    Default value = false

  • -D --> to run command in debug mode (it enable the logs for gosnmp)

Command Example : snmpwalk -v2c -c public -t 3 -exp true -r 3 172.16.10.47 .1.3.6.1.2.1.1.9.1.2.1 -D 

Usage

Running snmp packet capturing gives the following output (from my printer):

% go run snmpPacketCapture.go snmpget -v2c -c public 172.16.10.47 .1.3.6.1.2.1.1.9.1.2.1 .1.3.6.1.2.1.1.9.1.4.1
.1.3.6.1.2.1.1.9.1.2.1 = OID: .1.3.6.1.6.3.1
.1.3.6.1.2.1.1.9.1.4.1 = Timeticks: (5100) 0:00:51.00

% go run snmpPacketCapture.go snmpwalk -v2c -c public 172.16.10.47 .1.3.6.1.2.1.1.9.1.2.1
.1.3.6.1.2.1.1.9.1.2.1 = OID: .1.3.6.1.6.3.1

The following BER types have been implemented:

  • 0x00 UnknownType
  • 0x02 Integer
  • 0x04 OctetString
  • 0x05 Null
  • 0x06 ObjectIdentifier
  • 0x40 IPAddress (IPv4 & IPv6)
  • 0x41 Counter32
  • 0x42 Gauge32
  • 0x43 TimeTicks
  • 0x44 Opaque (Float & Double)
  • 0x46 Counter64
  • 0x81 NoSuchInstance

Screenshot from 2024-01-31 21-06-48

Screenshot from 2024-01-31 21-09-33

  • Here you can see I specify retry count as 4 and timeout as 2 second so it will gives that output as WalkAll error of timeout with 4 retries. (Note : here device is not reachable).

Screenshot from 2024-01-31 21-30-35

  • Here in above image you can see that when I need debugging for particular snmp capturing I added -D flag it will prints all the debug logs in the console.

…2c and SNMP v3 using both IPv4 and IPv6.

Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Copy link
Member

@TimRots TimRots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

I'm having a difficult time reviewing this code with the superfluous line-breaks. Could you please fix this up first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants