Created
February 5, 2015 08:19
-
-
Save mikeminutillo/bf6ff38557829f15411d to your computer and use it in GitHub Desktop.
A LINQPad Script which will retrieve the stored password that IE autocomplete saved against a particular url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With massive help from http://securityxploded.com/iepasswordsecrets.php | |
var urlBytes = System.Text.Encoding.Unicode.GetBytes((url + '\0').ToLower()); | |
byte[] hashBytes; | |
using(var sha1 = new SHA1Managed()) | |
hashBytes = sha1.ComputeHash(urlBytes); | |
var checksum = hashBytes.Aggregate((x,y) => (byte)((int)x + (int)y)); | |
var keyBytes = hashBytes.Concat(new[] { checksum }).ToArray(); | |
var regKey = String.Join("", keyBytes.Select(x => x.ToString("X2"))); | |
var encryptedData = (byte[])Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\IntelliForms\Storage2", regKey, null); | |
var unprotectedData = ProtectedData.Unprotect(encryptedData, urlBytes, DataProtectionScope.CurrentUser); | |
var headerSize = BitConverter.ToInt32(unprotectedData, 0 * sizeof(int)); | |
var secretInfoSize = BitConverter.ToInt32(unprotectedData, 1 * sizeof(int)); | |
var secretSize = BitConverter.ToInt32(unprotectedData, 2 * sizeof(int)); | |
var secretBytes = unprotectedData.Reverse().Take(secretSize).Reverse().ToArray(); | |
Encoding.Unicode.GetString(secretBytes).Split('\0').Take(2).Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically the process is as follows: