0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NTLM协议相关的安全问题之Pass The Hash

Last updated at Posted at 2020-10-18

在前文写ntlm协议中的认证时,客户端接收到Challenge之后,使用用户NTLM Hash与Challenge进行加密运算得到Response,将Response,username,Challenge发给服务器。那也就是说我们不需要用户的明文密码,只需要hash和challenge就可以认证,也就是PTH(Pass The Hash)。

先介绍几个pth的工具

PTH工具

可以PTH的工具太多了,每个工具都有自己的优缺点。

impacket

impacket工具包下的几个可以远程执行命令的

image.png

python2 psexec.py web/administrator@172.16.33.9 -hashes 00000000000000000000000000000000:58ec08167e274ad52d1849da7a3e9a81

image.png

冒号分割的前半段是LM Hash,用32个0填充就行,后面的是mimikatz抓的ntlm hash。

crackmapexec

root权限运行,否则会报一些错误。
image.png

psexec.exe

创建服务,杀软盯得死。

C:\Users\Administrator\Desktop\PSTools>PsExec64.exe -accepteula \\web -s -u test\administrator -p 00000000000000000000000000000000:58ec08167e274ad52d1849da7a3e9a81 cmd.exe

image.png

wmiexec.py

image.png

powershell

参考地址:https://github.com/Kevin-Robertson/Invoke-TheHash/

支持smb wmi多种方式

Invoke-WMIExec:

Invoke-WMIExec -hash 58ec08167e274ad52d1849da7a3e9a81 -Target 172.16.33.9 -domain . -Username administrator -command calc -Verbose

类似wmiexec.py

image.png

wmihacker

mimikatz

image.png

kb2871997

微软为了防御pth,发布了补丁kb2871997,但是实际上对于本地Administrator用户和加入本地管理员组的域用户是没有影响的。

在打了补丁之后,使用rid500和非500的用户来测试
image.png

使用administrator rid为500的账户pth
image.png

使用admin rid非500的账户来pth
image.png

而使用加入本地管理员组的域用户来pth是可以的,我这里换了域环境,使用win7来测试。
image.png

域中的Domain Admins组也存在于本地管理员组中,加一个域用户test\test并且将它加入到Domain Admins组中
image.png

使用test\test来pth没有问题
image.png

这些问题的真正罪魁祸首是远程访问上下文中的用户帐户控制(UAC)令牌筛选。

对于远程连接到Windows Vista +计算机的任何非RID 500本地管理员帐户,无论是通过WMI,PSEXEC还是其他方法(有个例外,那就是通过RDP远程),即使用户是本地管理员,返回的令牌都是已过滤的管理员令牌(没有过UAC)。而对于本地“管理员”组中的域用户帐户,文档指出:

当具有域用户帐户的用户远程登录Windows Vista计算机并且该用户是Administrators组的成员时,域用户将在远程计算机上以完全管理员访问令牌运行,并且该用户的UAC被禁用在该会话的远程计算机上。

如果计算机中 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy 项存在(默认不存在)且配置为1,将授予来自管理员所有本地成员的远程连接完整的高完整性令牌。这意味着未过滤非RID 500帐户连接,并且可以成功传递哈希值!

自己新建一个这个键值之后就可以进行pth了。在配置winrm的时候,也会遇到同样的问题,本地管理员组的非RID500账户不能登录,于是有些运维在搜寻了一堆文章后,开启该注册表项是最快捷有效的问题:)

image.png

image.png

总结一下

用户(组) 解除限制前 解除限制后
Administrators(除Administrator的本地用户) 无权限 有权限
Administrator 有权限 有权限
被添加到Administrators中的域用户 有权限 有权限
Domain Users 无权限 无权限
Users 无权限 无权限

参考

  1. https://daiker.gitbook.io/windows-protocol/ntlm-pian/4
  2. https://3gstudent.github.io/3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-Pass-The-Hash%E7%9A%84%E5%AE%9E%E7%8E%B0/
  3. https://www.anquanke.com/post/id/193150
  4. https://ares-x.com/2020/03/10/%E5%85%B3%E4%BA%8EIPC%E5%92%8CPTH%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90%E9%97%AE%E9%A2%98/
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?