渗透攻击红队
一个专注于红队攻击的公众号
![62959c2c2a0f4c5370dd0d16c6cf508b.png](https://i-blog.csdnimg.cn/blog_migrate/5217f92b1da81a82cbd41d164ddc3c4b.jpeg)
大家好,这里是 渗透攻击红队 的第 40 篇文章,本公众号会记录一些我学习红队攻击的复现笔记(由浅到深),不出意外每天一更
![93093e208626ca4692cb2a671f45287a.gif](https://i-blog.csdnimg.cn/blog_migrate/ca9aeb2086b98a88ad6725b411e04287.gif)
Hook PasswordChangeNotify 的作用是当用户修改密码后在系统中进行同步。
攻击者可以利用该功能获取用户修改密码时输入的密码明文。
在修改密码时,用户输入新密码后,LSA 会调用 PasswordFileter 来检查该密码是否符合复杂性要求,如果密码符合要求,LSA 会调用 PasswordChangeNotify,在系统中同步密码。
Hook PasswordChangeNotify
实验操作
Hook dll
下载连接:https://github.com/clymb3r/Misc-Windows-Hacking
使用 VS 2019的开发环境,MFC设置为在静态库中使用MFC编译工程,生成 HookPasswordChange.dll。
下载脚本:https://github.com/clymb3r/PowerShell/blob/master/Invoke-ReflectivePEInjection/Invoke-ReflectivePEInjection.ps1
首先需要 Invoke-ReflectivePEInjection.ps1 脚本将 HookPasswordChange.dll 注入内存,在目标系统中启动管理员权限的 Powershell:
Set-ExecutionPolicy bypassImport-Module .\Invoke-ReflectivePEInjection.ps1Invoke-ReflectivePEInjection -PEPath HookPasswordChange.dll -procname lsass
这个时候没有报错就说明成功了,最后我们手动改一次域控的密码:Admin123456
更改成功后,我们在 C:\Windows\Temp 可以找到文件:passwords.txt
此时可以看到域控的密码为:Admin123456
如果想要更改 passwords.txt 存放路径的话,那么更改 HookPasswordChange.cpp 代码的 132 行 为你想要生成的路径即可:
我修改为 windows.log 误以为让管理员知道是 log 文件,随后再次执行:
这样就能在 windows.log 文件中查看到域控更改的密码!
防御措施
使用 Hook PasswordChangeNotify 方法不需要重启系统、不会在系统磁盘中留下 DLL 文件、不需要修改注册表。
如果 PasswordChangeNotify 被攻击者利用,网络管理员是很难检测到的。
防御措施就是:对 Powershell 进行严格的监视。
参考文章:
https://www.cnblogs.com/xiaoxiaosen/p/13537305.html
https://github.com/clymb3r/PowerShell
https://github.com/clymb3r/Misc-Windows-Hacking
渗透攻击红队
一个专注于渗透红队攻击的公众号
![113bc179468a3b4ea842f92ef7056c7a.png](https://i-blog.csdnimg.cn/blog_migrate/beb6f2cd25c6502e1358df71e926ac84.jpeg)
![f166627f6e4164b41a6e303af8688b64.png](https://i-blog.csdnimg.cn/blog_migrate/42f169f54c1be3afd3f099969abdc3e8.png)
![cf78526a7233790a7f1fd77a648f285a.png](https://i-blog.csdnimg.cn/blog_migrate/257c2a02deff1d24a457a1d5ac35915e.png)
![c6674fa1789e870065b35f25ac25ce6a.png](https://i-blog.csdnimg.cn/blog_migrate/da430e19ad1e9916a8b5d3dab33f641f.png)