Dump URL Handler Script

I will have a look into the URL Handler Bugs soon, and there must be a lot to learn inside. Prior to that, I still need to find out what to investigate. So here are the scripts to dump URL Handlers for Windows and Linux, scripted uglily in Python in minutes. My Macbook is pretty screwed for those who know, so no Mac version. Feel free to use.

Windows :

from _winreg import OpenKey, EnumValue, EnumKey, HKEY_CLASSES_ROOT

handlers = []

hkcrKey = OpenKey(HKEY_CLASSES_ROOT, "")
	i = 0
	while 1:
		keyName = EnumKey(hkcrKey, i)
		keyHandle = OpenKey(HKEY_CLASSES_ROOT, keyName)
			j = 0
			while 1:
				valueName = EnumValue(keyHandle, j)
				if valueName[0] == 'URL Protocol':
				j = j + 1

		except WindowsError:
		i = i + 1
except WindowsError:

for handler in sorted(handlers):
	print handler

Linux :

import os
import re
import sys
from sets import Set

file = open('/usr/share/gconf/schemas/desktop_gnome_url_handlers.schemas', 'r')
data = file.read()

The interesting parts are "applyto" tags. The term between 4th and 5th slash is the URI we want.

uris = re.compile('([a-zA-Z0-9/\-]+)', re.MULTILINE).findall(data)
handlers = []

for uri in uris:
    handler = uri.split('/')[4]

for handler in sorted(Set(handlers)):
    print handler

Here we go…

I am so sorry the scripts look so awful, and thanks to Kane for the PRE tag tip!


0 Responses to “Dump URL Handler Script”

  1. Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: