Nmap tso-enum NSE Script


This page contains detailed information about how to use the tso-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/tso-enum.nse
Script categories: intrusive, brute
Target service / protocol: tn3270
Target network port(s): 23, 992, 623
List of CVEs: -

Script Description


TSO User ID enumerator for IBM mainframes (z/OS). The TSO logon panel tells you when a user ID is valid or invalid with the message: IKJ56420I Userid <user ID> not authorized to use TSO.

The TSO logon process can work in two ways: 1) You get prompted with IKJ56700A ENTER USERID - to which you reply with the user you want to use. If the user ID is valid it will give you a normal TSO logon screen. Otherwise it will give you the screen logon error above. 2) You're given the TSO logon panel and enter your user ID at the Userid ===> prompt. If you give it an invalid user ID you receive the error message above.

This script relies on the NSE TN3270 library which emulates a TN3270 screen for NMAP.

TSO user IDs have the following rules:

  • it cannot begin with a number
  • only contains alpha-numeric characters and @, #, $.
  • it cannot be longer than 7 chars

Tso-enum NSE Script Arguments


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

tso-enum.commands

Commands in a semi-colon separated list needed to access TSO. Defaults to tso.

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=tso-enum --script-args tso-enum.commands=value,creds.global=value <target>

Tso-enum NSE Script Example Usage


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

nmap --script=tso-enum -p 23 <targets>

nmap -sV -p 9923 10.32.70.10 --script tso-enum --script-args userdb=tso_users.txt,tso-enum.commands="logon applid(tso)"

Tso-enum NSE Script Example Output


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

PORT   STATE SERVICE VERSION
23/tcp open  tn3270  IBM Telnet TN3270
| tso-enum:
|   TSO User ID:
|     TSO User:RAZOR -  Valid User ID
|     TSO User:BLADE -  Valid User ID
|     TSO User:PLAGUE -  Valid User ID
|_  Statistics: Performed 6 guesses in 3 seconds, average tps: 2

Tso-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


Related NSE scripts to the tso-enum.nse script:

Visit Nmap NSE Library for more scripts.

The tso-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.

Could not initiate TN3270: %s


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

80:	  end,
81:	  connect = function( self )
82:	    local status, err = self.tn3270:initiate(self.host,self.port)
83:	    self.tn3270:get_screen_debug(2)
84:	    if not status then
85:	      stdnse.debug("Could not initiate TN3270: %s", err )
86:	      return false
87:	    end
88:	    return true
89:	  end,
90:	  disconnect = function( self )

IKJ56710I INVALID USERID


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

118:	      self.tn3270:get_all_data()
119:	    end
120:	
121:	    if not self.tn3270:find("ENTER USERID")
122:	       and not self.tn3270:find("TSO/E LOGON")
123:	       and not self.tn3270:find("IKJ56710I INVALID USERID") then
124:	      local err = brute.Error:new("Too many connections")
125:	        -- This error occurs on too many concurrent application requests it
126:	        -- should be temporary. We use the new setReduce function.
127:	      err:setReduce(true)
128:	      stdnse.debug(1,"TSO Unavailable for UserID %s", pass )

Too many connections


Here is a relevant code snippet related to the "Too many connections" error message:

119:	    end
120:	
121:	    if not self.tn3270:find("ENTER USERID")
122:	       and not self.tn3270:find("TSO/E LOGON")
123:	       and not self.tn3270:find("IKJ56710I INVALID USERID") then
124:	      local err = brute.Error:new("Too many connections")
125:	        -- This error occurs on too many concurrent application requests it
126:	        -- should be temporary. We use the new setReduce function.
127:	      err:setReduce(true)
128:	      stdnse.debug(1,"TSO Unavailable for UserID %s", pass )
129:	      return false, err

IKJ56710I INVALID USERID


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

137:	    end
138:	
139:	    stdnse.debug(2,"Screen Received for User ID: %s", pass)
140:	    self.tn3270:get_screen_debug(2)
141:	    if self.tn3270:find('not authorized to use TSO') or
142:	       self.tn3270:find('IKJ56710I INVALID USERID') then -- invalid user ID
143:	      return false,  brute.Error:new( "Incorrect User ID" )
144:	    elseif self.tn3270:find('NO USER APPLID AVAILABLE') or self.tn3270:isClear()
145:	           or not (self.tn3270:find('TSO/E LOGON') or
146:	                   self.tn3270:find("IKJ56710I INVALID USERID")) then
147:	        -- This error occurs on too many concurrent application requests it

Incorrect User ID


Here is a relevant code snippet related to the "Incorrect User ID" error message:

138:	
139:	    stdnse.debug(2,"Screen Received for User ID: %s", pass)
140:	    self.tn3270:get_screen_debug(2)
141:	    if self.tn3270:find('not authorized to use TSO') or
142:	       self.tn3270:find('IKJ56710I INVALID USERID') then -- invalid user ID
143:	      return false,  brute.Error:new( "Incorrect User ID" )
144:	    elseif self.tn3270:find('NO USER APPLID AVAILABLE') or self.tn3270:isClear()
145:	           or not (self.tn3270:find('TSO/E LOGON') or
146:	                   self.tn3270:find("IKJ56710I INVALID USERID")) then
147:	        -- This error occurs on too many concurrent application requests it
148:	        -- should be temporary. We use the new setReduce function here to reduce number of connections.

