Added protocol enumeration script
This commit is contained in:
parent
352b5498d2
commit
23ae50020f
24
enumerate.py
Normal file
24
enumerate.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from winreg import *
|
||||||
|
from contextlib import suppress
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
def subkeys(path, hkey=HKEY_CLASSES_ROOT, flags=0):
|
||||||
|
with suppress(WindowsError), OpenKey(hkey, path, 0, KEY_READ|flags) as k:
|
||||||
|
for i in itertools.count():
|
||||||
|
yield EnumKey(k, i)
|
||||||
|
|
||||||
|
def subvalues(path, hkey=HKEY_CLASSES_ROOT, flags=0):
|
||||||
|
with suppress(WindowsError), OpenKey(hkey, path, 0, KEY_READ|flags) as k:
|
||||||
|
for i in itertools.count():
|
||||||
|
yield EnumValue(k, i)
|
||||||
|
|
||||||
|
for entry in subkeys(""):
|
||||||
|
if "shell" not in list(subkeys(entry)):
|
||||||
|
continue
|
||||||
|
|
||||||
|
with suppress(WindowsError):
|
||||||
|
key = OpenKey(HKEY_CLASSES_ROOT, f"{entry}\\shell\\open\\command")
|
||||||
|
command = EnumValue(key, 0)[1]
|
||||||
|
protocolEnabled = "URL Protocol" in (x[0] for x in subvalues(entry))
|
||||||
|
if protocolEnabled:
|
||||||
|
print(f"{entry:38} : {command}")
|
||||||
Loading…
Reference in New Issue
Block a user