Home page logo
/
Zenmap screenshot
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
Example Nmap output

Library snmp

SNMP library.

Authors:
Patrik Karlsson <patrik@cqure.net>
Gioacchino Mazzurco <gmazzurco89@gmail.com>

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

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

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.

connect (self)

Connect to the server For UDP ports, this doesn't send any packets, but it creates the socket and locks in the timeout.

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.

fetchResponseValues (resp)

Fetches values from a SNMP response.

get (self, options, ...)

Sends an SNMP Get request

getnext (self, options, ...)

Sends an SNMP Get Next request

ip2str (ip)

Transforms a table representing an IP to a string.

new (self, host, port, community, options)

Creates a new Helper instance

oid2str (oid)

Transforms a table representing an object identifier to a string.

request (self, message)

Communications helper Sends an SNMP message and receives a response.

set (self, options, oid, setparam, value)

Sends an SNMP Set request

str2ip (ipStr)

Transforms a string into an IP table.

str2oid (oidStr)

Transforms a string into an object identifier table.

walk (self, base_oid)

Walks the MIB Tree

Tables

snmp.options

SNMP options table



Functions

buildGetNextRequest (options, ...)

Create an SNMP Get Next Request PDU.

Parameters

  • options: SNMP options table
  • ...: Object identifiers to be queried.

Return value:

Table representing PDU.

See also:

buildGetRequest (options, ...)

Create an SNMP Get Request PDU.

Parameters

  • options: SNMP options table
  • ...: Object identifiers to be queried.

Return value:

Table representing PDU.

See also:

buildGetResponse (options, oid, value)

Create an SNMP Get Response PDU.

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

Parameters

  • options: SNMP options table
  • 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.

See also:

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.
buildSetRequest (options, oid, value)

Create an SNMP Set Request PDU.

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

Parameters

  • options: SNMP options table
  • 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.

See also:

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

Create an SNMP Trap PDU.

Parameters

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

Return value:

Table representing PDU
connect (self)

Connect to the server For UDP ports, this doesn't send any packets, but it creates the socket and locks in the timeout.

Parameters

  • self:

Return value:

status true on success, false on failure
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.
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.
get (self, options, ...)

Sends an SNMP Get request

Parameters

  • self:
  • options: SNMP options table
  • ...: Object identifiers to be queried.

Return values:

  1. status False if error, true otherwise
  2. Table with all decoded responses and their OIDs.

See also:

getnext (self, options, ...)

Sends an SNMP Get Next request

Parameters

  • self:
  • options: SNMP options table
  • ...: Object identifiers to be queried.

Return values:

  1. status False if error, true otherwise
  2. Table with all decoded responses and their OIDs.

See also:

ip2str (ip)

Transforms a table representing an IP to a string.

Parameters

  • ip: IP table.

Return value:

IP string.
new (self, host, port, community, options)

Creates a new Helper instance

Parameters

  • self:
  • host: string containing the host name or ip
  • port: number containing the port to connect to
  • community: string containing SNMP community
  • options: A table with appropriate options: * timeout - the timeout in milliseconds (Default: 5000) * version - the SNMP version code (Default: 0 (SNMP V1))

Return value:

o a new instance of Helper
oid2str (oid)

Transforms a table representing an object identifier to a string.

Parameters

  • oid: Object identifier table.

Return value:

OID string.
request (self, message)

Communications helper Sends an SNMP message and receives a response.

Parameters

  • self:
  • message: the result of one of the build*Request functions

Return values:

  1. status False if there was an error, true otherwise.
  2. response The raw response read from the socket.
set (self, options, oid, setparam, value)

Sends an SNMP Set request

Parameters

  • self:
  • options: SNMP options table
  • oid: Object identifiers of object to be set.
  • setparam:
  • value: To which value object should be set. If given a table, use the table instead of OID/value pair.

Return values:

  1. status False if error, true otherwise
  2. Table with all decoded responses and their OIDs.

See also:

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.
walk (self, base_oid)

Walks the MIB Tree

Parameters

  • self:
  • 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

Tables

snmp.options

SNMP options table

Fields
  • reqId: Request ID.
  • err: Error.
  • errIdx: Error index.

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 ]