Nmap sip-enum-users NSE Script
This page contains detailed information about how to use the sip-enum-users NSE script. For list of all NSE scripts, visit the Nmap NSE Library.
Select: |
---|
Script Overview
Script source code: https://github.com/nmap/nmap/tree/master/scripts/sip-enum-users.nse
Script categories: auth, intrusive
Target service / protocol: sip, tcp, udp
Target network port(s): 5060
List of CVEs: -
Script Description
The sip-enum-users.nse script enumerates a SIP server's valid extensions (users).
The script works by sending REGISTER SIP requests to the server with the specified extension and checking for the response status code in order to know if an extension is valid. If a response status code is 401 or 407, it means that the extension is valid and requires authentication. If the response status code is 200, it means that the extension exists and doesn't require any authentication while a 403 response status code means that extension exists but access is forbidden. To skip false positives, the script begins by sending a REGISTER request for a random extension and checking for response status code.
Sip-enum-users NSE Script Arguments
This is a full list of arguments supported by the sip-enum-users.nse script:
extExtension to send register request to.
sessSession to use.
sip-enum-users.maxext
Extension value to end enumeration at. Defaults to 999
.
Extension value to start enumeration from. Defaults to 0
.
Number of digits to pad zeroes up to. Defaults to 0
. No padding if this is set to zero.
If set, will also enumerate users from userslist
file.
Path to list of users. Defaults to nselib/data/usernames.lst
.
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
passdbThe filename of an alternate password database. Default: nselib/data/passwords.lst
unpwdb.passlimit
The maximum number of passwords passwords
will return (default unlimited).
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.
The maximum number of usernames usernames
will return (default unlimited).
The filename of an alternate username database. Default: nselib/data/usernames.lst
brute.credfileA file containing username and password pairs delimited by '/'
brute.delayThe number of seconds to wait between guesses (default: 0)
brute.emptypassGuess an empty password for each user (default: false)
brute.firstonlyStop guessing after first password is found (default: false)
brute.guessesThe number of guesses to perform against each account. (default: 0 (unlimited)). The argument can be used to prevent account lockouts.
brute.modeCan 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.
Iterate over passwords only for services that provide only a password for authentication. (default: false)
brute.retriesThe number of times to retry if recoverable failures occur. (default: 2)
brute.startThe number of threads the engine will start with. (default: 5).
brute.threadsThe number of initial worker threads, the number of active threads will be automatically adjusted.
brute.uniqueMake sure that each password is only guessed once (default: true)
brute.useraspassGuess 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
sip.timeoutSpecifies the session (socket) timeout in seconds
- - -
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=sip-enum-users --script-args ext=value,sess=value <target>
Sip-enum-users NSE Script Example Usage
Here's an example of how to use the sip-enum-users.nse script:
nmap --script=sip-enum-users -sU -p 5060 <targets>
nmap --script=sip-enum-users -sU -p 5060 <targets> --script-args
'sip-enum-users.padding=4, sip-enum-users.minext=1000,
sip-enum-users.maxext=9999'
Sip-enum-users NSE Script Example Output
Here's a sample output from the sip-enum-users.nse script:
5060/udp open sip
| sip-enum-users:
| Accounts
| 101: Auth required
| 120: No auth
| Statistics
|_ Performed 1000 guesses in 50 seconds, average tps: 20
Sip-enum-users 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
- Hani Benhabiles
References
- https://nmap.org/nsedoc/scripts/sip-enum-users.html
- https://github.com/nmap/nmap/tree/master/scripts/sip-enum-users.nse
See Also
Related NSE scripts to the sip-enum-users.nse script:
Visit Nmap NSE Library for more scripts.
The sip-enum-users.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 find %s
Here is a relevant code snippet related to the "Couldn't find %s" error message:
117: -- @return status false if error.
118: -- @return string current line.
119: local useriterator = function(list)
120: local f = nmap.fetchfile(list) or list
121: if not f then
122: return false, ("Couldn't find %s"):format(list)
123: end
124: f = io.open(f)
125: if ( not(f) ) then
126: return false, ("Failed to open %s"):format(list)
127: end
Failed to open %s
Here is a relevant code snippet related to the "Failed to open %s" error message:
121: if not f then
122: return false, ("Couldn't find %s"):format(list)
123: end
124: f = io.open(f)
125: if ( not(f) ) then
126: return false, ("Failed to open %s"):format(list)
127: end
128: return function()
129: for line in f:lines() do
130: return line
131: end
Failed to connect to the SIP server.
Here is a relevant code snippet related to the "Failed to connect to the SIP server." error message:
142: randext = math.random(1234567,987654321)
143:
144: session = sip.Session:new(host, port)
145: status = session:connect()
146: if not status then
147: return false, "Failed to connect to the SIP server."
148: end
149:
150: status, response = registerext(session, randext)
151: if not status then
152: return false, "No response from the SIP server."
No response from the SIP server.
Here is a relevant code snippet related to the "No response from the SIP server." error message:
147: return false, "Failed to connect to the SIP server."
148: end
149:
150: status, response = registerext(session, randext)
151: if not status then
152: return false, "No response from the SIP server."
153: end
154: if response:getErrorCode() ~= 404 then
155: return false, "Server not returning 404 for random extension."
156: end
157: return true
Server not returning 404 for random extension.
Here is a relevant code snippet related to the "Server not returning 404 for random extension." error message:
150: status, response = registerext(session, randext)
151: if not status then
152: return false, "No response from the SIP server."
153: end
154: if response:getErrorCode() ~= 404 then
155: return false, "Server not returning 404 for random extension."
156: end
157: return true
158:
159: end
160:
Couldn't connect to host
Here is a relevant code snippet related to the "Couldn't connect to host" error message:
171:
172: connect = function( self )
173: self.session = sip.Session:new(self.host, self.port)
174: local status = self.session:connect()
175: if ( not(status) ) then
176: return false, brute.Error:new( "Couldn't connect to host" )
177: end
178: return true
179: end,
180:
181: login = function( self, username, password)
Not found
Here is a relevant code snippet related to the "Not found" error message:
202: -- but access is forbidden.
203:
204: elseif responsecode == sip.Error.FORBIDDEN then
205: return true, creds.Account:new(password, " Forbidden", '')
206: end
207: return false,brute.Error:new( "Not found" )
208: else
209: return false,brute.Error:new( "No response" )
210: end
211: end,
212:
No response
Here is a relevant code snippet related to the "No response" error message:
204: elseif responsecode == sip.Error.FORBIDDEN then
205: return true, creds.Account:new(password, " Forbidden", '')
206: end
207: return false,brute.Error:new( "Not found" )
208: else
209: return false,brute.Error:new( "No response" )
210: end
211: end,
212:
213: disconnect = function(self)
214: self.session:close()
maxext should be greater or equal than minext.
Here is a relevant code snippet related to the "maxext should be greater or equal than minext." error message:
229: local usersfile = stdnse.get_script_args(SCRIPT_NAME .. ".userslist")
230: or "nselib/data/usernames.lst"
231:
232: -- min extension should be less than max extension.
233: if minext > maxext then
234: return fail("maxext should be greater or equal than minext.")
235: end
236: -- If not set to zero, number of digits to pad up to should have less or
237: -- equal the number of digits of max extension.
238: if padding ~= 0 and #tostring(maxext) > padding then
239: return fail("padding should be greater or equal to number of digits of maxext.")
padding should be greater or equal to number of digits of maxext.
Here is a relevant code snippet related to the "padding should be greater or equal to number of digits of maxext." error message:
234: return fail("maxext should be greater or equal than minext.")
235: end
236: -- If not set to zero, number of digits to pad up to should have less or
237: -- equal the number of digits of max extension.
238: if padding ~= 0 and #tostring(maxext) > padding then
239: return fail("padding should be greater or equal to number of digits of maxext.")
240: end
241:
242: -- We test for false positives by sending a request for a random extension
243: -- and checking if it did return a 404.
244: status, err = test404(host, port)
Version
This page has been created based on Nmap version 7.92.
Go back to menu.