Last active
September 9, 2021 11:01
-
-
Save nullbind/e409b3f1f216919270ee0df7086e501c to your computer and use it in GitHub Desktop.
Get-ProtocolHandle.ps1
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
# based on: https://msrc-blog.microsoft.com/2008/12/09/ms08-075-reducing-attack-surface-by-turning-off-protocol-handlers/ | |
# https://blogs.msdn.microsoft.com/noahc/2006/10/19/register-a-custom-url-protocol-handler/ | |
# https://zero.lol/2019-05-22-fun-with-uri-handlers/ | |
# https://www.vdoo.com/blog/exploiting-custom-protocol-handlers-in-windows | |
# https://docs.microsoft.com/en-us/windows/win32/shell/app-registration | |
# https://docs.microsoft.com/en-us/windows/win32/shell/fa-intro | |
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts | |
# jnlp:file://///server/file.txt | |
$null = $DataTable = New-Object System.Data.DataTable; | |
$null = $DataTable.Columns.Add("key"); | |
$null = $DataTable.Columns.Add("path"); | |
foreach ($Key in Get-ChildItem Microsoft.PowerShell.Core\Registry::HKEY_CLASSES_ROOT) | |
{ | |
$Path = $Key.PSPath + '\shell\open\command'; | |
$HasURLProtocol = $Key.Property -contains 'URL Protocol'; | |
if(($HasURLProtocol) -and (Test-Path $Path)){ | |
$CommandKey = Get-Item $Path; | |
$ProtBin = $CommandKey.GetValue("") | |
$ProtKey = $Key.Name.SubString($Key.Name.IndexOf('\') + 1) | |
$null = $DataTable.Rows.Add($ProtKey,$ProtBin) | |
} | |
} | |
$DataTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment