snmpsim icon indicating copy to clipboard operation
snmpsim copied to clipboard

snmpsimd incorrectly parse escaped strings.

Open landy2005 opened this issue 6 years ago • 8 comments

I have dump from an device (Dell SAN), mostly Oids correctly walked, but when I try to get this tree/table (1.3.6.1.3.94), I get such error:

$ snmpwalk -v2c -c dellsan4024 -On localhost:1161 1.3.6.1.3.94
.1.3.6.1.3.94.1.1.0 = INTEGER: 0
.1.3.6.1.3.94.1.2.0 = STRING: "http:172.30.1.29"
.1.3.6.1.3.94.1.3.0 = Timeticks: (1554901966) 179 days, 23:10:19.66
.1.3.6.1.3.94.1.4.0 = Timeticks: (1554901966) 179 days, 23:10:19.66
.1.3.6.1.3.94.1.5.0 = Timeticks: (1554901966) 179 days, 23:10:19.66
.1.3.6.1.3.94.1.5.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
$ snmpwalk -v2c -c dellsan4024 -On localhost:1161 1.3.6.1.3.94.1.6
.1.3.6.1.3.94.1.6 = No more variables left in this MIB View (It is past the end of the MIB tree)

Here partial dump for this Oid tree:

1.3.6.1.3.94.1.1.0|2|0
1.3.6.1.3.94.1.2.0|4|http:172.30.1.29
1.3.6.1.3.94.1.3.0|67|1554901966
1.3.6.1.3.94.1.4.0|67|1554901966
1.3.6.1.3.94.1.5.0|67|1554901966
1.3.6.1.3.94.1.6.1.1.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4e| \x80\x00\xc0\xff\xf0\\o\x00\x00\x00\x00\x00\x00\x00\x00
1.3.6.1.3.94.1.6.1.2.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4e| \x80\x00\xc0\xff\xf0\\o\x00\x00\x00\x00\x00\x00\x00\x00
1.3.6.1.3.94.1.6.1.3.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|11
1.3.6.1.3.94.1.6.1.4.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|8
1.3.6.1.3.94.1.6.1.5.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|2
1.3.6.1.3.94.1.6.1.6.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|3
1.3.6.1.3.94.1.6.1.7.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|DELL EMC ME4024
1.3.6.1.3.94.1.6.1.8.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|CN0PJ27VFCG008CM01CVA00
1.3.6.1.3.94.1.6.1.9.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|67|1554901948
1.3.6.1.3.94.1.6.1.10.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|http:172.30.1.29
1.3.6.1.3.94.1.6.1.11.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4e|\xff\xff\xff
1.3.6.1.3.94.1.6.1.12.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|3
1.3.6.1.3.94.1.6.1.13.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|1
1.3.6.1.3.94.1.6.1.14.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|41
1.3.6.1.3.94.1.6.1.15.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|67|1554901948
1.3.6.1.3.94.1.6.1.16.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|67|1554901948
1.3.6.1.3.94.1.6.1.17.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|50
1.3.6.1.3.94.1.6.1.18.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|0
1.3.6.1.3.94.1.6.1.19.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4e|\x00
1.3.6.1.3.94.1.6.1.20.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|fei-vic-san-1
1.3.6.1.3.94.1.6.1.21.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|PJ27V
1.3.6.1.3.94.1.6.1.22.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|2
1.3.6.1.3.94.1.6.1.23.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|[email protected]
1.3.6.1.3.94.1.6.1.24.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4|7625 Omnitech Place, Victor, NY 14564
1.3.6.1.3.94.1.6.1.25.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|0
1.3.6.1.3.94.1.6.1.26.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|40
1.3.6.1.3.94.1.6.1.27.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|40
1.3.6.1.3.94.1.6.1.28.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|2|0

You can get full dump for this device by this link: https://pastebin.com/wsxkk0QP

landy2005 avatar Apr 17 '19 17:04 landy2005

Output in daemon console:

Using /home/mstupalov/snmpdata/dellsan4024.snmprec controller selected by candidate b'0f90dab4314ebe9922fb7aa000e93f17'; transport ID 1.3.6.1.6.1.1.0, source address 77.222.50.30, context name "b'0f90dab4314ebe9922fb7aa000e93f17'"
SNMP EngineID 0x80004fb8056176617461722e636f6f736d2e6e65744cbbc908, transportDomain (1, 3, 6, 1, 6, 1, 1, 0), transportAddress ('77.222.50.30', 51666), securityModel 2, securityName 0f90dab4314ebe9922fb7aa000e93f17, securityLevel 1
Request var-binds: 1.3.6.1.3.94.1.6=<>, flags: NEXT, GET
ERROR data error at /home/mstupalov/snmpdata/dellsan4024.snmprec controller for 1.3.6.1.3.94.1.6: value evaluation error for tag '4', value ' \\x80\\x00\\xc0\\xff\\xf0\\\\o\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00': Unknown escape character o
Response var-binds: 1.3.6.1.3.94.1.6=<No more variables left in this MIB View>

Ohh, now I see where problem:

1.3.6.1.3.94.1.6.1.1.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0|4e| \x80\x00\xc0\xff\xf0\\o\x00\x00\x00\x00\x00\x00\x00\x00

landy2005 avatar Apr 17 '19 17:04 landy2005

Seems as this is again HEX trouble (with escaped strings). Originally this Oid fetched by snmpwalk as:

.1.3.6.1.3.94.1.6.1.1.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0 = Hex-STRING: 20 80 00 C0 FF F0 5C 6F 00 00 00 00 00 00 00 00   [ .....\o........]
.1.3.6.1.3.94.1.6.1.2.32.128.0.192.255.240.92.111.0.0.0.0.0.0.0.0 = Hex-STRING: 20 80 00 C0 FF F0 5C 6F 00 00 00 00 00 00 00 00   [ .....\o........]

than I convert this walk by cmd: datafile.py --sort-records --deduplicate-records --escaped-strings --source-record-type=snmpwalk --input-file=devel/walks/dellme4024-snmpwalk.txt --output-file=dellme4024.snmprec

landy2005 avatar Apr 17 '19 17:04 landy2005

For self I recrete this dump without escaped-strings option, and walking now ok, but issue for escaped string actual.

landy2005 avatar Apr 17 '19 18:04 landy2005

Aha, there need additional escaping for \ char (in HEX 5C).

landy2005 avatar Apr 18 '19 11:04 landy2005

Thank you! Should be fixed in master by now.

etingof avatar Apr 20 '19 06:04 etingof

BTW, would you consider donating your snmpwalk from Dell SAN to this project? ;-)

That's a long-desired thing to collect some real-world snmpwalks and publish them for public consumption.

etingof avatar Apr 20 '19 06:04 etingof

BTW, would you consider donating your snmpwalk from Dell SAN to this project? ;-)

I already have many walks from different devices for our project, but exactly this is contributed by user, not sure if it's allowed for pulic use. Will ask him.

landy2005 avatar Apr 20 '19 07:04 landy2005

I already have many walks from different devices for our project

It would be awesome to have as many of them as possible! It's not about Dell SAN specifically, but the variety of different walks.

I've opened a call for contribution.

etingof avatar Apr 20 '19 07:04 etingof