Created
June 22, 2024 14:53
-
-
Save matterpreter/4d8d5fd7d411b06d626ed1fd766c593d to your computer and use it in GitHub Desktop.
COM server vtable finder
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
# Instantiate the object | |
$clsid = '{A845DCD6-BB08-4F37-9BA5-AAC66F5ADDCE}' | |
$obj = [System.Activator]::CreateInstance([type]::GetTypeFromCLSID($clsid)) | |
# Get the address of the IUnknown vtable | |
Add-Type -AssemblyName 'System.Runtime.InteropServices' | |
$iunk = [System.Runtime.InteropServices.Marshal]::GetIUnknownForObject($obj) | |
$vtable = [System.Runtime.InteropServices.Marshal]::ReadIntPtr($iunk) | |
# Locate the in-proc server and get it's base address | |
$modbase = (gps -Id $pid).Modules | ? ModuleName -Like 'SimpleCOMServer*' | % BaseAddress | |
# Calculate the offset | |
'{0:x}' -f ($vtable.ToInt64() - $modbase.ToInt64()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment