Closed antonioCoco closed 9 months ago
Hi. Sorry for the late response. The first working version has been implemented in PR #17. It might need a little bit more extensive testing before merging though. Let me know if you run into any issues with the PR revision if you have a chance to test it out.
@metthal tested your fix and works well with all MS drivers i was able to test. Well done! :thumbsup:
Fixed with #17
Hi,
it seems there is a bug in the library when parsing the countersignatures on Microsoft signed drivers.
If you try to run the authenticode_dumper code from your examples on a Microsoft signed driver, e.g. procexp.sys, you will get the following output:
As you can see the Verify Flags is set to
COUNTERSIGNATURE_VFY_CANT_PARSE
in the parsed countersignature. BTW this bug happens with any drivers signed by Microsoft, you can pick any drivers with a signature in the C:\Windows\System32\drivers directory and the same unwanted behavior happens.When using the "Digital Signatures" tab from explorer in Windows, you can see that it correctly parses the countersignature from Microsoft-signed drivers. Below example for the procexp.sys driver:
Instead, the parsing of countersignatures from drivers non-Microsoft signed works properly, e.g. kprocesshacker.sys:
I debugged a bit the issue and it seems the failure is here --> https://github.com/avast/authenticode-parser/blob/master/src/countersignature.c#L187 It seems that the openssl function
d2i_PKCS7
is not able to parse the data from the unauthenticated attribute.Also, i have a suspect that this bug is causing an issue in the parsing of countersignature in the "pe" module of yara in which i opened already an issue here --> https://github.com/VirusTotal/yara/issues/2012
Thanks,
Antonio Cocomazzi