Nmap nje-pass-brute NSE Script


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

Script Description


z/OS JES Network Job Entry (NJE) 'I record' password brute forcer.

After successfully negotiating an OPEN connection request, NJE requires sending, what IBM calls, an 'I record'. This initialization record may sometimes require a password. This script, provided with a valid OHOST/RHOST for the NJE connection, brute forces the password.

Most systems only have one password, it is recommended to use the brute.firstonly script argument.

Nje-pass-brute NSE Script Arguments


This is a full list of arguments supported by the nje-pass-brute.nse script:

nje-pass-brute.ohost

The target NJE server OHOST value.

nje-pass-brute.rhost

The target NJE server RHOST value.

nje-pass-brute.sleep

NJE only allows one connection from a valid OHOST. The sleep value ensures only one connection is valid at a time. The default is 1 second.

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=nje-pass-brute --script-args nje-pass-brute.ohost=value,nje-pass-brute.rhost=value <target>

Nje-pass-brute NSE Script Example Usage


Here's an example of how to use the nje-pass-brute.nse script:

nmap -sV --script=nje-pass-brute --script-args=ohost='POTATO',rhost='CACTUS' <target>

nmap --script=nje-pass-brute --script-args=ohost='POTATO',rhost='CACTUS',sleep=5 -p 175 <target>

Nje-pass-brute NSE Script Example Output


Here's a sample output from the nje-pass-brute.nse script:

PORT    STATE SERVICE VERSION
175/tcp open  nje     IBM Network Job Entry (JES)
| nje-pass-brute:
|   NJE Password:
|     Password:A - Valid credentials
|_  Statistics: Performed 8 guesses in 12 seconds, average tps: 0

Nje-pass-brute 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


  • Soldier of Fortran

References


See Also


Related NSE scripts to the nje-pass-brute.nse script:

Visit Nmap NSE Library for more scripts.

The nje-pass-brute.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 connect


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

68:	
69:	  connect = function( self )
70:	    -- the high timeout should take delays into consideration
71:	    local s, r, opts, _ = comm.tryssl(self.host, self.port, '', { timeout = 50000 } )
72:	    if ( not(s) ) then
73:	      stdnse.debug("Failed to connect")
74:	      return false, "Failed to connect to server"
75:	    end
76:	    self.socket = s
77:	    return true
78:	  end,

Failed to connect to server


Here is a relevant code snippet related to the "Failed to connect to server" error message:

69:	  connect = function( self )
70:	    -- the high timeout should take delays into consideration
71:	    local s, r, opts, _ = comm.tryssl(self.host, self.port, '', { timeout = 50000 } )
72:	    if ( not(s) ) then
73:	      stdnse.debug("Failed to connect")
74:	      return false, "Failed to connect to server"
75:	    end
76:	    self.socket = s
77:	    return true
78:	  end,
79:	

Failed to send OPEN


Here is a relevant code snippet related to the "Failed to send OPEN" error message:

87:	
88:	    -- Open the connection by sending OPEN NJE packet
89:	    local openNJE = openNJEfmt:format(drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
90:	                                drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['ohost'])) )
91:	    local status, err = self.socket:send( openNJE )
92:	    if not status then return false, brute.Error:new("Failed to send OPEN") end
93:	    local status, data = self.socket:receive_bytes(33)
94:	    if not status then return false, brute.Error:new("Failed to receive") end
95:	    -- Make sure the response is valid
96:	    if data:sub(-1) ~= "\0" then
97:	      err = brute.Error:new("Invalid OHOST (".. self.options['ohost'] ..") or RHOST (".. self.options['rhost'] ..")")

Failed to receive


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

89:	    local openNJE = openNJEfmt:format(drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
90:	                                drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['ohost'])) )
91:	    local status, err = self.socket:send( openNJE )
92:	    if not status then return false, brute.Error:new("Failed to send OPEN") end
93:	    local status, data = self.socket:receive_bytes(33)
94:	    if not status then return false, brute.Error:new("Failed to receive") end
95:	    -- Make sure the response is valid
96:	    if data:sub(-1) ~= "\0" then
97:	      err = brute.Error:new("Invalid OHOST (".. self.options['ohost'] ..") or RHOST (".. self.options['rhost'] ..")")
98:	      err:setAbort(true) -- no point continuing if these aren't correct
99:	      return false, err

Invalid OHOST (".. self.options['ohost'] ..") or RHOST (".. self.options['rhost'] ..")


Here is a relevant code snippet related to the "Invalid OHOST (".. self.options['ohost'] ..") or RHOST (".. self.options['rhost'] ..")" error message:

92:	    if not status then return false, brute.Error:new("Failed to send OPEN") end
93:	    local status, data = self.socket:receive_bytes(33)
94:	    if not status then return false, brute.Error:new("Failed to receive") end
95:	    -- Make sure the response is valid
96:	    if data:sub(-1) ~= "\0" then
97:	      err = brute.Error:new("Invalid OHOST (".. self.options['ohost'] ..") or RHOST (".. self.options['rhost'] ..")")
98:	      err:setAbort(true) -- no point continuing if these aren't correct
99:	      return false, err
100:	    end
101:	    -- Next send SOH & SEQ
102:	    status, err = self.socket:send( sohenq )