IKJ56710I INVALID USERID


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

141:	    if self.tn3270:find('not authorized to use TSO') or
142:	       self.tn3270:find('IKJ56710I INVALID USERID') then -- invalid user ID
143:	      return false,  brute.Error:new( "Incorrect User ID" )
144:	    elseif self.tn3270:find('NO USER APPLID AVAILABLE') or self.tn3270:isClear()
145:	           or not (self.tn3270:find('TSO/E LOGON') or
146:	                   self.tn3270:find("IKJ56710I INVALID USERID")) then
147:	        -- This error occurs on too many concurrent application requests it
148:	        -- should be temporary. We use the new setReduce function here to reduce number of connections.
149:	      local err = brute.Error:new( "TSO Unavailable" )
150:	      err:setReduce(true)
151:	      stdnse.debug(1,"TSO Unavailable for UserID %s", pass )

TSO Unavailable


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

144:	    elseif self.tn3270:find('NO USER APPLID AVAILABLE') or self.tn3270:isClear()
145:	           or not (self.tn3270:find('TSO/E LOGON') or
146:	                   self.tn3270:find("IKJ56710I INVALID USERID")) then
147:	        -- This error occurs on too many concurrent application requests it
148:	        -- should be temporary. We use the new setReduce function here to reduce number of connections.
149:	      local err = brute.Error:new( "TSO Unavailable" )
150:	      err:setReduce(true)
151:	      stdnse.debug(1,"TSO Unavailable for UserID %s", pass )
152:	      return false, err
153:	    else
154:	      stdnse.verbose("Valid TSO User ID: %s", string.upper(pass))

Could not initiate TN3270: %s


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

171:	  local status, err = tn:initiate(host,port)
172:	  local tso = false -- initially we're not at TSO logon panel
173:	  local secprod = "RACF"
174:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug
175:	  if not status then
176:	    stdnse.debug("Could not initiate TN3270: %s", err )
177:	    return tso, "Could not Initiate TN3270"
178:	  end
179:	  local run = stringaux.strsplit(";%s*", commands)
180:	  for i = 1, #run do
181:	    stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])

Could not Initiate TN3270


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

172:	  local tso = false -- initially we're not at TSO logon panel
173:	  local secprod = "RACF"
174:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug
175:	  if not status then
176:	    stdnse.debug("Could not initiate TN3270: %s", err )
177:	    return tso, "Could not Initiate TN3270"
178:	  end
179:	  local run = stringaux.strsplit(";%s*", commands)
180:	  for i = 1, #run do
181:	    stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
182:	    tn:send_cursor(run[i])

Enumeration is not possible. PASSWORDPREPROMPT is set to ON.


Here is a relevant code snippet related to the "Enumeration is not possible. PASSWORDPREPROMPT is set to ON." error message:

192:	    tso = true
193:	    -- Patch OA44855 removed the ability to enumerate users
194:	    tn:send_cursor("notreal")
195:	    tn:get_all_data()
196:	    if tn:find("IKJ56476I ENTER PASSWORD") then
197:	      return false, secprod, "Enumeration is not possible. PASSWORDPREPROMPT is set to ON."
198:	    end
199:	  end
200:	  tn:send_pf(3)
201:	  tn:disconnect()
202:	  return tso, secprod, "Could not get to TSO. Try --script-args=tso-enum.commands='logon applid(tso)'. Aborting."

Could not get to TSO. Try --script-args=tso-enum.commands='logon applid(tso)'. Aborting.


Here is a relevant code snippet related to the "Could not get to TSO. Try --script-args=tso-enum.commands='logon applid(tso)'. Aborting." error message:

197:	      return false, secprod, "Enumeration is not possible. PASSWORDPREPROMPT is set to ON."
198:	    end
199:	  end
200:	  tn:send_pf(3)
201:	  tn:disconnect()
202:	  return tso, secprod, "Could not get to TSO. Try --script-args=tso-enum.commands='logon applid(tso)'. Aborting."
203:	end
204:	
205:	--- Tests the target to see if we can speed up brute forcing
206:	-- VTAM/USSTable will sometimes allow you to put the userid
207:	-- in the command area either through data() or just adding

Could not initiate TN3270: %s


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

218:	  stdnse.debug2("Connecting TN3270 to %s:%s", host.targetname or host.ip, port.number)
219:	  local status, err = tn:initiate(host,port)
220:	  stdnse.debug2("Displaying initial TN3270 Screen:")
221:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug
222:	  if not status then
223:	    stdnse.debug("Could not initiate TN3270: %s", err )
224:	    return false
225:	  end
226:	  -- We're connected now to test.
227:	  local data = false
228:	  if commands:upper():find('LOGON APPLID') then

IKJ56710I INVALID USERID


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

248:	    end
249:	    tn:get_all_data()
250:	  end
251:	  tn:get_screen_debug(2)
252:	
253:	  if tn:find("IKJ56710I INVALID USERID")     or
254:	     tn:find("Enter LOGON parameters below") then
255:	    stdnse.debug('IKJ56700A message skip supported')
256:	    return true
257:	  else
258:	    return false

Version


This page has been created based on Nmap version 7.92.

Go back to menu.