Home page logo
/
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.

decode (encStr, pos)

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

encode (val)

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

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.

snmpWalk (socket, base_oid)

Walks the MIB Tree

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
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).
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.
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.
snmpWalk (socket, base_oid)

Walks the MIB Tree

Parameters

  • socket: socket already connected to the server
  • base_oid: string containing the base object ID to walk

Return values:

  1. status true on success, false on failure
  2. table containing oid and value
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 ]