diff --git a/src/safelinks.js b/src/safelinks.js new file mode 100644 index 00000000..d33689b7 --- /dev/null +++ b/src/safelinks.js @@ -0,0 +1,5 @@ +// Decode O365 Safelinks +// https://support.microsoft.com/en-us/office/advanced-outlook-com-security-for-microsoft-365-subscribers-882d2243-eab9-4545-a58a-b36fee4a46e2 +const inputUrl = new URL(`http://${process.argv[2]}`) +const outputUrl = new URL(inputUrl.searchParams.get('url')) +console.log(outputUrl.hostname) diff --git a/src/script.sh b/src/script.sh index bb458b48..d51b2a77 100644 --- a/src/script.sh +++ b/src/script.sh @@ -212,10 +212,13 @@ while read URL; do HOST=$(echo "$URL" | cut -d"/" -f1) URI=$(echo "$URL" | sed "s/^$HOST//") - ## Separate host-only URL if [ -z "$URI" ] || [ "$URI" = "/" ]; then + ## Separate host-only URL echo "$HOST" | \ cut -f 1 -d ":" >> "phishing-notop-domains-temp.txt" + elif test "${URL#*safelinks.protection.outlook.com}" != "$URL"; then + ## Parse hostname from O365 safelink + echo $(node "../src/safelinks.js" "$URL") >> "phishing-notop-domains-temp.txt" else ## Parse phishing URLs from popular domains echo "$URL" | \