Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Added exception handling for BestGuessConvert #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions SharpHound3/Tasks/ObjectPropertyTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,17 @@ private static object BestGuessConvert(string property)
//A string ending with 0Z is likely a timestamp
if (property.EndsWith("0Z"))
{
var dt = DateTime.ParseExact(property, "yyyyMMddHHmmss.0K", CultureInfo.CurrentCulture);
return (long)dt.Subtract(WindowsEpoch).TotalSeconds;
// If the string isn't actually a timestamp, a System.FormatException will be thrown
try
{
var dt = DateTime.ParseExact(property, "yyyyMMddHHmmss.0K", CultureInfo.CurrentCulture);
return (long)dt.Subtract(WindowsEpoch).TotalSeconds;
}
catch
{
// Not a valid timestamp
return property;
}
}

//This string corresponds to the max int, and is usually set in accountexpires
Expand Down