Jump to content

SNMP_UDF for SNMPv1 and SNMPv2c


enaiman
 Share

Recommended Posts

@dmollico

That is happening if something in the packet is wrong.

I can see that you are using "A0" (get request) with that OID. This is not working always because A0 expects an instance to be specified. In order to work you will have to add a 0 at the end of your OID (instance 0)

Global $SNMP_OID = "1.3.6.1.2.1.43.10.2.1.4.1.1.0"

If that doesn't work, you will need to use (the easiest way to get the info you need) "A1" (get next) with your current OID (Global $SNMP_OID = "1.3.6.1.2.1.43.10.2.1.4.1.1")

Hope any of these solutions will work :)

(I'll be back next week)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

  • 1 month later...

Time for a new update :P

Added GetBulk support.

This works for SNMP v2 and up (if used with SNMP v1 will return an error).

GetBulk is used to retrieve large amounts of OIDs in the same packet - a single querry is send with an OID (the start OID) and a number of OId to be returned.

GetBulk can work with a generous amount of OId requested but using it with too many OIDs will make the udf to reach its (string and array) limits and the script will fail. I have successfully tested it for 80 OIDs but failed for 100 (I guess the arrays in the udf were too small) - as I said, it depends on OID's length - that's why I would recommend a value of 50 as being "safe".

The return type of the function have been changed as well. The old return has an "educational" value, showing everything received in a not-so-easy to work with array. The new return is a 2D array having in pos [0][0] the error code and the next elements are pairs OID - ClearValue.

The old return (array) is still built in the memory and can be accessed anytime - its name is $SNMP_Received.

Also I have changed the example script to show 4 different request types.

That's it for now :unsure:

Have fun.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Link to comment
Share on other sites

@ptrex

The fact that you find this udf useful is enough reward for me; I haven't wasted the time working on it :P

It still needs some work in its actual form (formatting the udf, coments and making the code more compact; a "tunning" job) and I still have SNMP v3 to look forward to. I don't know about SNMP v3 it is a big project and I'm afraid I won't have enough time to work on it. It has brought alot of changes and encryption and authentication might prove too much for me, plus I'm not sure I can find enough info on the Internet about SNMPv3 packet structure.

As I said, I'm not sure atm if I would add support for SNMPv3 ... but .. who knows? maybe :unsure:

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for the great UDF. I have some problems when I use for example this 1.3.6.1.4.1.26565.1.1.1.24.0 OID. The result also shows a different OID... (1.3.6.1.4.129.10113.207.69.1.1.1.24.0) any idea what is causing this problem?

Edited by Sjee
Link to comment
Share on other sites

I have some problems when I use for example this 1.3.6.1.4.1.26565.1.1.1.24.0

Wow - I haven't seen such a great number 26565 - obviously my UDF wasn't ready to handle it ... but it will.

Issue fixed; it will work fine with such great numbers but not over 65535 :o

I'll upload the changed version very soon - check first page.

Thanks for testing and finding this error :D

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Do you mean that the OID "returned" by the polled device is decoded wrong? Or this is the OID you are trying to poll?

I have checked again the UDF and it works - are you sure you have downloaded the new version and replaced the old one? (it should have version 1.3)

If this is correct - can you post here the packet you receive and it's badly decoded? (it is the variable passed to _ShowSNMPReceived function)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

I have some problems too:

The OID should look so - ".1.3.6.1.4.1.15.1143.1.1" - with point before 1. So it is written to instructions to a server.

Snmpget.exe returns value "81" and it's correct. But script returns "1.3.6.1.4.1.15.132215.1.1 - 0" - another OID, and no value.

If i try to use OID without point, return value looks the same.

Edited by Axel82
Link to comment
Share on other sites

Thank you for providing feedback :D

Took me some time to find that there is an error somewhere - then tooke me some more time to isolate and correct it. I still can't believe that the error was in "_encode" function (it was there since the begining but it went undetected)

I have corrected it and uploaded the new version (1.3.1)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

  • 2 weeks later...

@Axel82

What method are you using? "A0" (GetRequest) or "A1"(GetNext)?

My guess is that you're using GetNext since the OID returned differs so much.

I don't know what equipment are you trying to use my udf with; you can specify that and I might be able to dig around ...

Anyway - try to use 1.3.6.1.2.1.15.1271.1.0 and "A0" - if 0 instance exists it will return a value then.

Let me know what happens.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

@Axel82

I guess I found your mistake: you are using a wrong OID.

From your SNMP browser I can read: .iso.org.dod.internet.private.enterprises and this will translate in:

iso = 1

org = 3

dod = 6

internet = 1

private = 4

enterprises = 1

So the correct OID will be 1.3.6.1.4.1.15.1271.1.0 not 1.3.6.1.2.1.15.1271.1.0 which is the equivalent of .iso.org.dod.internet.mgmt.mib2.bgp.1271.1.0

Try the OID above and all will be fine.

Note: OIDs in "non-numeric" form are not supported at the moment (maybe a future project ... not sure yet). The only OID form supported is 1.3.6.x.y.... (no dot in front)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

I'm not sure I understand exactly what do you want to get ...

Do you want to get the list of all folders under iso.dod.internet.private.enterprise.15 ?

Please give a more detailed explanation.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...