-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurldecoder.py
More file actions
58 lines (45 loc) · 1.27 KB
/
urldecoder.py
File metadata and controls
58 lines (45 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Decode ProofPoint URL Defense encoded links
# November 11th, 2019
import requests
import json
import sys
import re
def intro():
print("\nProofPoint URL Defense decoder")
print("Enter the encoded URL and press 'Enter'")
print("Type 'exit' to exit")
main()
def main():
headers = {
"Content-Type": "application/json"
}
print("""
Encoded URL:
------------""")
try:
url = input()
if (url == "exit") or (url == "Exit"):
sys.exit()
elif re.search("https://urldefense\.proofpoint\.com/", url):
data = {"urls": [url]}
r = requests.post("https://tap-api-v2.proofpoint.com/v2/url/decode", headers=headers, json=data)
json_data = json.loads(r.text)
for item in json_data["urls"]:
for k,v in item.items():
if k == "decodedUrl":
print(f"""
Decoded URL:
------------
{v}""")
main()
else:
continue
else:
print(f"{url} is not an encoded URL")
main()
except KeyboardInterrupt:
sys.exit()
except Exception as error:
print(f"Error: {error}")
if __name__ == '__main__':
intro()