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

Sponsors

SolarWinds makes easy-to-use enterprise IT management software to help IT pros solve problems every day and help to enable efficient and effective management of networks and IT environments.

Join our online community of over 100,000 IT professionals talking shop. Get involved. Gain insights. Share tips and tricks. Visit thwack today!


Library drda

DRDA Library supporting a very limited subset of operations.

Summary

  • The library currently provides functionality to: (1) Query the server for
basic settings using the getServerInfo function of the helper class. (2) Authenticate to a DB2 server using a plain-text username and password.

The library contains the following classes:

  • DRDA
** Implements the Distributed Relational Database Architecture class .
  • DRDAParameter
** Implements a number of functions to handle DRDA parameters.
  • DDM
** Implements the DDM portion of the DRDA structure
  • Command
** Provides functions for easy creation of the most common DRDAs. ** Implemented as a static class that returns an instance of the DRDA.
  • Helper
** A helper class that provides easy access to the rest of the library
  • DB2Socket
** A smallish socket wrapper that provides fundamental buffering
  • StringUtil
** Provides EBCDIC/ASCII conversion functions
  • Comm
** Provides fundamental communication support (send/receive DRDAPacket)
  • DRDAPacket
** A class holding one or more DRDA's and provides some basic access methods

The following sample code illustrates how scripts can use the Helper class to interface with the library:

	db2helper = drda.Helper:new()
	status, err = db2helper:connect(host, port)
	status, res = db2helper:getServerInfo()
	status, err = db2helper:close()

The implementation is based on packet dumps and the excellent decoding provided by Wireshark.

There is some documentation at http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db29.doc.drda/db2z_drda.htm.

Author:
"Patrik Karlsson <patrik@cqure.net>"

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

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

Functions

__tostring (self)

Converts the DDM object to a string

__tostring (self)

Converts the DDM object to a string

__tostring (self)

Converts the DDM object to a string

ACCRDB (database, rdbaccl, prdid, prddata, typdefnam, crrtkn, typdefovr)

Builds an ACCRDB DRDA packet

ACCSEC (secmec, database)

Builds an ACCSEC DRDA packet

addParameter (self, param)

Adds a DRDA parameter to the table

close (self)

Closes an open connection.

close (self)

Closes an open connection.

connect (self, hostid, port, protocol)

Establishes a connection.

connect (self, hostid, port, protocol)

Establishes a connection.

exchDRDAPacket (self, packet)

Sends a packet to the server and receives the response

EXCSAT (extname, srvname, rellev, mgrlvlls, srvclass)

Builds an EXCSAT DRDA packet

fromString (self, str)

Constructs a DDM object from a string

fromString (self, str)

Constructs a DDM object from a string

getData (self)

Returns the data in EBCDIC format

getDataAsASCII (self)

Returns the data portion of the parameter as an ASCII string

getParameter (self, codepoint)

Gets a parameter from the DRDA parameter table

getServerInfo (self)

Returns Server Information (name, platform, version)

isChained (self)

Verifiers if there are additional DRDA's following

login (self, database, username, password)

Login to DB2 database server

new (self, codepoint, format, corelid)

Creates a new DDM packet

new (self, codepoint, format, corelid)

Creates a new DDM packet

padWithChar (str, chr, len)

Pads a string with a character

receive (self, db2socket)

Receives data from the db2socket and builds a DRDA object

recv (self, count)

Opposed to the socket:receive_bytes function, that returns at least x bytes, this function returns the amount of bytes requested.

recvDRDA (self)

Reads a single or multiple DRDA's of the socket

SECCHK (secmec, database, username, password)

Builds a SECCHK DRDA packet

send (self, data)

Sends data over the socket

send (self, data)

Sends data over the socket

sendDRDA (self, drda)

Sends a single or multiple DRDA's over the socket

setChained (self, chained)

Set the DRDA as chained (more following)

setDDM (self, ddm)

Sets the DDM

toASCII (ebcdic)

Converts an EBCDIC string to ASCII

toEBCDIC (ascii)

Converts an ASCII string to EBCDIC



Functions

__tostring (self)

Converts the DDM object to a string

Parameters

  • self:
__tostring (self)

Converts the DDM object to a string

Parameters

  • self:
__tostring (self)

Converts the DDM object to a string

Parameters

  • self:
ACCRDB (database, rdbaccl, prdid, prddata, typdefnam, crrtkn, typdefovr)

Builds an ACCRDB DRDA packet

Parameters

  • database: string containing the database name
  • rdbaccl: string containing the RDB access manager class
  • prdid: string containing the product id
  • prddata:
  • typdefnam: string containing the data type definition name
  • crrtkn:
  • typdefovr: string containing the data type definition override

Return value:

drda DRDA instance
ACCSEC (secmec, database)

Builds an ACCSEC DRDA packet

Parameters

  • secmec: number containing the security mechanism ID
  • database: string containing the database name

Return value:

drda DRDA instance
addParameter (self, param)

Adds a DRDA parameter to the table

Parameters

  • self:
  • param: DRDAParam containing the parameter to add to the table

