googleprojectzero / sandbox-attacksurface-analysis-tools

Set of tools to analyze Windows sandboxes for exposed attack surface.
Apache License 2.0
2.05k stars 428 forks source link

Kerberos Updates #51

Closed monoxgas closed 2 years ago

monoxgas commented 2 years ago

I assume this can be a longer term PR as I work out the best ways to contribute. I've made some initial changes to help support updating and re-packing tickets, authenticators, and the PAC. Some initial questions+thoughts:

Current code is awesome though, I do wonder what optimizations/APIs I'm missing just having to dissect the code without reference. I'll message you privately regarding that. Let me now how you're feeling about handling these object trees, field updates, and repacking nested structures. Feels like IDerObject, GetData(), _data, etc. all have some overlap and I might not be understanding the larger picture.

tyranid commented 2 years ago

Thanks. The code is in a transitional state (well isn't it always?) as in the code was originally written purely for read-only purposes and I'm having to retro fit in writing. That's why there's inconsistencies such as some objects which are fully rebuildable at serialization while others construct the data and reparse. I'd prefer to move it to one way or another, but I'm in part mindful that at least for top level authentication tokens I'd rather keep the byte representation as originally received so that the more common use case of client/server authentication doesn't break if my reserialization isn't correct or breaks a checksum somewhere.

I've tended to go for a builder paradigm where possible, you have your read-only object which can be converted into builder to modify and then convert it back to a read-only object. Though of course as the code has been written it isn't always 100% consistent. But certainly I can imagine as the complexity of the object graph goes up then it's going to make it more complex to use that approach, though I guess if you have a builder you could convert the whole PAC data to a "builder", modify and reserialize in place.

As for ensure correct reserialization perhaps changing things that need to be reserialized in the exact same way we should convert them to use a structure which guarantees a full round trip.