脚本所属分类: auth, intrusive
Attempts to enumerate the users on a remote Windows system, with as much
information as possible, through two different techniques (both over MSRPC,
which uses port 445 or 139; see
smb.lua). The goal of this script
is to discover all user accounts that exist on a remote system. This can be
helpful for administration, by seeing who has an account on a server, or for
penetration testing or network footprinting, by determining which accounts
exist on a system.
A penetration tester who is examining servers may wish to determine the purpose of a server. By getting a list of who has access to it, the tester might get a better idea (if financial people have accounts, it probably relates to financial information). Additionally, knowing which accounts exist on a system (or on multiple systems) allows the pen-tester to build a dictionary of possible usernames for bruteforces, such as a SMB bruteforce or a Telnet bruteforce. These accounts may be helpful for other purposes, such as using the accounts in Web applications on this or other servers.
From a pen-testers perspective, retrieving the list of users on any given server creates endless possibilities.
Users are enumerated in two different ways: using SAMR enumeration or LSA bruteforcing. By default, both are used, but they have specific advantages and disadvantages. Using both is a great default, but in certain circumstances it may be best to give preference to one.
Advantages of using SAMR enumeration:
Advantages of using LSA bruteforcing:
SAMR enumeration is done with the
If this succeeds, it will return a detailed list of users, along with descriptions,
types, and full names. This can be done anonymously against Windows 2000, and
with a user-level account on other Windows versions (but not with a guest-level account).
To perform this test, the following functions are used:
Bind: bind to the SAMR service.
Connect4: get a connect_handle.
EnumDomains: get a list of the domains.
QueryDomain: get the sid for the domain.
OpenDomain: get a handle for each domain.
QueryDisplayInfo: get the list of users in the domain.
Close: Close the domain handle.
Close: Close the connect handle.
Regardless of whether this succeeds, a second technique is used to pull user accounts, called LSA bruteforcing. LSA bruteforcing can be done anonymously against Windows 2000, and requires a guest account or better on other systems. It has the advantage of running with less permission, and will also find more account types (i.e., groups, aliases, etc.). The disadvantages is that it returns less information, and that, because it's a brute-force guess, it's possible to miss accounts. It's also extremely noisy.
This isn't a brute-force technique in the common sense, however: it's a brute-forcing of users' RIDs. A user's RID is a value (generally 500, 501, or 1000+) that uniquely identifies a user on a domain or system. An LSA function is exposed which lets us convert the RID (say, 1000) to the username (say, "Ron"). So, the technique will essentially try converting 1000 to a name, then 1001, 1002, etc., until we think we're done.
To do this, the script breaks users into groups of RIDs based on the
constant. All members of this group are checked simultaneously, and the responses recorded.
When a series of empty groups are found (
LSA_MINEMPTY groups, specifically),
the scan ends. As long as you are getting a few groups with active accounts, the scan will
Before attempting this conversion, the SID of the server has to be determined. The SID is determined by doing the reverse operation; that is, by converting a name into its RID. The name is determined by looking up any name present on the system. We try:
In theory, the computer name should be sufficient for this to always work, and it has so far has in my tests, but I included the rest of the names for good measure. It doesn't hurt to add more.
The names and details from both of these techniques are merged and displayed. If the output is verbose, then extra details are shown. The output is ordered alphabetically.
Credit goes out to the
The code I wrote for this is largely based on the techniques used by them.
If set, script will only query a list of users using a SAMR lookup. This is much quieter than LSA lookups, so enable this if you want stealth. Generally, however, you'll get better results by using the default options.
If set, script will only enumerate using an LSA bruteforce (requires less access than samr). Only set if you know what you're doing, you'll get better results by using the default options.
nmap --script smb-enum-users.nse -p445 <host> sudo nmap -sU -sS --script smb-enum-users.nse -p U:137,T:139 <host>
Host script results: | smb-enum-users: |_ |_ Domain: RON-WIN2K-TEST; Users: Administrator, Guest, IUSR_RON-WIN2K-TEST, IWAM_RON-WIN2K-TEST, test1234, TsInternetUser Host script results: | smb-enum-users: | | RON-WIN2K-TEST\Administrator (RID: 500) | | | Description: Built-in account for administering the computer/domain | | |_ Flags: Password does not expire, Normal user account | | RON-WIN2K-TEST\Guest (RID: 501) | | | Description: Built-in account for guest access to the computer/domain | | |_ Flags: Password not required, Password does not expire, Normal user account | | RON-WIN2K-TEST\IUSR_RON-WIN2K-TEST (RID: 1001) | | | Full name: Internet Guest Account | | | Description: Built-in account for anonymous access to Internet Information Services | | |_ Flags: Password not required, Password does not expire, Normal user account | | RON-WIN2K-TEST\IWAM_RON-WIN2K-TEST (RID: 1002) | | | Full name: Launch IIS Process Account | | | Description: Built-in account for Internet Information Services to start out of process applications | | |_ Flags: Password not required, Password does not expire, Normal user account | | RON-WIN2K-TEST\test1234 (RID: 1005) | | |_ Flags: Normal user account | | RON-WIN2K-TEST\TsInternetUser (RID: 1000) | | | Full name: TsInternetUser | | | Description: This user account is used by Terminal Services. |_ |_ |_ Flags: Password not required, Password does not expire, Normal user account
Author: Ron Bowes
License: VER007 整理 http://www.ver007.com