Last active
November 30, 2023 10:03
-
-
Save onetdev/93e76fa471eece60e49f963ebe46613e to your computer and use it in GitHub Desktop.
Scan .well-known URIs for a path
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
#!/bin/bash | |
echo "For full list of well-known urls: https://en.wikipedia.org/wiki/Well-known_URI" | |
scanBaseUri=$1 | |
outputPath="./well-known-scans" | |
if test -z "$scanBaseUri" | |
then | |
echo "You must provide param for domain/path scan" | |
exit 0 | |
else | |
echo "Scanning for path: $scanBaseUri" | |
fi | |
mkdir -p $outputPath | |
wellKnownPaths=( | |
'acme-challenge' | |
'ai-plugin.json' | |
'apple-app-site-association' | |
'apple-developer-merchantid-domain-association' | |
'ashrae' | |
'assetlinks.json' | |
'autoconfig/mail' | |
'browserid' | |
'caldav' | |
'carddav' | |
'change-password' | |
'coap' | |
'com.apple.remotemanagement' | |
'core' | |
'csvm' | |
'dat' | |
'did.json' | |
'discord' | |
'dnt' | |
'dnt-policy.txt' | |
'est' | |
'genid' | |
'gpc' | |
'hoba' | |
'host-meta' | |
'host-meta.json' | |
'http-opportunistic' | |
'jwks.json' | |
'keybase.txt' | |
'matrix' | |
'mercure' | |
'mta-sts.txt' | |
'ni' | |
'nodeinfo' | |
'openid-configuration' | |
'openorg' | |
'openpgpkey' | |
'pki-validation' | |
'posh' | |
'pubvendors.json' | |
'reload-config' | |
'repute-template' | |
'resourcesync' | |
'security.txt' | |
'statements.txt' | |
'stun-key' | |
'tdmrep.json' | |
'time' | |
'timezone' | |
'uma2-configuration' | |
'void' | |
'webfinger' | |
'xrp-ledger.toml' | |
) | |
for i in "${wellKnownPaths[@]}" | |
do | |
: | |
scanUrl="${scanBaseUri}.well-known/${i}" | |
scanOutputPath="${outputPath}/${i/\//__}" | |
echo "Scanning [${i}]" | |
# curl -o "${scanOutputPath}" "${scanUrl}" | |
queryInfo=$(curl -I -L $scanUrl 2>/dev/null | head -n 1 | cut -d$' ' -f2) | |
queryResult=$(curl -s -L $scanUrl) | |
if [[ $queryResult =~ ^\<head || $queryResult =~ ^\n$ || $queryInfo != '200' ]]; then | |
echo "File seems to contain HTML/error"; | |
else | |
echo "Storing result [$scanUrl > $scanOutputPath]"; | |
echo $queryResult > $scanOutputPath | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment