Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Library snmp

SNMP functions.

Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html

Source: http://nmap.org/svn/nselib/snmp.lua

Script Arguments

snmpcommunity

The community string to use. If not given, it is "public", or whatever is passed to buildPacket.

Functions

buildGetNextRequest (options, ...)

Create an SNMP Get Next Request PDU.

buildGetRequest (options, ...)

Create an SNMP Get Request PDU.

buildGetResponse (options, oid, value)

Create an SNMP Get Response PDU.

buildPacket (PDU, version, commStr)

Create an SNMP packet.

buildSetRequest (options, oid, value)

Create an SNMP Set Request PDU.

buildTrap (enterpriseOid, agentIp, genTrap, specTrap, timeStamp)

Create an SNMP Trap PDU.

dec (encStr, pos)

Decodes an SNMP packet or a part of it according to ASN.1 basic encoding rules.

decode (encStr, pos)

Decodes an SNMP packet or a part of it according to ASN.1 basic encoding rules.

decodeInt (encStr, len, pos)

Decodes an Integer according to ASN.1 basic encoding rules.

decodeLength (encStr, pos)

Decodes length part of encoded value according to ASN.1 basic encoding rules.

decodeOID (encStr, len, pos)

Decodes an OID from a sequence of bytes.

decodeSeq (encStr, len, pos)

Decodes a sequence according to ASN.1 basic encoding rules.

encode (val)

Encodes a given value according to ASN.1 basic encoding rules for SNMP packet creation.

encodeInt (val)

Encodes an Integer according to ASN.1 basic encoding rules.

encodeLength (len, val)

Encodes the length part of a ASN.1 encoding triplet using the "primitive, definite-length" method.

fetchFirst (response)

Fetches the first value from a SNMP response.

fetchResponseValues (resp)

Fetches values from a SNMP response.

ip2str (ip)

Transforms a table representing an IP to a string.

oid2str (oid)

Transforms a table representing an object identifier to a string.

str2ip (ipStr)

Transforms a string into an IP table.

str2oid (oidStr)

Transforms a string into an object identifier table.



Functions

buildGetNextRequest (options, ...)

Create an SNMP Get Next Request PDU.

Parameters

  • options: A table containing the following fields:
    • "reqId": Request ID.
    • "err": Error.
    • "errIdx": Error index.
  • ...: Object identifiers to be queried.

Return value:

Table representing PDU.
buildGetRequest (options, ...)

Create an SNMP Get Request PDU.

Parameters

  • options: A table containing the following fields:
    • "reqId": Request ID.
    • "err": Error.
    • "errIdx": Error index.
  • ...: Object identifiers to be queried.

Return value:

Table representing PDU.
buildGetResponse (options, oid, value)

Create an SNMP Get Response PDU.

Takes one OID/value pair or an already prepared table.

Parameters

  • options: A table containing the following keys and values:
    • "reqId": Request ID.
    • "err": Error.
    • "errIdx": Error index.
  • oid: Object identifiers of object to be sent back.
  • value: If given a table, use the table instead of OID/value pair.

Return value:

Table representing PDU.
buildPacket (PDU, version, commStr)

Create an SNMP packet.

Parameters

  • PDU: SNMP Protocol Data Unit to be encapsulated in the packet.
  • version: SNMP version, default 0 (SNMP V1).
  • commStr: community string, if not already supplied in registry or as the snmpcommunity script argument.
buildSetRequest (options, oid, value)

Create an SNMP Set Request PDU.

Takes one OID/value pair or an already prepared table.

Parameters

  • options: A table containing the following keys and values:
    • "reqId": Request ID.
    • "err": Error.
    • "errIdx": Error index.
  • oid: Object identifiers of object to be set.
  • value: To which value object should be set. If given a table, use the table instead of OID/value pair.

Return value:

Table representing PDU.
buildTrap (enterpriseOid, agentIp, genTrap, specTrap, timeStamp)

Create an SNMP Trap PDU.

Parameters

  • enterpriseOid:
  • agentIp:
  • genTrap:
  • specTrap:
  • timeStamp:

Return value:

Table representing PDU
dec (encStr, pos)

Decodes an SNMP packet or a part of it according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • pos: Current position in the string.

Return value:

The decoded value(s).
decode (encStr, pos)

Decodes an SNMP packet or a part of it according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • pos: Current position in the string.

Return values:

  1. The position after decoding
  2. The decoded value(s).
decodeInt (encStr, len, pos)

Decodes an Integer according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • len: Length of integer in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The decoded integer.
decodeLength (encStr, pos)

Decodes length part of encoded value according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The length of the following value.
decodeOID (encStr, len, pos)

Decodes an OID from a sequence of bytes.

Parameters

  • encStr: Encoded string.
  • len: Length of sequence in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The OID as an array.
decodeSeq (encStr, len, pos)

Decodes a sequence according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • len: Length of sequence in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The decoded sequence as a table.
encode (val)

Encodes a given value according to ASN.1 basic encoding rules for SNMP packet creation.

Parameters

  • val: Value to be encoded.

Return value:

Encoded value.
encodeInt (val)

Encodes an Integer according to ASN.1 basic encoding rules.

Parameters

  • val: Value to be encoded.

Return value:

Encoded integer.
encodeLength (len, val)

Encodes the length part of a ASN.1 encoding triplet using the "primitive, definite-length" method.

Parameters

  • len:
  • val: Value to be encoded.

Return value:

Encoded length value.
fetchFirst (response)

Fetches the first value from a SNMP response.

Parameters

  • response: SNMP Response (will be decoded if necessary).

Return value:

First decoded value of the response.
fetchResponseValues (resp)

Fetches values from a SNMP response.

Parameters

  • resp: SNMP Response (will be decoded if necessary).

Return value:

Table with all decoded responses and their OIDs.
ip2str (ip)

Transforms a table representing an IP to a string.

Parameters

  • ip: IP table.

Return value:

IP string.
oid2str (oid)

Transforms a table representing an object identifier to a string.

Parameters

  • oid: Object identifier table.

Return value:

OID string.
str2ip (ipStr)

Transforms a string into an IP table.

Parameters

  • ipStr: IP as string.

Return value:

Table representing IP.
str2oid (oidStr)

Transforms a string into an object identifier table.

Parameters

  • oidStr: Object identifier as string, for example "1.3.6.1.2.1.1.1.0".

Return value:

Table representing OID.

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]