关于net use和psexec无法使用本地管理员组用户建立连接的问题
测试环境:
win7系统,存在域环境 域名:de1ay 普通域用户: de1ayde1ay 域管理员用户:de1ayAdministrator 本地管理员用户: de1ay
当我尝试使用域用户de1ayde1ay和本地管理员组的用户de1ay使用psexec连接目标Windows服务器执行命令时返回了拒绝访问,并且在使用net use建立IPC连接的时候返回了Access Denied
唯一成功的是使用域管用户de1ayAdministrator成功获取到cmd
并且确定ADMIN$目录开启了共享
了解到Psexec是借助的IPC连接执行命令,那么尝试使用上面两组用户名进行IPC连接
只有域管用户成功建立了IPC连接,de1ay/de1ay全局组成员显示为Domain Users 普通的域成员,并非管理员,猜测是因为de1ayde1ay是普通用户权限不足,所以无法建立连接。尝试将de1ayde1ay加入到Domain Admins域管理员组。
再次尝试使用de1ayde1ay用户连接,果然这次成功建立了对admin$目录的IPC连接
可成功使用Psexec弹回cmd
此时回到本地用户,在我修改了域控的密码复杂度等组策略并且在目标机器上启用了Administrator用户后发现使用目标机器本地的Administrator用户可以建立对admin$目录的IPC连接,而同为管理员组下的de1ay又是失败的。
联想到微软 KB2871997 补丁使攻击者无法将哈希传递给非内置RID为500(Administrator)的管理用用户,猜测是否与补丁有关
但是通过查询补丁发现并没有安装KB2871997
而且网上也有一些即使未安装补丁也无法使用本地管理员组非RID500的用户进行哈希传递 和 安装了补丁也可以使用RID非500的用户完成哈希传递的案例,那么除了补丁外,还有什么会对这些行为造成影响?
这些问题的罪魁祸首是远程访问上下文中的用户帐户控制(UAC)令牌过滤
微软的 WindowsVistaUACDevReqs 文档中有如下描述:
User Account Control and Remote Scenarios:
When an administrator logs on to a Windows Vista computer remotely, through Remote Desktop for instance, the user is logged on to the computer as a standard user by default. Remote administration has been modified to be restrictive over a network. This restriction helps prevent malicious software from performing application “loopbacks” if a user is running with an administrator access token.
Local User Accounts:
When a user with an administrator account in a Windows Vista computer’s local Security Accounts Manager (SAM) database remotely connects to a Windows Vista computer, the user has no elevation potential on the remote computer and cannot perform administrative tasks. If the user wants to administer the workstation with a SAM account, the user must interactively logon to the computer that he/she wishes to administer.
Domain User Accounts:
When a user with a domain user account logs on to a Windows Vista computer remotely, and the user is a member of the Administrators group, the domain user will run with a full administrator access token on the remote computer and UAC is disabled for the user on the remote computer for that session.
还有另一份 Description of User Account Control and remote restrictions in Windows Vista 中的描述
Local user accounts (Security Account Manager user account):
When a user who is a member of the local administrators group on the target remote computer establishes a remote administrative connection by using the net use * remotecomputerShare$ command, for example, they will not connect as a full administrator. The user has no elevation potential on the remote computer, and the user cannot perform administrative tasks. If the user wants to administer the workstation with a Security Account Manager (SAM) account, the user must interactively log on to the computer that is to be administered with Remote Assistance or Remote Desktop, if these services are available.
Domain user accounts (Active Directory user account):
A user who has a domain user account logs on remotely to a Windows Vista computer. And, the domain user is a member of the Administrators group. In this case, the domain user will run with a full administrator access token on the remote computer, and UAC will not be in effect.
Note This behavior is not different from the behavior in Windows XP.
对于本地用户:
即使已启用远程管理,内置管理员帐户之外的本地管理员帐户也可能不具有远程管理服务器的权限。 必须将远程用户帐户控制(UAC) LocalAccountTokenFilterPolicy注册表设置配置为允许除内置管理员帐户之外的管理员组的本地帐户远程管理服务器。
如果目标服务器未加入域,请启用以下注册表设置:
HKLMSOFTWAREMicrosoftWindowsCurrentversionsystemLocalAccountTokenFilterPolicy策略。
在不对系统设置进行更改的情况下,除默认的本地管理员账户(Administrators)外无法使用其他本地管理员账户完成远程管理。
对于域用户(ACTIVE DIRECTORY 账户):
以上便解释了为什么本地管理账户在利用IPC远程访问时会失败,但是域管理员账户可以成功。
Windows已经普遍默认禁用了Administrator用户,并且在域环境下,由于域控端设置的密码安全策略,会因为默认的空密码不满足域内密码安全策略中的密码最小长度导致无法在域机器中启用该账户,除非在域控机器上主动修改域内的密码安全策略,在官方文档中已经有了解决方法,通过修改注册表来解除对非默认管理员账户的限制.
在注册表中新建如下项:
Key: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem Value: LocalAccountTokenFilterPolicy Data: 1 (to disable, 0 enables filtering) Type: REG_DWORD (32-bit)
建立完成后再次测试,本地管理员用户de1ay成功建立IPC连接,并且Psexec执行成功。
至此问题已经解决,总结如下:
用户(组) | 添加注册表前 | 添加注册表后 |
---|---|---|
本地管理员(非Administrator) | 无权限 | 有权限 |
Administrator | 有权限 | 有权限 |
域管理员 | 有权限 | 有权限 |
普通域用户 | 无权限 | 无权限 |
普通用户 | 无权限 | 无权限 |