Nmap smtp-enum-users NSE Script
This page contains detailed information about how to use the smtp-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/smtp-enum-users.nse
Script categories: auth, external, intrusive
Target service / protocol: smtp, smtps, submission
Target network port(s): 25, 465, 587
List of CVEs: -
Script Description
The smtp-enum-users.nse script attempts to enumerate the users on a SMTP server by issuing the VRFY, EXPN or RCPT TO commands. The goal of this script is to discover all the user accounts in the remote system.
The script will output the list of user names that were found. The script will stop querying the SMTP server if authentication is enforced. If an error occurs while testing the target host, the error will be printed with the list of any combinations that were found prior to the error.
The user can specify which methods to use and in which order. The script will ignore repeated methods. If not specified the script will use the RCPT first, then VRFY and EXPN. An example of how to specify the methods to use and the order is the following:
smtp-enum-users.methods={EXPN,RCPT,VRFY}
Smtp-enum-users NSE Script Arguments
This is a full list of arguments supported by the smtp-enum-users.nse script:
smtp.domainOr smtp-enum-users.domain Define the domain to be used in the SMTP commands
smtp-enum-users.methodsDefine the methods and order to be used by the script (EXPN, VRFY, RCPT)
smbdomainThe domain to log in with. If you aren't in a domain environment, then anything will (should?) be accepted by the server.
smbhashA password hash to use when logging in. This is given as a single hex string (32 characters) or a pair of hex strings (both 32 characters, optionally separated by a single character). These hashes are the LanMan or NTLM hash of the user's password, and are stored on disk or in memory. They can be retrieved from memory using the fgdump or pwdump tools.
smbnoguestUse to disable usage of the 'guest' account.
smbpasswordThe password to connect with. Be cautious with this, since some servers will lock accounts if the incorrect password is given. Although it's rare that the Administrator account can be locked out, in the off chance that it can, you could get yourself in trouble. To use a blank password, leave this parameter off altogether.
smbtypeThe type of SMB authentication to use. These are the possible options:
v1
: Sends LMv1 and NTLMv1.LMv1
: Sends LMv1 only.NTLMv1
: Sends NTLMv1 only (default).v2
: Sends LMv2 and NTLMv2.LMv2
: Sends LMv2 only.NTLMv2
: Doesn't exist; the protocol doesn't support NTLMv2 alone. The default,NTLMv1
, is a pretty decent compromise between security and compatibility. If you are paranoid, you might want to usev2
orlmv2
for this. (Actually, if you're paranoid, you should be avoiding this protocol altogether!). If you're using an extremely old system, you might need to set this tov1
orlm
, which are less secure but more compatible. For information, seesmbauth.lua
.
The SMB username to log in with. The forms "DOMAIN\username" and "username@DOMAIN" are not understood. To set a domain, use the smbdomain
argument.
The 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
- - -
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=smtp-enum-users --script-args smtp.domain=value,smtp-enum-users.methods=value <target>
Smtp-enum-users NSE Script Example Usage
Here's an example of how to use the smtp-enum-users.nse script:
nmap --script smtp-enum-users.nse [--script-args smtp-enum-users.methods={EXPN,...},...] -p 25,465,587 <host>
Smtp-enum-users NSE Script Example Output
Here's a sample output from the smtp-enum-users.nse script:
Host script results:
| smtp-enum-users:
|_ RCPT, root
Smtp-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
- Duarte Silva [email protected]>
References
- https://nmap.org/nsedoc/scripts/smtp-enum-users.html
- https://github.com/nmap/nmap/tree/master/scripts/smtp-enum-users.nse
- http://lua-users.org/wiki/TableUtils
See Also
Related NSE scripts to the smtp-enum-users.nse script:
- smtp-brute.nse
- smtp-commands.nse
- smtp-ntlm-info.nse
- smtp-open-relay.nse
- smtp-strangeport.nse
- smtp-vuln-cve2010-4344.nse
- smtp-vuln-cve2011-1720.nse
- smtp-vuln-cve2011-1764.nse
Visit Nmap NSE Library for more scripts.
The smtp-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.
Failed to issue %s %s command (%s)n
Here is a relevant code snippet related to the "Failed to issue %s %s command (%s)n" error message:
150:
151: -- If this command fails to be sent, then something
152: -- went wrong with the connection.
153: if not status then
154: return STATUS_CODES.ERROR,
155: string.format("Failed to issue %s %s command (%s)\n",
156: command, combination, response)
157: end
158:
159: if string.match(response, "^530") then
160: -- If the command failed, check if authentication is
Failed to issue MAIL FROM:<usertest@%s> command (%s)
Here is a relevant code snippet related to the "Failed to issue MAIL FROM:<usertest@%s> command (%s)" error message:
222:
223: if not status then
224: -- If this command fails to be sent, then something went wrong
225: -- with the connection.
226: return STATUS_CODES.ERROR,
227: string.format("Failed to issue MAIL FROM:<usertest@%s> command (%s)",
228: domain, response)
229: elseif string.match(response, "^530") then
230: -- If the command failed, check if authentication is needed
231: -- because all the other attempts will fail.
232: return STATUS_CODES.ERROR,
Failed to issue RCPT TO:<%s@%s> command (%s)
Here is a relevant code snippet related to the "Failed to issue RCPT TO:<%s@%s> command (%s)" error message:
241: status, response = smtp.query(socket, "RCPT",
242: string.format("TO:<%s@%s>", username, domain))
243:
244: if not status then
245: return STATUS_CODES.ERROR,
246: string.format("Failed to issue RCPT TO:<%s@%s> command (%s)",
247: username, domain, response)
248: elseif string.match(response, "^550") then
249: -- 550 User Unknown
250: return STATUS_CODES.UNKNOWN
251: elseif string.match(response, "^553") then
Failed to read the user names database
Here is a relevant code snippet related to the "Failed to read the user names database" error message:
277: function go(host, port)
278: -- Get the current usernames list from the file.
279: local status, nextuser = unpwdb.usernames()
280:
281: if not status then
282: return false, "Failed to read the user names database"
283: end
284:
285: local options = {
286: timeout = 10000,
287: recv_before = true,
Invalid method found, %s
Here is a relevant code snippet related to the "Invalid method found, %s" error message:
292:
293: local methods
294: status, methods = get_method()
295:
296: if not status then
297: return false, string.format("Invalid method found, %s", methods)
298: end
299:
300: local socket, response = smtp.connect(host, port, options)
301:
302: -- Failed connection attempt.
Couldn't establish connection on port %i
Here is a relevant code snippet related to the "Couldn't establish connection on port %i" error message:
299:
300: local socket, response = smtp.connect(host, port, options)
301:
302: -- Failed connection attempt.
303: if not socket then
304: return false, string.format("Couldn't establish connection on port %i",
305: port.number)
306: end
307:
308: status, response = smtp.ehlo(socket, domain)
309: if not status then
Couldn't perform user enumeration, authentication needed
Here is a relevant code snippet related to the "Couldn't perform user enumeration, authentication needed" error message:
347: elseif status == STATUS_CODES.ERROR then
348: -- An error occurred with the connection.
349: return failure(response)
350: elseif status == STATUS_CODES.AUTHENTICATION then
351: smtp.quit(socket)
352: return false, "Couldn't perform user enumeration, authentication needed"
353: elseif status == STATUS_CODES.INVALID then
354: table.insert(result,
355: string.format("Method %s returned a unhandled status code.",
356: method))
357: break
Version
This page has been created based on Nmap version 7.92.
Go back to menu.