Audit Gone Bad - I'm Now The Domain Admin.
Today I had the pleasure of auditing a branch organization. The guilty will remain nameless.
Anyhow, over the years I have put together a set of tests to perform in a Microsoft AD environment. Because I'm seeing this issue more and more, I figured I would report it here so perhaps you don't find yourself on the hook during a security audit.
Without going into extensive detail, Microsoft AD uses logon scripts to map your host to certain resources at logon time. These scripts can also be used to push software, change policy, etc..
When written properly, you don't have many issues. When deployed poorly, you can give away the domain admin account in seconds.
Because you have to be able to execute the login scripts, each host must be able to read and execute the batch file. This means that from *any* workstation you can peruse the logon script directory on the domain controller. There are secure ways to setup scripts, however in this example, the lazy admin took the easy way out and believed he was secure in doing so.
OK, so here is what he did:
1) Created a login script that utilized a third party "runas" tool made by lansweeper. Its called lsrunasE.
See: http://www.lansweeper.com/ls/lsrunas.aspx
It basically takes your password and runs it through a weak encryption process that uses (surprise, surprise) static salts.
2) He placed his domain admin credentials in the logon script.
Code:
lsrunase /user:ADMIN /password:5F44Dxkkjd1167aaa== /domain:DOMAIN.XXX various other switches.
3) Reported to us that the script is secure.
OK, when I first saw this I laughed. He didn't find humor in this. He said, "You have to break the encryption if you are going to do anything with that account.
I responded with, "Oh really?!" and the typical smirk of discontent.
To humor him I simply Googled lsrunase and DLed the tool which comes with the encryption engine. This is a free tool BTW. I already knew I could run this tool and pass the hash through on any app or server in the domain, but hey, he said I had to break the encryption so I had to prove him wrong.
The lsrunase app obviously has the decrytion mechanism in it or the hash wouldn't work. All I did was run this tool with the user and password as seen below in a shortcut to the lsrunase app which called the domain administration MMC.
Example:
Code:
"C:\temp\lsrunase\lsrunase.exe" /user:ADMIN /password:5F44Dxkkjd1167aaa== /domain:DOMAIN.XXX/command:"mmc dsa.msc"
PRESTO!
Without decrypting the hash, I am now the domain admin. Can you guess where I go from here? Yep, back to the hash. Needless to say, the encryption is extremely weak. In fact, I think that even skiddieleet could break it. After about 5 minutes I handed him his password and wrote up the failing grade on the audit before leaving the first test.
If you ever want to see someone lose their mind on the spot, this is a good way to provoke it.
Just so everyone knows, the info above (user:password, etc.) has been heavily doctored to leave no trace of the real credentials. The point here is that in a matter of 5 minutes I PWN3D a very sensitive agency and they didn't like it very much. I can't imagine that these poor fools are the only ones doing things like this. Please look at and understand how to securely manage your AD environment!
This has been a public service announcement
--TH13