Nmap vtam-enum NSE Script


This page contains detailed information about how to use the vtam-enum NSE script. For list of all NSE scripts, visit the Nmap NSE Library.

Select:
Overview
Error Messages

Script Overview


Script source code: https://github.com/nmap/nmap/tree/master/scripts/vtam-enum.nse
Script categories: intrusive, brute
Target service / protocol: tn3270
Target network port(s): 23, 992
List of CVEs: -

Script Description


Many mainframes use VTAM screens to connect to various applications (CICS, IMS, TSO, and many more).

This script attempts to brute force those VTAM application IDs.

This script is based on mainframe_brute by Dominic White (https://github.com/sensepost/mainframe_brute). However, this script doesn't rely on any third party libraries or tools and instead uses the NSE TN3270 library which emulates a TN3270 screen in lua.

Application IDs only allows for 8 byte IDs, that is the only specific rule found for application IDs.

Vtam-enum NSE Script Arguments


This is a full list of arguments supported by the vtam-enum.nse script:

idlist

Path to list of application IDs to test. Defaults to nselib/data/vhosts-default.lst.

vtam-enum.commands

Commands in a semi-colon separated list needed to access VTAM. Defaults to nothing.

vtam-enum.macros

When set to true does not prepend the application ID with 'logon applid()'. Default is false.

vtam-enum.path

Folder used to store valid transaction id 'screenshots' Defaults to None and doesn't store anything.

creds.global

Credentials to be returned by Credentials.getCredentials regardless of the service.

creds.[service]

Credentials to be returned by Credentials.getCredentials for [service]. E.g. creds.http=admin:password

passdb

The filename of an alternate password database. Default: nselib/data/passwords.lst

unpwdb.passlimit

The maximum number of passwords passwords will return (default unlimited).

unpwdb.timelimit

The maximum amount of time that any iterator will run before stopping. The value is in seconds by default and you can follow it with ms, s, m, or h for milliseconds, seconds, minutes, or hours. For example, unpwdb.timelimit=30m or unpwdb.timelimit=.5h for 30 minutes. The default depends on the timing template level (see the module description). Use the value 0 to disable the time limit.

unpwdb.userlimit

The maximum number of usernames usernames will return (default unlimited).

userdb

The filename of an alternate username database. Default: nselib/data/usernames.lst

brute.credfile

A file containing username and password pairs delimited by '/'

brute.delay

The number of seconds to wait between guesses (default: 0)

brute.emptypass

Guess an empty password for each user (default: false)

brute.firstonly

Stop guessing after first password is found (default: false)

brute.guesses

The number of guesses to perform against each account. (default: 0 (unlimited)). The argument can be used to prevent account lockouts.

brute.mode

Can be user, pass or creds and determines what mode to run the engine in.

  • user - the unpwdb library is used to guess passwords, every password Password is tried for each user. (The user iterator is in the outer loop)
  • pass - the unpwdb library is used to guess passwords, each password Is tried for every user. (The password iterator is in the outer loop)
  • creds - a set of credentials (username and password pairs) are Guessed against the service. This allows for lists of known or common username and password combinations to be tested. If no mode is specified and the script has not added any custom iterator the pass mode will be enabled.

brute.passonly

Iterate over passwords only for services that provide only a password for authentication. (default: false)

brute.retries

The number of times to retry if recoverable failures occur. (default: 2)

brute.start

The number of threads the engine will start with. (default: 5).

brute.threads

The number of initial worker threads, the number of active threads will be automatically adjusted.

brute.unique

Make sure that each password is only guessed once (default: true)

brute.useraspass

Guess the username as password for each user (default: true)

creds.[service]

Credentials to be returned by Credentials.getCredentials for [service]. E.g. creds.http=admin:password

- - -
To use these script arguments, add them to the Nmap command line using the --script-args arg1=value,[arg2=value,..] syntax. For example:

nmap --script=vtam-enum --script-args idlist=value,vtam-enum.commands=value <target>

Vtam-enum NSE Script Example Usage


Here's an example of how to use the vtam-enum.nse script:

nmap --script vtam-enum -p 23 <targets>

nmap --script vtam-enum --script-args idlist=defaults.txt,
vtam-enum.command="exit;logon applid(logos)",vtam-enum.macros=true
vtam-enum.path="/home/dade/screenshots/" -p 23 -sV <targets>

Vtam-enum NSE Script Example Output


Here's a sample output from the vtam-enum.nse script:

PORT   STATE SERVICE VERSION
23/tcp open  tn3270  IBM Telnet TN3270
| vtam-enum:
|   VTAM Application ID:
|     applid:TSO - Valid credentials
|     applid:CICSTS51 - Valid credentials
|_  Statistics: Performed 14 guesses in 5 seconds, average tps: 2

Vtam-enum NSE Script Example XML Output


There is no sample XML output for this module. However, by providing the -oX <file> option, Nmap will produce a XML output and save it in the file.xml file.

Author


  • Philip Young aka Soldier of Fortran

References


See Also


Visit Nmap NSE Library for more scripts.

The vtam-enum.nse script may fail with the following error messages. Check for the possible causes by using the code snippets highlighted below found in the script source code. This can often times help in identifying the root cause of the problem.

Failed to open file (%s)


Here is a relevant code snippet related to the "Failed to open file (%s)" error message:

71:	-- @param data contains the data
72:	-- @return status true on success, false on failure
73:	-- @return err string containing error message if status is false
74:	local function save_screens( filename, data )
75:	  local f = io.open( filename, "w")
76:	  if not f then return false, ("Failed to open file (%s)"):format(filename) end
77:	  if not(f:write(data)) then return false, ("Failed to write file (%s)"):format(filename) end
78:	  f:close()
79:	  return true
80:	end
81:	

Failed to write file (%s)


Here is a relevant code snippet related to the "Failed to write file (%s)" error message:

72:	-- @return status true on success, false on failure
73:	-- @return err string containing error message if status is false
74:	local function save_screens( filename, data )
75:	  local f = io.open( filename, "w")
76:	  if not f then return false, ("Failed to open file (%s)"):format(filename) end
77:	  if not(f:write(data)) then return false, ("Failed to write file (%s)"):format(filename) end
78:	  f:close()
79:	  return true
80:	end
81:	
82:	--- Compares two screens and returns the difference as a percentage

Could not initiate TN3270: %s


Here is a relevant code snippet related to the "Could not initiate TN3270: %s" error message:

108:	    return o
109:	  end,
110:	  connect = function( self )
111:	    local status, err = self.tn3270:initiate(self.host,self.port)
112:	    if not status then
113:	      stdnse.debug2("Could not initiate TN3270: %s", err )
114:	      return false
115:	    end
116:	    return true
117:	  end,
118:	  disconnect = function( self )

UNABLE TO ESTABLISH SESSION


Here is a relevant code snippet related to the "UNABLE TO ESTABLISH SESSION" error message:

138:	    self.tn3270:send_cursor(cmdfmt:format(pass))
139:	    self.tn3270:get_all_data()
140:	    self.tn3270:get_screen_debug(2)
141:	    local current_screen = self.tn3270:get_screen_raw()
142:	
143:	    if (self.tn3270:find('UNABLE TO ESTABLISH SESSION')  or -- thanks goes to Dominic White for creating these
144:	        self.tn3270:find('COMMAND UNRECOGNI[SZ]ED')      or
145:	        self.tn3270:find('USSMSG0[1-4]')                 or
146:	        self.tn3270:find('SESSION NOT BOUND')            or
147:	        self.tn3270:find('INVALID COMMAND')              or
148:	        self.tn3270:find('PARAMETER OMITTED')            or

INVALID COMMAND


Here is a relevant code snippet related to the "INVALID COMMAND" error message:

142:	
143:	    if (self.tn3270:find('UNABLE TO ESTABLISH SESSION')  or -- thanks goes to Dominic White for creating these
144:	        self.tn3270:find('COMMAND UNRECOGNI[SZ]ED')      or
145:	        self.tn3270:find('USSMSG0[1-4]')                 or
146:	        self.tn3270:find('SESSION NOT BOUND')            or
147:	        self.tn3270:find('INVALID COMMAND')              or
148:	        self.tn3270:find('PARAMETER OMITTED')            or
149:	        self.tn3270:find('REQUERIDO PARAMETRO PERDIDO')  or
150:	        self.tn3270:find('Your command is unrecognized') or
151:	        self.tn3270:find('invalid command or syntax')    or
152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or

invalid command or syntax


Here is a relevant code snippet related to the "invalid command or syntax" error message:

146:	        self.tn3270:find('SESSION NOT BOUND')            or
147:	        self.tn3270:find('INVALID COMMAND')              or
148:	        self.tn3270:find('PARAMETER OMITTED')            or
149:	        self.tn3270:find('REQUERIDO PARAMETRO PERDIDO')  or
150:	        self.tn3270:find('Your command is unrecognized') or
151:	        self.tn3270:find('invalid command or syntax')    or
152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or
153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or

REQSESS error


Here is a relevant code snippet related to the "REQSESS error" error message:

148:	        self.tn3270:find('PARAMETER OMITTED')            or
149:	        self.tn3270:find('REQUERIDO PARAMETRO PERDIDO')  or
150:	        self.tn3270:find('Your command is unrecognized') or
151:	        self.tn3270:find('invalid command or syntax')    or
152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or
153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or

syntax invalid


Here is a relevant code snippet related to the "syntax invalid" error message:

149:	        self.tn3270:find('REQUERIDO PARAMETRO PERDIDO')  or
150:	        self.tn3270:find('Your command is unrecognized') or
151:	        self.tn3270:find('invalid command or syntax')    or
152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or
153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then

INVALID SYSTEM


Here is a relevant code snippet related to the "INVALID SYSTEM" error message:

150:	        self.tn3270:find('Your command is unrecognized') or
151:	        self.tn3270:find('invalid command or syntax')    or
152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or
153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then
160:	      -- Looks like an invalid APPLID.

INVALID USERID, APPLID


Here is a relevant code snippet related to the "INVALID USERID, APPLID" error message:

152:	        self.tn3270:find('UNSUPPORTED FUNCTION')         or
153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then
160:	      -- Looks like an invalid APPLID.
161:	      stdnse.verbose(2,'Invalid Application ID: %s',string.upper(pass))
162:	      return false,  brute.Error:new( "Invalid VTAM Application ID" )

UNABLE TO CONNECT TO THE REQUESTED APPLICATION


Here is a relevant code snippet related to the "UNABLE TO CONNECT TO THE REQUESTED APPLICATION" error message:

153:	        self.tn3270:find('REQSESS error')                or
154:	        self.tn3270:find('syntax invalid')               or
155:	        self.tn3270:find('INVALID SYSTEM')               or
156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then
160:	      -- Looks like an invalid APPLID.
161:	      stdnse.verbose(2,'Invalid Application ID: %s',string.upper(pass))
162:	      return false,  brute.Error:new( "Invalid VTAM Application ID" )
163:	    else

Invalid Application ID: %s


Here is a relevant code snippet related to the "Invalid Application ID: %s" error message:

156:	        self.tn3270:find('NOT VALID')                    or
157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then
160:	      -- Looks like an invalid APPLID.
161:	      stdnse.verbose(2,'Invalid Application ID: %s',string.upper(pass))
162:	      return false,  brute.Error:new( "Invalid VTAM Application ID" )
163:	    else
164:	      stdnse.verbose(2,"Valid Application ID: %s",string.upper(pass))
165:	      if path ~= nil then
166:	        stdnse.verbose(2,"Writting screen to: %s", path..string.upper(pass)..".txt")

Invalid VTAM Application ID


Here is a relevant code snippet related to the "Invalid VTAM Application ID" error message:

157:	        self.tn3270:find('INVALID USERID, APPLID') )     or
158:	        self.tn3270:find('UNABLE TO CONNECT TO THE REQUESTED APPLICATION') or
159:	        screen_diff(previous_screen, current_screen) > threshold then
160:	      -- Looks like an invalid APPLID.
161:	      stdnse.verbose(2,'Invalid Application ID: %s',string.upper(pass))
162:	      return false,  brute.Error:new( "Invalid VTAM Application ID" )
163:	    else
164:	      stdnse.verbose(2,"Valid Application ID: %s",string.upper(pass))
165:	      if path ~= nil then
166:	        stdnse.verbose(2,"Writting screen to: %s", path..string.upper(pass)..".txt")
167:	        local status, err = save_screens(path..string.upper(pass)..".txt",self.tn3270:get_screen())

Failed writting screen to: %s


Here is a relevant code snippet related to the "Failed writting screen to: %s" error message:

164:	      stdnse.verbose(2,"Valid Application ID: %s",string.upper(pass))
165:	      if path ~= nil then
166:	        stdnse.verbose(2,"Writting screen to: %s", path..string.upper(pass)..".txt")
167:	        local status, err = save_screens(path..string.upper(pass)..".txt",self.tn3270:get_screen())
168:	        if not status then
169:	          stdnse.verbose(2,"Failed writting screen to: %s", path..string.upper(pass)..".txt")
170:	        end
171:	      end
172:	      return true, creds.Account:new(type,string.upper(pass), creds.State.VALID)
173:	    end
174:	  end

Could not initiate TN3270: %s


Here is a relevant code snippet related to the "Could not initiate TN3270: %s" error message:

186:	  local status, err = tn:initiate(host,port)
187:	  stdnse.debug1("Testing if VTAM and 'logon applid' command supported")
188:	  stdnse.debug2("Connecting TN3270 to %s:%s", host.targetname or host.ip, port.number)
189:	
190:	  if not status then
191:	    stdnse.debug1("Could not initiate TN3270: %s", err )
192:	    return false
193:	  end
194:	
195:	  stdnse.debug2("Displaying initial TN3270 Screen:")
196:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug

Version


This page has been created based on Nmap version 7.92.

Go back to menu.