Created
November 10, 2020 17:11
-
-
Save bjonnh/3f8ec5e22efbbce7188b188e34d98163 to your computer and use it in GitHub Desktop.
Decode outlook safe whatever urls
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
# 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