Nmap lu-enum NSE Script


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

Script Description


The lu-enum.nse script attempts to enumerate Logical Units (LU) of TN3270E servers.

When connecting to a TN3270E server you are assigned a Logical Unit (LU) or you can tell the TN3270E server which LU you'd like to use. Typically TN3270E servers are configured to give you an LU from a pool of LUs. They can also have LUs set to take you to a specific application. This script attempts to guess valid LUs that bypass the default LUs you are assigned. For example, if a TN3270E server sends you straight to TPX you could use this script to find LUs that take you to TSO, CICS, etc.

Lu-enum NSE Script Arguments


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

lu-enum.path

Folder used to store valid logical unit 'screenshots' Defaults to None and doesn't store anything. This stores all valid logical units.

lulist

Path to list of Logical Units to test. Defaults the initial Logical Unit TN3270E provides, replacing the last two characters with 00-99.

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=lu-enum --script-args lu-enum.path=value,lulist=value <target>

Lu-enum NSE Script Example Usage


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

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

nmap --script lu-enum --script-args lulist=lus.txt,
lu-enum.path="/home/dade/screenshots/" -p 23 -sV <targets>

Lu-enum NSE Script Example Output


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

PORT     STATE SERVICE REASON  VERSION
23/tcp   open  tn3270  syn-ack IBM Telnet TN3270 (TN3270E)
| lu-enum:
|   Logical Units:
|     LU:BSLVLU69 - Valid credentials
|_  Statistics: Performed 7 guesses in 7 seconds, average tps: 1.0

Lu-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 lu-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:

58:	-- @param data contains the data
59:	-- @return status true on success, false on failure
60:	-- @return err string containing error message if status is false
61:	local function save_screens( filename, data )
62:	  local f = io.open( filename, "w")
63:	  if not f then return false, ("Failed to open file (%s)"):format(filename) end
64:	  if not(f:write(data)) then return false, ("Failed to write file (%s)"):format(filename) end
65:	  f:close()
66:	  return true
67:	end
68:	

Failed to write file (%s)


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

59:	-- @return status true on success, false on failure
60:	-- @return err string containing error message if status is false
61:	local function save_screens( filename, data )
62:	  local f = io.open( filename, "w")
63:	  if not f then return false, ("Failed to open file (%s)"):format(filename) end
64:	  if not(f:write(data)) then return false, ("Failed to write file (%s)"):format(filename) end
65:	  f:close()
66:	  return true
67:	end
68:	
69:	--- 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:

106:	    local threshold = 90
107:	    stdnse.verbose(2,"Trying Logical Unit: %s", pass)
108:	    self.tn3270:set_lu(pass)
109:	    local status, err = self.tn3270:initiate(self.host,self.port)
110:	    if not status then
111:	      stdnse.debug(2,"Could not initiate TN3270: %s", err )
112:	      stdnse.verbose(2, "Invalid LU: %s",string.upper(pass))
113:	      return false,  brute.Error:new( "Invalid Logical Unit" )
114:	    end
115:	    self.tn3270:get_all_data()
116:	    self.tn3270:get_screen_debug(2)

Invalid LU: %s


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

107:	    stdnse.verbose(2,"Trying Logical Unit: %s", pass)
108:	    self.tn3270:set_lu(pass)
109:	    local status, err = self.tn3270:initiate(self.host,self.port)
110:	    if not status then
111:	      stdnse.debug(2,"Could not initiate TN3270: %s", err )
112:	      stdnse.verbose(2, "Invalid LU: %s",string.upper(pass))
113:	      return false,  brute.Error:new( "Invalid Logical Unit" )
114:	    end
115:	    self.tn3270:get_all_data()
116:	    self.tn3270:get_screen_debug(2)
117:	    if path ~= nil then

Invalid Logical Unit


Here is a relevant code snippet related to the "Invalid Logical Unit" error message:

108:	    self.tn3270:set_lu(pass)
109:	    local status, err = self.tn3270:initiate(self.host,self.port)
110:	    if not status then
111:	      stdnse.debug(2,"Could not initiate TN3270: %s", err )
112:	      stdnse.verbose(2, "Invalid LU: %s",string.upper(pass))
113:	      return false,  brute.Error:new( "Invalid Logical Unit" )
114:	    end
115:	    self.tn3270:get_all_data()
116:	    self.tn3270:get_screen_debug(2)
117:	    if path ~= nil then
118:	      stdnse.verbose(2,"Writting screen to: %s", path..string.upper(pass)..".txt")

Failed writting screen to: %s


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

116:	    self.tn3270:get_screen_debug(2)
117:	    if path ~= nil then
118:	      stdnse.verbose(2,"Writting screen to: %s", path..string.upper(pass)..".txt")
119:	      local status, err = save_screens(path..string.upper(pass)..".txt",self.tn3270:get_screen())
120:	      if not status then
121:	        stdnse.verbose(2,"Failed writting screen to: %s", path..string.upper(pass)..".txt")
122:	      end
123:	    end
124:	
125:	    stdnse.debug(3, "compare results: %s ", tostring(screen_diff(original, self.tn3270:get_screen_raw())))
126:	    if screen_diff(original, self.tn3270:get_screen_raw()) > threshold then

Invalid Logical Unit


Here is a relevant code snippet related to the "Invalid Logical Unit" error message:

123:	    end
124:	
125:	    stdnse.debug(3, "compare results: %s ", tostring(screen_diff(original, self.tn3270:get_screen_raw())))
126:	    if screen_diff(original, self.tn3270:get_screen_raw()) > threshold then
127:	      stdnse.verbose(2,'Same Screen for LU: %s',string.upper(pass))
128:	      return false,  brute.Error:new( "Invalid Logical Unit" )
129:	    else
130:	      stdnse.verbose(2,"Valid Logical Unit: %s",string.upper(pass))
131:	      return true, creds.Account:new("LU", string.upper(pass), creds.State.VALID)
132:	    end
133:	  end

[lu_test] Could not initiate TN3270: %s


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

141:	local function lu_test( host, port )
142:	  local tn = tn3270.Telnet:new()
143:	  local status, err = tn:initiate(host,port)
144:	  
145:	  if not status then
146:	    stdnse.debug(1,"[lu_test] Could not initiate TN3270: %s", err )
147:	    return false
148:	  end
149:	
150:	  stdnse.debug(2,"[lu_test] Displaying initial TN3270 Screen:")
151:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug

Not in TN3270E Mode. LU not supported.', '


Here is a relevant code snippet related to the "Not in TN3270E Mode. LU not supported.', '" error message:

151:	  tn:get_screen_debug(2) -- prints TN3270 screen to debug
152:	  if tn.state == tn.TN3270E_DATA then -- Could make a function in the library 'istn3270e'
153:	    stdnse.debug(1,"[lu_test] Orig screen: %s", tn:get_screen_raw())
154:	    return true, tn:get_lu(), tn:get_screen_raw()
155:	  else 
156:	    return false, 'Not in TN3270E Mode. LU not supported.', ''
157:	  end
158:	
159:	end
160:	
161:	-- Checks if it's a valid Logical Unit name

Version


This page has been created based on Nmap version 7.92.

Go back to menu.