NetSPI / PESecurity

PowerShell module to check if a Windows binary (EXE/DLL) has been compiled with ASLR, DEP, SafeSEH, StrongNaming, and Authenticode.
https://blog.netspi.com/verifying-aslr-dep-and-safeseh-with-powershell/
MIT License
621 stars 147 forks source link

Powershell Core 7 support #22

Closed silverqx closed 2 years ago

silverqx commented 3 years ago

Module works fine on PS 5, but when I try it on PS 7 then I get many errors, I'm attaching the output file: output.txt

eabase commented 2 years ago

Yep, please fix this, or tell us how to work around it. Seem to be an old problem...

InvalidOperation: Method invocation failed because [System.AppDomain] does not 
contain a method named 'DefineDynamicAssembly'.

InvalidOperation: You cannot call a method on a null-valued expression.

...
egru commented 2 years ago

The work around is to use powershell 5 or lower. I think it needs a large rewrite to work for powershell 7.

eabase commented 2 years ago

The following references seem to suggest otherwise:

egru commented 2 years ago

I'll gladly accept a pull request with the needed changes.

eabase commented 2 years ago

@egru well that's not gonna happen. I'm obviously not a PS programmer and even less so a .NET fan. If I knew how to fix it, you'd have a PR already!

egru commented 2 years ago

The latest commit fixes the issue with PowerShell Core.

eabase commented 2 years ago

@egru Thank you so much Eric, for taking the time for a patch! 💯

silverqx commented 2 years ago

Thx @egru I have tested it on PS5 and pwsh core and it works great 👌.