Failed to send SOH/ENQ


Here is a relevant code snippet related to the "Failed to send SOH/ENQ" error message:

98:	      err:setAbort(true) -- no point continuing if these aren't correct
99:	      return false, err
100:	    end
101:	    -- Next send SOH & SEQ
102:	    status, err = self.socket:send( sohenq )
103:	    if not status then return false, brute.Error:new("Failed to send SOH/ENQ") end
104:	    status, data = self.socket:receive_bytes(18)
105:	    if not status or data ~= dleack then return false, brute.Error:new("Failed to receive") end
106:	    -- Finally send an I record with the password
107:	    local njePKT = iRECfmt:format( drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
108:	                                   drda.StringUtil.toEBCDIC(("%-8s"):format(password:upper())):rep(2))

Failed to receive


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

100:	    end
101:	    -- Next send SOH & SEQ
102:	    status, err = self.socket:send( sohenq )
103:	    if not status then return false, brute.Error:new("Failed to send SOH/ENQ") end
104:	    status, data = self.socket:receive_bytes(18)
105:	    if not status or data ~= dleack then return false, brute.Error:new("Failed to receive") end
106:	    -- Finally send an I record with the password
107:	    local njePKT = iRECfmt:format( drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
108:	                                   drda.StringUtil.toEBCDIC(("%-8s"):format(password:upper())):rep(2))
109:	    status, err = self.socket:send( njePKT )
110:	    if not status then return false, brute.Error:new("Failed to send NJE Packet") end

Failed to send NJE Packet


Here is a relevant code snippet related to the "Failed to send NJE Packet" error message:

105:	    if not status or data ~= dleack then return false, brute.Error:new("Failed to receive") end
106:	    -- Finally send an I record with the password
107:	    local njePKT = iRECfmt:format( drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
108:	                                   drda.StringUtil.toEBCDIC(("%-8s"):format(password:upper())):rep(2))
109:	    status, err = self.socket:send( njePKT )
110:	    if not status then return false, brute.Error:new("Failed to send NJE Packet") end
111:	    status, data = self.socket:receive_bytes(19)
112:	    if not status then return false, "Failed to receive" end
113:	    -- When we send an 'I' record, if the password is invalid it will reply with a 'B' record
114:	    -- B in EBCDIC is 0xC2
115:	    if data:sub(19,19) ~= "\xc2" then

Failed to receive


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

107:	    local njePKT = iRECfmt:format( drda.StringUtil.toEBCDIC(("%-8s"):format(self.options['rhost'])),
108:	                                   drda.StringUtil.toEBCDIC(("%-8s"):format(password:upper())):rep(2))
109:	    status, err = self.socket:send( njePKT )
110:	    if not status then return false, brute.Error:new("Failed to send NJE Packet") end
111:	    status, data = self.socket:receive_bytes(19)
112:	    if not status then return false, "Failed to receive" end
113:	    -- When we send an 'I' record, if the password is invalid it will reply with a 'B' record
114:	    -- B in EBCDIC is 0xC2
115:	    if data:sub(19,19) ~= "\xc2" then
116:	      stdnse.verbose(2,"Valid NJE Password: %s", password)
117:	      return true, creds.Account:new("Password", password, creds.State.VALID)

Invalid Password


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

114:	    -- B in EBCDIC is 0xC2
115:	    if data:sub(19,19) ~= "\xc2" then
116:	      stdnse.verbose(2,"Valid NJE Password: %s", password)
117:	      return true, creds.Account:new("Password", password, creds.State.VALID)
118:	    end
119:	    return false, brute.Error:new( "Invalid Password" )
120:	  end,
121:	}
122:	
123:	-- Checks string to see if it follows node naming limitations
124:	local valid_pass = function(x)

No OHOST or RHOST set. Use --script-args nje-node-brute.rhost="<rhost>",nje-node-brute.ohost="<ohost>"


Here is a relevant code snippet related to the "No OHOST or RHOST set. Use --script-args nje-node-brute.rhost="<rhost>",nje-node-brute.ohost="<ohost>"" error message:

129:	action = function( host, port )
130:	  local r_host = stdnse.get_script_args('nje-pass-brute.rhost') or nil
131:	  local o_host = stdnse.get_script_args('nje-pass-brute.ohost') or nil
132:	  local sleep = stdnse.get_script_args('nje-pass-brute.sleep') or 1
133:	  if not o_host or not r_host then
134:	    return false, "No OHOST or RHOST set. Use --script-args nje-node-brute.rhost="<rhost>",nje-node-brute.ohost="<ohost>""
135:	  end
136:	  stdnse.verbose(2, "Using RHOST / OHOST: %s / %s", r_host:upper(), o_host:upper())
137:	  local options = { rhost = r_host:upper(), ohost = o_host:upper(), sleep = sleep }
138:	  local engine = brute.Engine:new(Driver, host, port, options)
139:	  local passwords = unpwdb.filter_iterator(brute.passwords_iterator(),valid_pass)

Version


This page has been created based on Nmap version 7.92.

Go back to menu.