SharpHound3 icon indicating copy to clipboard operation
SharpHound3 copied to clipboard

Added exception handling for BestGuessConvert

Open ash47 opened this issue 3 years ago • 0 comments

Added exception handling for a System.FormatException that occurs when a property looks like a timestamp (ends with 0Z) but isn't actually a timestamp

This is fixed via a try catch to handle the uncaught exception, and a comment to explain what's actually going on :)

The following exception occurs under very specific AD configurations:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.FormatException: String was not recognized as a valid DateTime.
   at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
   at System.DateTime.ParseExact(String s, String format, IFormatProvider provider)
   at SharpHound3.Tasks.ObjectPropertyTasks.BestGuessConvert(String property)
   at SharpHound3.Tasks.ObjectPropertyTasks.ParseAllProperties(LdapWrapper wrapper)
   at SharpHound3.Tasks.ObjectPropertyTasks.<ResolveObjectProperties>d__2.MoveNext()
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SharpHound3.SharpHound.<Main>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SharpHound3.SharpHound.<Main>(String[] args)

ash47 avatar Mar 15 '21 00:03 ash47