Skip to content

Instantly share code, notes, and snippets.

@matterpreter
Created June 22, 2024 14:53
Show Gist options
  • Save matterpreter/4d8d5fd7d411b06d626ed1fd766c593d to your computer and use it in GitHub Desktop.
Save matterpreter/4d8d5fd7d411b06d626ed1fd766c593d to your computer and use it in GitHub Desktop.
COM server vtable finder
# 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