Return values:

  1. status bool true on success, false on failure
  2. err string containing the error message if status is false
close (self)

Closes an open connection.

Parameters

  • self:

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
close (self)

Closes an open connection.

Parameters

  • self:

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
connect (self, hostid, port, protocol)

Establishes a connection.

Parameters

  • self:
  • hostid: Host table, hostname, or IP address.
  • port: Port table or number.
  • protocol: "tcp", "udp", or

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
connect (self, hostid, port, protocol)

Establishes a connection.

Parameters

  • self:
  • hostid: Host table, hostname, or IP address.
  • port: Port table or number.
  • protocol: "tcp", "udp", or

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
exchDRDAPacket (self, packet)

Sends a packet to the server and receives the response

Parameters

  • self:
  • packet:

Return values:

  1. status true on success, false on failure
  2. packet an instance of DRDAPacket
EXCSAT (extname, srvname, rellev, mgrlvlls, srvclass)

Builds an EXCSAT DRDA packet

Parameters

  • extname: string containing the external name
  • srvname: string containing the server name
  • rellev: string containing the server product release level
  • mgrlvlls: string containing the manager level list
  • srvclass: string containing the server class name

Return value:

drda DRDA instance
fromString (self, str)

Constructs a DDM object from a string

Parameters

  • self:
  • str: containing the data from which to construct the object
fromString (self, str)

Constructs a DDM object from a string

Parameters

  • self:
  • str: containing the data from which to construct the object
getData (self)

Returns the data in EBCDIC format

Parameters

  • self:

Return value:

str containing the data portion of the DRDA parameter in EBCDIC
getDataAsASCII (self)

Returns the data portion of the parameter as an ASCII string

Parameters

  • self:

Return value:

str containing the data portion of the DRDA parameter as ASCII
getParameter (self, codepoint)

Gets a parameter from the DRDA parameter table

Parameters

  • self:
  • codepoint: number containing the parameter type ro retrieve

Return value:

param DRDAParameter containing the requested parameter
getServerInfo (self)

Returns Server Information (name, platform, version)

Parameters

  • self:

Return value:

table containing extname, srvclass, srvname and prodrel
isChained (self)

Verifiers if there are additional DRDA's following

Parameters

  • self:

Return value:

true if the DRDA is to be chained, false if it's the last one
login (self, database, username, password)

Login to DB2 database server

Parameters

  • self:
  • database: containing the name of the database
  • username: containing the authentication username
  • password: containing the authentication password

Return values:

  1. Status (true or false)
  2. err message (if status if false)
new (self, codepoint, format, corelid)

Creates a new DDM packet

Parameters

  • self:
  • codepoint:
  • format:
  • corelid:

Return value:

DDM object
new (self, codepoint, format, corelid)

Creates a new DDM packet

Parameters

  • self:
  • codepoint:
  • format:
  • corelid:

Return value:

DDM object
padWithChar (str, chr, len)

Pads a string with a character

Parameters

  • str: string to pad
  • chr: char to pad with
  • len: the total length of the finnished string

Return value:

str string containing the padded string
receive (self, db2socket)

Receives data from the db2socket and builds a DRDA object

Parameters

  • self:
  • db2socket: from which to read data

Return values:

  1. Status (true or false).
  2. Data (if status is true) or error string (if status is false).
recv (self, count)

Opposed to the socket:receive_bytes function, that returns at least x bytes, this function returns the amount of bytes requested.

Parameters

  • self:
  • count: of bytes to read

Return values:

  1. true on success, false on failure
  2. data containing bytes read from the socket err containing error message if status is false
recvDRDA (self)

Reads a single or multiple DRDA's of the socket

Parameters

  • self:

Return values:

  1. status (true or false)
  2. drda table containing retrieved DRDA's
SECCHK (secmec, database, username, password)

Builds a SECCHK DRDA packet

Parameters

  • secmec: number containing the security mechanism ID
  • database: string containing the database name
  • username: string
  • password: string

Return value:

drda DRDA instance
send (self, data)

Sends data over the socket

Parameters

  • self:
  • data:

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
send (self, data)

Sends data over the socket

Parameters

  • self:
  • data:

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
sendDRDA (self, drda)

Sends a single or multiple DRDA's over the socket

Parameters

  • self:
  • drda: a single or a table containing multiple DRDA's

Return values:

  1. Status (true or false).
  2. Error code (if status is false).
setChained (self, chained)

Set the DRDA as chained (more following)

Parameters

  • self:
  • chained: boolean true if more DRDA's are following
setDDM (self, ddm)

Sets the DDM

Parameters

  • self:
  • ddm: DDM to assign to the DRDA

Return value:

status boolean true on success, false on failure
toASCII (ebcdic)

Converts an EBCDIC string to ASCII

Parameters

  • ebcdic: string containing EBCDIC value

Return value:

string containing ASCII value
toEBCDIC (ascii)

Converts an ASCII string to EBCDIC

Parameters

  • ascii: string containing the ASCII value

Return value:

string containing the EBCDIC value

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 ]