Jump to content

SNMP_UDF for SNMPv1 and SNMPv2c


enaiman
 Share

Recommended Posts

I see ...

This is so called "MIB Walking" and to quote something I found about this:

SNMP walking is the SNMP application equivalent to a port scan

I'm afraid I can't help you with this (I don't have so much spare time to do the research).

If you find a solution to this and you post it here I would be grateful.

Good luck,

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

Having never needed to interact with SNMP via script before, I've just now come across this code. I apologize if I've missed it in the thread somewhere, but I'm wondering if it's possible to read a manufacturer-provided MIB to provide more useful results specific to whatever you're connecting to.

My UDFs: ExitCodes

Link to comment
Share on other sites

@c0deWorm

It is possible of course to read a MIB and to have this way all the OIDs in a database, array ...

That I'm afraid is now a simple AutoIt matter, it can be done via FileRead functions, using regular expressions to isolate the OIDs and organizing the OIDs in a database ...

My UDF was created to give the possibility to talk via SNMP using AutoIt; it is the "base" and other application will be built on top (it's like TCP/IP for a "gazzilion" of other applications).

Unfortunately I won't be working on any application based on my UDF (not now and not in the near future) but I will look forward to see some1 else doing it ^_^ I will provide help at any time though.

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...

This error appears sometime.

SNMP_UDF.au3 (182) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$SNMP_Answ_RqID_Val &= $SNMP_Answer[$A_RqId_len + $y]

$SNMP_Answ_RqID_Val &= ^ ERROR

I fixed it by this way and it even works, but I am not assured that the reason in it

181 For $y = 1 To Dec($SNMP_Answer[$A_RqId_len] -1)

182 $SNMP_Answ_RqID_Val &= $SNMP_Answer[$A_RqId_len + $y] ;RqId value (string)

183 Next

Edited by Axel82
Link to comment
Share on other sites

@Axel82

Thanks for leting me know about that error. Unfortunately I don't have the time to debug it now - I will do that in the future.

If your workaround works, you can use it but I wouldn't be 100% sure that the results would be accurate (.. and again, I could have made a mistake in my UDF and you are right ... we'll see that in a couple of weeks).

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 year later...

@FKFK

I try to keep an eye on this thread but unfortunately I don't have as much time as I used to. SNMP v3 I'm afraid is much more complex than what I thought. It is not only about the packet structure but it is more about encryption, authentication - It might be just too much for me ;)

Who knows? Maybe some day, somebody ... I can't promise anything.

Thank you for your comments :blink:

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...

Great UDF so far.

I got it to grab what I've needed so far but I am looking at the SNMP_UDF.au3 and I'm not seeing SetRequest implementation. Or if it is in there, ready to go, how to use it correctly. Thought I would just try and do all this SNMP stuff inside of Autoit instead of automating a third party program, but not seeing anything on the forums about how to do SNMP's Set.

(Also how would I get it to display, what kind of manipulation would I need to do to get it to display, OctetStrings? At the moment any OctetString is blank)

Failing to get the Set to work inside of Autoit do you, or anyone else for that matter, know of a good free SNMP MIB Browser that they would recommend for automation? (Need to able to send commands to it rather then using the mouse)

Link to comment
Share on other sites

@GSM

I was pretty sure that is possible; I had a look now at the UDF and the functionality is definitely there

Look at: _SNMPBuildPacket

$PDUType - PDU type ("A0"= GetRequest, "A1"= GetNext, "A2"= GetResponse, "A3"= SetRequest, "A5"= Get Bulk))

All you have to do is change the value of $PDUType to A3 and it will work.

Let me know how it's going.

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

It seems to work, it has an error code of 0 in the array view I'm assuming that is right. But I guess I'm not understanding what to do after that to actually change the data. Or maybe I'm misunderstanding the use of SetRequest.

Link to comment
Share on other sites

SetRequest is writing the data in that location - assuming that specific location is not read-only

If you want to check the result, just read the value from that location after you attempted to set the value.

If the error was 0 I am pretty much confident that the writing was OK.

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

So calling _SNMPBuildPacket($snmpOID, $snmpCOMM, $snmpVER, $snmpReqID, $PDUType = "A1") with PDUType = A3 sends SetRequest. Which of those is the variable that is the new data getting written to that location?

(snmpReqID?)

Won't have a chance to check till Monday.

Edited by GSM
Link to comment
Share on other sites

;)

My bad. Thank you for pointing this out to me. You were completely right 100% - there is no way at this point to write anything via SNMP using my UDF.

I start to remember that I haven't tested this. It is really embarasing.

I will try to fix this during the next days - I'll post the update when ready.

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

Finally I got that to work ;)

I have released a new version with support for SetRequest, updated the test script and uploaded a new test script especially made to test SetRequest. You can download them from the first post.

Please let me know if you find any bugs.

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

So I was messing around with your latest SNMP UDF and I'm not sure if I'm messing something up or if this is a bug but.

It seems it changes the SNMP_OID. So setting it to 1.3.6.1.1.1.17777.1.1.1.1.1.1.1 (which is a single get (A0)) would yield

1.3.6.1.1.1.163969.1393.1.1.1.1.1.1.1

Must have something to do with how big 17777 is, but that is what I need it to be, well around there. The old script (for reading that value (A0) yields the correct result and OID. If you put in a smaller value, like changing the 17777 to 1, it doesn't change it and, I'm guessing, would work find.

Link to comment
Share on other sites

I'll have a look into that.

It seems I'm not able to pinpoint the problem very easy so I'll need your help for that.

I need you to post here the "$SNMP_Command" you get and also "$srcv" (which is displayed in the console when you run my demo script). That will help me to see if the problem is in encoding or decoding the info.

There is something weird with this OID: 1.3.6.1.1 points to iso.org.dod.internet.directory and it stops there - I can't see anything under this OID so your OID seem to be wrong to me ... Well, that shouldn't have any effect in converting the OIDs.

Post the info I asked you for and I'll be able to fix it.

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

Alright lets see.

In script it runs:

Global $SNMP_OID = "1.3.6.1.4.1.17701.10.1.2.5.1.11.1"
$SNMP_Command = _SNMPBuildPacket($SNMP_OID, $SNMP_Community,$SNMP_Version, $SNMP_ReqID, "A0")

The $SNMP_Command, after the above, is

0x303202010104067075626C6963A025020200010201000201003019301706132B0601040181818A81818A250A010205010B010500

and the $srcv is

0x302F02010104067075626C6963A2220201010201000201003017301506112B060104018A81818A250A010205010B018000

Running the above in the old version returned

SNMP_Command = 0x302E02010104067075626C6963A0210202000102010002010030153013060F2B06010401818A250A010205010B010500
$srcv = 0x302E02010104067075626C6963A22102010102010002010030163014060F2B06010401818A250A010205010B01420104

Which has the correct value of 4.

Edited by GSM
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...