Last active
March 24, 2024 14:54
-
-
Save HackingLZ/0285d248f648f5dd216758c3fbf78c97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python3 | |
import re | |
import zipfile | |
import argparse | |
from urllib.parse import urlparse | |
from colorama import Fore | |
from colorama import Style | |
from colorama import init | |
init() | |
ignore_list = list({ | |
'purl.org', | |
'microsoft.com', | |
'openxmlformats.org', | |
'w3.org', | |
}) # use of set within list ensures that all items are unique | |
alert_list = list({ | |
'internalcanarytokendomain.org', | |
'canarytokens.com', | |
}) | |
url = re.compile("(https?:\/\/[\w.-]+[\/\w .-]*)") | |
ap = argparse.ArgumentParser() | |
ap.add_argument("--input", "-i", required=True, help="Input file") | |
args = ap.parse_args() | |
with zipfile.ZipFile(args.input) as doc: | |
match = [] | |
for i in doc.filelist: | |
with doc.open(i.filename) as file: | |
for line in file: | |
match.extend(url.findall(line.decode('utf-8'))) | |
match = list(filter( | |
lambda x: not any((urlparse(x).hostname.endswith(y) for y in ignore_list)), | |
match | |
)) | |
for item in match: | |
if any((urlparse(item).hostname.endswith(y) for y in alert_list)): | |
foreground_color = Fore.RED | |
else: | |
foreground_color = Fore.YELLOW | |
print(foreground_color + item + Style.RESET_ALL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Powershell version, it's janky but works :)
https://gist.github.com/C0axx/ebf65d863ee708464287c7040b15162a