Skip to content

Commit

Permalink
Store the encrypted bytes in CorePassSearchSpace + test
Browse files Browse the repository at this point in the history
  • Loading branch information
Coding-Enthusiast committed Nov 2, 2024
1 parent 79dbe76 commit af6c425
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Src/FinderOuter/Services/SearchSpaces/CorePassSearchSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CorePassSearchSpace : SearchSpaceBase
/// Maximum possible password size in bytes (will be padded to be divisible by 4)
/// </summary>
public int MaxPasswordSize { get; private set; }
public byte[] Encrypted { get; private set; }
public byte[] Salt { get; private set; }
public byte[] XOR { get; private set; }
public int Iteration { get; private set; }
Expand Down Expand Up @@ -148,6 +149,7 @@ public bool Process(string hex, int passLength, out string error)
PasswordLength = passLength;
Iteration = iteration;
Salt = salt;
Encrypted = encKey.SubArray(32, 16);
XOR = encKey.SubArray(16, 16);

error = string.Empty;
Expand Down
19 changes: 11 additions & 8 deletions Src/Tests/Services/SearchSpaces/CorePassSearchSpaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static IEnumerable<object[]> GetProcessCases()
2,
true, string.Empty,
Helper.HexToBytes("9ca0271b64c0e66f"),
Helper.HexToBytes("0032153d50cbf924a2ac1dc5f6279436"),
Helper.HexToBytes("55f5e848d66586747cc000826d4c0c35"),
327366
};
Expand All @@ -27,55 +28,56 @@ public static IEnumerable<object[]> GetProcessCases()
"43000130ac71182a748152bb788fb9deb11f2f5a55f5e848d66586747cc000826d4c0c350032153d50cbf924a2ac1dc5f6279436089ca0271b64c0e66f00000000c6fe040000",
0,
false, "Password length must be at least 1.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
"43000130ac71182a748152bb788fb9deb11f2f5a55f5e848d66586747cc000826d4c0c350032153d50cbf924a2ac1dc5f6279436089ca0271b64c0e66f00000000c6fe040000",
-1,
false, "Password length must be at least 1.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
null,
2,
false, "Input hex can not be null or empty.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
"abcx",
2,
false, "Invalid character \"x\" found at index=3.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
"abc",
2,
false, "Invalid hex string.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
"abcd",
2,
false, "Input hex is expected to be at least 70 bytes but it is 2 bytes.",
null, null, 0
null, null, null, 0
};
yield return new object[]
{
Helper.GetBytesHex(70),
2,
false, "Could not find 0x43000130 in the given hex.",
null, null, 0
null, null, null, 0
};
}

[Theory]
[MemberData(nameof(GetProcessCases))]
public void ProcessTest(string hex, int passLength, bool expected, string expError, byte[] expSalt, byte[] expXor, int expIter)
public void ProcessTest(string hex, int passLength, bool expected, string expError,
byte[] expSalt, byte[] expEncrypted, byte[] expXor, int expIter)
{
CorePassSearchSpace searchSpace = new();
bool actual = searchSpace.Process(hex, passLength, out string error);
Expand All @@ -87,6 +89,7 @@ public void ProcessTest(string hex, int passLength, bool expected, string expErr
{
Assert.Equal(searchSpace.PasswordLength, passLength);
Assert.Equal(searchSpace.Salt, expSalt);
Assert.Equal(searchSpace.Encrypted, expEncrypted);
Assert.Equal(searchSpace.XOR, expXor);
Assert.Equal(searchSpace.Iteration, expIter);
}
Expand Down

0 comments on commit af6c425

Please sign in to comment.