Skip to content

Instantly share code, notes, and snippets.

@manasmbellani
Last active October 20, 2021 01:42
Show Gist options
  • Save manasmbellani/da8ab2352027e6bcb18ecf65de7e1697 to your computer and use it in GitHub Desktop.
Save manasmbellani/da8ab2352027e6bcb18ecf65de7e1697 to your computer and use it in GitHub Desktop.
scan_url_in_urlscan_io.sh - Scan URL via urlscan.io and open it in default browser
VISIBILITY="public"
SLEEP_TIMEOUT=10
USAGE="[-]
Usage:
$0 <url> <apikey> [visibility=]
Summary:
Scan URL in urlscan.io and open it with default browser
Args:
url - URL to scan
apikey - API Key for urlscan.io
visibility - Visibility to keep for the scan. By default, $VISIBILITY.
Examples:
To scan URL, https://www.msn.com and view result in browser, run the command:
$0 https://www.msn.com $APIKEY
"
if [ $# -lt 1 ]; then
echo "$USAGE"
exit 1
fi
url="$1"
apikey="$2"
echo "[*] Scanning the URL: $url via curl on URLSCAN.IO..."
scan_result=$(curl -s -X POST "https://urlscan.io/api/v1/scan/" \
-H "Content-Type: application/json" \
-H "API-Key: $apikey" \
-d "{ \
\"url\": \"$url\", \"visibility\": \"$VISIBILITY\"}")
echo "[*] Checking if scan was successful for url: $url..."
scan_result_url=$(echo "$scan_result" | grep -i "\"result\"" | cut -d '"' -f4)
if [ -z "$scan_result_url" ]; then
echo "[-] Scan result wasn't successful for url: $url. Result:"
echo "[-] $result"
exit 1
fi
echo "[*] Sleep for $SLEEP_TIMEOUT s until scan completes..."
sleep $SLEEP_TIMEOUT
echo "[*] Open the URLSCAN.IO result for url: $url in default browser..."
set -x
open "$scan_result_url"
set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment