Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize windows cert verify #108

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lysShub
Copy link

@lysShub lysShub commented Nov 26, 2024

No description provided.

@ayoubfaouzi
Copy link
Member

Thanks a lot. Can you post the output of: go test.

@lysShub
Copy link
Author

lysShub commented Nov 26, 2024

these errors should not be related to my changes @ayoubfaouzi

--- FAIL: TestGetAnomalies (0.00s)
    --- FAIL: TestGetAnomalies/D:\Desktop\c\pe/test/050708404553416d103652a7ca1f887ab81f533a019a0eeff0e6bb460a202cde.7z (0.00s)
        anomaly_test.go:37: Parse(D:\Desktop\c\pe/test/050708404553416d103652a7ca1f887ab81f533a019a0eeff0e6bb460a202cde.7z) failed, reason: DOS Header magic not found     
    --- FAIL: TestGetAnomalies/D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z (0.00s)
        anomaly_test.go:37: Parse(D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z) failed, reason: DOS Header magic not found     
--- FAIL: TestBoundImportDirectory (0.00s)
    --- FAIL: TestBoundImportDirectory/D:\Desktop\c\pe/test/0044e1870806c048a7558082d4482d1650dcd3ea73152ed2218a554983130721.7z (0.00s)
        boundimports_test.go:70: Parse(D:\Desktop\c\pe/test/0044e1870806c048a7558082d4482d1650dcd3ea73152ed2218a554983130721.7z) failed, reason: DOS Header magic not found
--- FAIL: TestDebugDirectoryCodeView (0.00s)
    --- FAIL: TestDebugDirectoryCodeView/D:\Desktop\c\pe/test/01008963d32f5cc17b64c31446386ee5b36a7eab6761df87a2989ba9394d8f3d.7z (0.00s)
        debug_test.go:104: Parse(D:\Desktop\c\pe/test/01008963d32f5cc17b64c31446386ee5b36a7eab6761df87a2989ba9394d8f3d.7z) failed, reason: DOS Header magic not found      
--- FAIL: TestDebugDirectoryVCFeature (0.00s)
    --- FAIL: TestDebugDirectoryVCFeature/D:\Desktop\c\pe/test/00da1a2a9d9ebf447508bf6550f05f466f8eabb4ed6c4f2a524c0769b2d75bc1.7z (0.00s)
        debug_test.go:476: Parse(D:\Desktop\c\pe/test/00da1a2a9d9ebf447508bf6550f05f466f8eabb4ed6c4f2a524c0769b2d75bc1.7z) failed, reason: DOS Header magic not found      
--- FAIL: TestDelayImportDirectory (0.00s)
    --- FAIL: TestDelayImportDirectory/D:\Desktop\c\pe/test/000049925c578e5a0883e7d1a8257c1a44feab8f7d9972ace8d0e3fb96612a4c.7z (0.00s)
        delayimports_test.go:68: Parse(D:\Desktop\c\pe/test/000049925c578e5a0883e7d1a8257c1a44feab8f7d9972ace8d0e3fb96612a4c.7z) failed, reason: DOS Header magic not found
--- FAIL: TestParseExceptionDirectory (0.00s)
    --- FAIL: TestParseExceptionDirectory/D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z (0.00s)
        exception_test.go:81: Parse(D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z) failed, reason: DOS Header magic not found   
--- FAIL: TestChecksum (0.01s)
    --- FAIL: TestChecksum/D:\Desktop\c\pe/test/010001e68577ef704792448ff474d22c6545167231982447c568e55041169ef0.7z (0.00s)
        file_test.go:94: Parse(D:\Desktop\c\pe/test/010001e68577ef704792448ff474d22c6545167231982447c568e55041169ef0.7z) failed, reason: DOS Header magic not found        
--- FAIL: TestImpHash (0.01s)
    --- FAIL: TestImpHash/D:\Desktop\c\pe/test/01008963d32f5cc17b64c31446386ee5b36a7eab6761df87a2989ba9394d8f3d.7z (0.00s)
        imports_test.go:146: Parse(D:\Desktop\c\pe/test/01008963d32f5cc17b64c31446386ee5b36a7eab6761df87a2989ba9394d8f3d.7z) failed, reason: DOS Header magic not found    
    --- FAIL: TestImpHash/D:\Desktop\c\pe/test/0103daa751660333b7ae5f098795df58f07e3031563e042d2eb415bffa71fe7a.7z (0.00s)
        imports_test.go:146: Parse(D:\Desktop\c\pe/test/0103daa751660333b7ae5f098795df58f07e3031563e042d2eb415bffa71fe7a.7z) failed, reason: DOS Header magic not found    
    --- FAIL: TestImpHash/D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z (0.00s)
        imports_test.go:146: Parse(D:\Desktop\c\pe/test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0.7z) failed, reason: DOS Header magic not found    
--- FAIL: TestLoadConfigDirectory (0.00s)
    --- FAIL: TestLoadConfigDirectory/D:\Desktop\c\pe/test/00da1a2a9d9ebf447508bf6550f05f466f8eabb4ed6c4f2a524c0769b2d75bc1.7z (0.00s)
        loadconfig_test.go:175: Parse(D:\Desktop\c\pe/test/00da1a2a9d9ebf447508bf6550f05f466f8eabb4ed6c4f2a524c0769b2d75bc1.7z) failed, reason: DOS Header magic not found 
    --- FAIL: TestLoadConfigDirectory/D:\Desktop\c\pe/test/3a081c7fe475ec68ed155c76d30cfddc4d41f7a09169810682d1c75421e98eaa.7z (0.00s)
        loadconfig_test.go:175: Parse(D:\Desktop\c\pe/test/3a081c7fe475ec68ed155c76d30cfddc4d41f7a09169810682d1c75421e98eaa.7z) failed, reason: DOS Header magic not found 
--- FAIL: TestParseSecurityDirectory (0.01s)
    --- FAIL: TestParseSecurityDirectory/579fd8a0385482fb4c789561a30b09f25671e86422f40ef5cca2036b28f99648.7z (0.00s)
        security_test.go:164: Parse(D:\Desktop\c\pe/test/579fd8a0385482fb4c789561a30b09f25671e86422f40ef5cca2036b28f99648.7z) failed, reason: DOS Header magic not found   
    --- FAIL: TestParseSecurityDirectory/00121dae38f26a33da2990987db58738c5a5966930126a42f606a3b40e014624.7z (0.00s)
        security_test.go:164: Parse(D:\Desktop\c\pe/test/00121dae38f26a33da2990987db58738c5a5966930126a42f606a3b40e014624.7z) failed, reason: DOS Header magic not found   
--- FAIL: TestAuthentihash (0.04s)
    --- FAIL: TestAuthentihash/D:\Desktop\c\pe/test/000057fd78f66e64e15f5070364c824a8923b6216bd8bcf6368857fb9674c483.7z (0.00s)
        security_test.go:241: Parse(D:\Desktop\c\pe/test/000057fd78f66e64e15f5070364c824a8923b6216bd8bcf6368857fb9674c483.7z) failed, reason: DOS Header magic not found   
--- FAIL: TestParseCOFFSymbolTable (0.00s)
    --- FAIL: TestParseCOFFSymbolTable/D:\Desktop\c\pe/test/0103daa751660333b7ae5f098795df58f07e3031563e042d2eb415bffa71fe7a.7z (0.00s)
        symbol_test.go:88: Parse(D:\Desktop\c\pe/test/0103daa751660333b7ae5f098795df58f07e3031563e042d2eb415bffa71fe7a.7z) failed, reason: DOS Header magic not found       
    --- FAIL: TestParseCOFFSymbolTable/D:\Desktop\c\pe/test/0000e876c5b712b6b7b3ce97f757ddd918fb3dbdc5a3938e850716fbd841309f.7z (0.00s)
        symbol_test.go:88: Parse(D:\Desktop\c\pe/test/0000e876c5b712b6b7b3ce97f757ddd918fb3dbdc5a3938e850716fbd841309f.7z) failed, reason: DOS Header magic not found       
--- FAIL: TestParseTLSDirectory (0.00s)
    --- FAIL: TestParseTLSDirectory/D:\Desktop\c\pe/test/3a081c7fe475ec68ed155c76d30cfddc4d41f7a09169810682d1c75421e98eaa.7z (0.00s)
        tls_test.go:55: Parse(D:\Desktop\c\pe/test/3a081c7fe475ec68ed155c76d30cfddc4d41f7a09169810682d1c75421e98eaa.7z) failed, reason: DOS Header magic not found
FAIL
FAIL    github.com/saferwall/pe 1.157s
ok      github.com/saferwall/pe/cmd     (cached)
ok      github.com/saferwall/pe/log     (cached)
FAIL

@ayoubfaouzi
Copy link
Member

ayoubfaouzi commented Nov 26, 2024

OK. Never mind the errors in unit tests.

My question is that if you use verify without a cert pool, it will use Windows crypto APIs to enumerate whatever is on the Windows box. And you can see in my comment why I didn't want to use that solution because :

// loadSystemsRoots manually downloads all the trusted root certificates
// in Windows by spawning certutil then adding root certs individually
// to the cert pool. Initially, when running in windows, go SystemCertPool()
// used to enumerate all the certificate in the Windows store using
// (CertEnumCertificatesInStore). Unfortunately, Windows does not ship
// with all of its root certificates installed. Instead, it downloads them
// on-demand. As a consequence, this behavior leads to a non-deterministic
// results. Go team then disabled the loading Windows root certs.

Windows have an on-demand approach. Read this: golang/go#18609

@lysShub
Copy link
Author

lysShub commented Nov 26, 2024

is there any problem with the on-demand approach? system will not misjudge the validity of the certificate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants