Skip to content
Browse files

Take into account longer passwords by making the scanning code a litt…

…le smarter
  • Loading branch information...
1 parent 491873e commit a954786dfc7ca36727897207cd25f01aa36f62ac @brandonlw committed Oct 16, 2012
Showing with 16 additions and 10 deletions.
  1. +16 −10 FingerprintEncryption/Startup.cs
View
26 FingerprintEncryption/Startup.cs
@@ -274,14 +274,20 @@ private static bool _HandleKeyValue(string key, string name, byte[] raw)
//For types 0x05 and above, the password is encrypted separately -- get it
if (!_verbose && type >= 0x05)
{
- //HACK: Not exactly sure how to parse the above data, so just look for a block with a specific size
- var index = _FindBytes(output, new byte[] { 0xF6, 0x00, 0x00, 0x00 });
- var passwordBlock = new byte[_GetInt(output, index.Value)];
- Array.Copy(output, index.Value + 4, passwordBlock, 0, passwordBlock.Length);
- var decryptedPassword = _DecryptBlock(passwordBlock);
-
- Console.WriteLine("\t\tPassword:\t" +
- UnicodeEncoding.Unicode.GetString(decryptedPassword).TrimEnd('\0'));
+ //HACK: Not exactly sure how to parse the above data, so just look for a block
+ // with a specific "signature" after "P1" Unicode string
+ var passwordIndex = _FindBytes(output, 0, new byte[] { 0x50, 0x00, 0x31, 0x00 });
+ if (passwordIndex.HasValue)
+ {
+ var index = _FindBytes(output, passwordIndex.Value,
+ new byte[] { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 });
+ var passwordBlock = new byte[_GetInt(output, index.Value - 2)];
+ Array.Copy(output, index.Value - 2 + 4, passwordBlock, 0, passwordBlock.Length);
+ var decryptedPassword = _DecryptBlock(passwordBlock);
+
+ Console.WriteLine("\t\tPassword:\t" +
+ UnicodeEncoding.Unicode.GetString(decryptedPassword).TrimEnd('\0'));
+ }
}
}
else
@@ -299,11 +305,11 @@ private static int _GetInt(byte[] raw, int offset)
(raw[offset + 2] << 16) | (raw[offset + 3] << 24));
}
- private static int? _FindBytes(byte[] haystack, byte[] needle)
+ private static int? _FindBytes(byte[] haystack, int startingIndex, byte[] needle)
{
int? ret = null;
- for (int i = 0; i < haystack.Length; i++)
+ for (int i = startingIndex; i < haystack.Length; i++)
{
bool found = true;

0 comments on commit a954786

Please sign in to comment.
Something went wrong with that request. Please try again.