Nmap telnet-brute NSE Script


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

Script Description


The telnet-brute.nse script performs brute-force password auditing against telnet servers.

Telnet-brute NSE Script Arguments


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

telnet-brute.autosize

Whether to automatically reduce the thread count based on the behavior of the target (default: "true")

telnet-brute.timeout

Connection time-out timespec (default: "5s")

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=telnet-brute --script-args telnet-brute.autosize=value,telnet-brute.timeout=value <target>

Telnet-brute NSE Script Example Usage


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

nmap -p 23 --script telnet-brute --script-args userdb=myusers.lst,passdb=mypwds.lst,telnet-brute.timeout=8s <target>

Telnet-brute NSE Script Example Output


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

23/tcp open  telnet
| telnet-brute:
|   Accounts
|     wkurtz:colonel
|   Statistics
|_    Performed 15 guesses in 19 seconds, average tps: 0

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


  • nnposter

References


See Also


Related NSE scripts to the telnet-brute.nse script:

Visit Nmap NSE Library for more scripts.

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

Unable to allocate connection


Here is a relevant code snippet related to the "Unable to allocate connection" error message:

345:	-- @return Connection if the operation was successful; error code otherwise
346:	Target.methods.attach = function (self)
347:	  local worker = self.workers[coroutine.running()]
348:	  local conn = worker.conn
349:	               or Connection.new(self.host, self.port, self.proto)
350:	  if not conn then return false, "Unable to allocate connection" end
351:	  worker.conn = conn
352:	
353:	  if conn.error then conn:close() end
354:	  if not conn.isopen then
355:	    local status, err = conn:connect()

Invalid username encountered


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

538:	    err:setAbort(true)
539:	    return false, err
540:	  end
541:	
542:	  local username_error = function ()
543:	    local msg = "Invalid username encountered"
544:	    debug(detail_debug, msg .. loc)
545:	    local err = brute.Error:new(msg)
546:	    err:setInvalidAccount(username)
547:	    return false, err
548:	  end

Login failed


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

546:	    err:setInvalidAccount(username)
547:	    return false, err
548:	  end
549:	
550:	  local login_error = function ()
551:	    local msg = "Login failed"
552:	    debug(detail_debug, msg .. loc)
553:	    return false, brute.Error:new(msg)
554:	  end
555:	
556:	  local login_success = function ()

Service unreachable


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

568:	  debug(detail_debug, "Login attempt %s:%s%s", username, password, loc)
569:	
570:	  if conn == Connection.GHOST then
571:	    -- reached when auto-sizing is enabled and all worker threads
572:	    -- failed
573:	    return connection_error("Service unreachable")
574:	  end
575:	
576:	  -- username has not yet been sent
577:	  while not sent_username do
578:	    local line = conn:get_line()

Login prompt not reached


Here is a relevant code snippet related to the "Login prompt not reached" error message:

576:	  -- username has not yet been sent
577:	  while not sent_username do
578:	    local line = conn:get_line()
579:	    if not line then
580:	      -- stopped receiving data
581:	      return connection_error("Login prompt not reached")
582:	    end
583:	
584:	    if is_username_prompt(line) then
585:	      -- being prompted for a username
586:	      conn:discard_line()

Password prompt not reached


Here is a relevant code snippet related to the "Password prompt not reached" error message:

607:	  -- username has been already sent
608:	  while not sent_password do
609:	    local line = conn:get_line()
610:	    if not line then
611:	      -- remote host disconnected
612:	      return connection_error("Password prompt not reached")
613:	    end
614:	
615:	    if is_login_success(line) then
616:	      -- successful login without a password
617:	      conn:close()

Login not completed


Here is a relevant code snippet related to the "Login not completed" error message:

645:	  -- password has been already sent
646:	  while true do
647:	    local line = conn:get_line()
648:	    if not line then
649:	      -- remote host disconnected
650:	      return connection_error("Login not completed")
651:	    end
652:	
653:	    if is_login_success(line) then
654:	      -- successful login
655:	      conn:close()

Invalid timeout value:


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

677:	
678:	
679:	action = function (host, port)
680:	  local ts, tserror = stdnse.parse_timespec(arg_timeout)
681:	  if not ts then
682:	    return stdnse.format_output(false, "Invalid timeout value: " .. tserror)
683:	  end
684:	  telnet_timeout = 1000 * ts
685:	  telnet_autosize = arg_autosize:lower() == "true"
686:	
687:	  local target = Target.new(host, port)

Unable to connect to the target


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

684:	  telnet_timeout = 1000 * ts
685:	  telnet_autosize = arg_autosize:lower() == "true"
686:	
687:	  local target = Target.new(host, port)
688:	  if not target then
689:	    return stdnse.format_output(false, "Unable to connect to the target")
690:	  end
691:	
692:	  local engine = brute.Engine:new(Driver, host, port, target)
693:	  engine.options.script_name = SCRIPT_NAME
694:	  target.passonly = engine.options.passonly

Version


This page has been created based on Nmap version 7.92.

Go back to menu.