Skip to content

Instantly share code, notes, and snippets.

@bjonnh
Created November 10, 2020 17:11
Show Gist options
  • Save bjonnh/3f8ec5e22efbbce7188b188e34d98163 to your computer and use it in GitHub Desktop.
Save bjonnh/3f8ec5e22efbbce7188b188e34d98163 to your computer and use it in GitHub Desktop.
Decode outlook safe whatever urls
# Adapted from https://modernsecuritymethods.com/2019/10/04/url-decoding/
from urllib.parse import unquote
import re
import sys
def decode_url(url):
decoded_url = unquote(url.lower())
try:
final_url = ''
h = decoded_url.split('http')
for i in h:
if len(i) < 1:
pass
else:
_url = "{}{}".format('http',i)
final_url = re.findall('(?:(?:https?|http):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.]+', _url)
final_url = "/".join(final_url)
return final_url
except:
return url
print(decode_url(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment