Nmap pcanywhere-brute NSE Script


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

Script Description


The pcanywhere-brute.nse script performs brute force password auditing against the pcAnywhere remote access protocol.

Due to certain limitations of the protocol, bruteforcing is limited to single thread at a time. After a valid login pair is guessed the script waits some time until server becomes available again.

Pcanywhere-brute NSE Script Arguments


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

pcanywhere-brute.timeout

Socket timeout for connecting to PCAnywhere (default 10s)

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=pcanywhere-brute --script-args pcanywhere-brute.timeout=value,creds.global=value <target>

Pcanywhere-brute NSE Script Example Usage


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

nmap --script=pcanywhere-brute <target>

Pcanywhere-brute NSE Script Example Output


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

5631/tcp open  pcanywheredata syn-ack
| pcanywhere-brute:
|   Accounts
|     administrator:administrator - Valid credentials
|   Statistics
|_    Performed 2 guesses in 55 seconds, average tps: 0

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


  • Aleksandar Nikolic

References


See Also


Visit Nmap NSE Library for more scripts.

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

Couldn't connect to host:


Here is a relevant code snippet related to the "Couldn't connect to host: " error message:

78:	    -- variable "retry" signifies if we need to wait or this is just not pcAnywhere server
79:	    while not status do
80:	      status, err = self.socket:connect(self.host, self.port)
81:	      self.socket:set_timeout(arg_timeout)
82:	      if(not(status)) then
83:	        return false, brute.Error:new( "Couldn't connect to host: " .. err )
84:	      end
85:	      status, err = self.socket:send(stdnse.fromhex("00000000")) --initial hello
86:	      status, response = self.socket:receive_bytes(0)
87:	      if not status and not retry then
88:	        break

Probably not pcAnywhere.


Here is a relevant code snippet related to the "Probably not pcAnywhere." error message:

91:	      stdnse.sleep(2) -- needs relatively big timeout between retries
92:	    end
93:	    if not status or string.find(response,"Please press <Enter>") == nil then
94:	      --probably not pcanywhere
95:	      stdnse.debug1("not pcAnywhere")
96:	      return false, brute.Error:new( "Probably not pcAnywhere." )
97:	    end
98:	    retry = false
99:	    status, err = self.socket:send(stdnse.fromhex("6f06ff")) -- downgrade into legacy mode
100:	    status, response = self.socket:receive_bytes(0)
101:	

handshake failed


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

103:	    status, response = self.socket:receive_bytes(0)
104:	
105:	    status, err = self.socket:send(stdnse.fromhex("6f620102000000")) -- auth capabilities II
106:	    status, response = self.socket:receive_bytes(0)
107:	    if not status or (string.find(response,"Enter user name") == nil and string.find(response,"Enter login name") == nil) then
108:	      stdnse.debug1("handshake failed")
109:	      return false, brute.Error:new( "Handshake failed." )
110:	    end
111:	    return true
112:	  end,
113:	

Handshake failed.


Here is a relevant code snippet related to the "Handshake failed." error message:

104:	
105:	    status, err = self.socket:send(stdnse.fromhex("6f620102000000")) -- auth capabilities II
106:	    status, response = self.socket:receive_bytes(0)
107:	    if not status or (string.find(response,"Enter user name") == nil and string.find(response,"Enter login name") == nil) then
108:	      stdnse.debug1("handshake failed")
109:	      return false, brute.Error:new( "Handshake failed." )
110:	    end
111:	    return true
112:	  end,
113:	
114:	  login = function (self, user, pass)

Sending username failed


Here is a relevant code snippet related to the "Sending username failed" error message:

119:	    -- send username and password
120:	    -- both are prefixed with 0x06, size and are encrypted
121:	    status, err = self.socket:send("\x06" .. string.pack("s1", encrypt(user)) ) -- send username
122:	    status, response = self.socket:receive_bytes(0)
123:	    if not status or string.find(response,"Enter password") == nil then
124:	      stdnse.debug1("Sending username failed")
125:	      return false, brute.Error:new( "Sending username failed." )
126:	    end
127:	    -- send password
128:	    status, err = self.socket:send("\x06" .. string.pack("s1", encrypt(pass)) ) -- send password
129:	    status, response = self.socket:receive_bytes(0)

Sending username failed.


Here is a relevant code snippet related to the "Sending username failed." error message:

120:	    -- both are prefixed with 0x06, size and are encrypted
121:	    status, err = self.socket:send("\x06" .. string.pack("s1", encrypt(user)) ) -- send username
122:	    status, response = self.socket:receive_bytes(0)
123:	    if not status or string.find(response,"Enter password") == nil then
124:	      stdnse.debug1("Sending username failed")
125:	      return false, brute.Error:new( "Sending username failed." )
126:	    end
127:	    -- send password
128:	    status, err = self.socket:send("\x06" .. string.pack("s1", encrypt(pass)) ) -- send password
129:	    status, response = self.socket:receive_bytes(0)
130:	    if not status or string.find(response,"Login unsuccessful") or string.find(response,"Invalid login.")then

Incorrect username or password.


Here is a relevant code snippet related to the "Incorrect username or password." error message:

127:	    -- send password
128:	    status, err = self.socket:send("\x06" .. string.pack("s1", encrypt(pass)) ) -- send password
129:	    status, response = self.socket:receive_bytes(0)
130:	    if not status or string.find(response,"Login unsuccessful") or string.find(response,"Invalid login.")then
131:	      stdnse.debug1("Incorrect username or password")
132:	      return false, brute.Error:new( "Incorrect username or password." )
133:	    end
134:	
135:	    if status then
136:	      retry = true -- now the server is in "locked mode", we need to retry next connection a few times
137:	      return true, creds.Account:new( user, pass, creds.State.VALID)

Incorrect password


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

134:	
135:	    if status then
136:	      retry = true -- now the server is in "locked mode", we need to retry next connection a few times
137:	      return true, creds.Account:new( user, pass, creds.State.VALID)
138:	    end
139:	    return false,brute.Error:new( "Incorrect password" )
140:	  end,
141:	
142:	  disconnect = function( self )
143:	    self.socket:close()
144:	    return true

Version


This page has been created based on Nmap version 7.92.

Go back to menu.