Library unpwdb
Username/password database library.
The usernames and passwords functions return
multiple values for use with exception handling via
nmap.new_try. The first value is the Boolean success
indicator, the second value is the closure.
The closures can take an argument of "reset" to rewind the list
to the beginning.
To avoid taking a long time against slow services, the closures will
stop returning values (start returning nil) after a
certain time. The time depends on the timing template level, and is
-T3or less: 10 minutes-T4: 5 minutes-T5: 3 minutes
userdb or passdb
script arguments. You can control the time limit directly with the
unpwdb.timelimit script argument. Use
unpwdb.timelimit=0 to disable the time limit.
You can select your own username and/or password database to read from with
the script arguments userdb and passdb,
respectively. Comments are allowed in these files, prefixed with
"#!comment:". Comments cannot be on the same line as a
username or password because this leaves too much ambiguity, e.g. does the
password in "mypass #!comment: blah" contain a space, two
spaces, or do they just separate the password from the comment?
Author:
| Kris Katterjohn 06/2008 |
Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html
Source: http://nmap.org/svn/nselib/unpwdb.lua
Script Arguments
unpwdb.passlimit
The maximum number of passwords
passwords will return (default unlimited).
userdb
The filename of an alternate username database.
unpwdb.userlimit
The maximum number of usernames
usernames 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.
passdb
The filename of an alternate password database.
Example Usage
require("unpwdb") local usernames, passwords local try = nmap.new_try() usernames = try(unpwdb.usernames()) passwords = try(unpwdb.passwords()) for password in passwords do for username in usernames do -- Do something with username and password. end usernames("reset") endnmap --script-args userdb=/tmp/user.lst nmap --script-args unpwdb.timelimit=10m
Functions
| limited_iterator (iterator, time_limit, count_limit) |
Wraps time and count limits around an iterator. When either limit expires,
starts returning |
| passwords (time_limit, count_limit) |
Returns a function closure which returns a new password with every call
until the password list is exhausted or either limit expires (in which cases
it returns |
| passwords_raw () |
Returns a function closure which returns a new password with every call
until the password list is exhausted (in which case it returns
|
| timelimit () |
Returns the suggested number of seconds to attempt a brute force attack,
based on the |
| usernames (time_limit, count_limit) |
Returns a function closure which returns a new password with every call
until the username list is exhausted or either limit expires (in which cases
it returns |
| usernames_raw () |
Returns a function closure which returns a new username with every call
until the username list is exhausted (in which case it returns
|
Functions
- limited_iterator (iterator, time_limit, count_limit)
-
Wraps time and count limits around an iterator. When either limit expires, starts returning
nil. Calling the iterator with an argument of "reset" resets the count.Parameters
- iterator:
-
time_limit:
Time limit in seconds. Use 0 or
nilfor no limit. -
count_limit:
Count limit in seconds. Use 0 or
nilfor no limit.
Return values:
- boolean Status.
- function The wrapped iterator.
- passwords (time_limit, count_limit)
-
Returns a function closure which returns a new password with every call until the password list is exhausted or either limit expires (in which cases it returns
nil).Parameters
- time_limit: Time limit in seconds. Use 0 for no limit.
- count_limit: Count limit in seconds. Use 0 for no limit.
Return values:
- boolean Status.
- function The passwords iterator.
- passwords_raw ()
-
Returns a function closure which returns a new password with every call until the password list is exhausted (in which case it returns
nil).Return values:
- boolean Status.
- function The passwords iterator.
- timelimit ()
-
Returns the suggested number of seconds to attempt a brute force attack, based on the
unpwdb.timelimitscript argument, Nmap's timing values (-T4etc.) and whether or not a user-defined list is used.You can use the script argument
notimelimitto make this function returnnil, which means the brute-force should run until the list is empty. Ifnotimelimitis not used, be sure to still check fornilreturn values on the above two functions in case you finish before the time limit is up. - usernames (time_limit, count_limit)
-
Returns a function closure which returns a new password with every call until the username list is exhausted or either limit expires (in which cases it returns
nil).Parameters
- time_limit: Time limit in seconds. Use 0 for no limit.
- count_limit: Count limit in seconds. Use 0 for no limit.
Return values:
- boolean Status.
- function The usernames iterator.
- usernames_raw ()
-
Returns a function closure which returns a new username with every call until the username list is exhausted (in which case it returns
nil).Return values:
- boolean Status.
- function The usernames iterator.




