Created
December 18, 2024 14:24
-
-
Save kylefmohr/b3c223ec6acb5f8f5332239dce34d76b to your computer and use it in GitHub Desktop.
Shodan Bluesky domain lookup
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
// ==UserScript== | |
// @name Bsky Domain History Lookup (Console Output) | |
// @namespace http://your-namespace.com | |
// @version 1.2 | |
// @description Looks up the history of custom domains on bsky.app profiles via Shodan and logs JSON to console. | |
// @author You | |
// @match https://bsky.app/profile/* | |
// @grant GM_xmlhttpRequest | |
// @connect api.shodan.io | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// 1. URL Check & Domain Extraction | |
const url = window.location.href; | |
const profilePath = url.split('/profile/')[1]; | |
if (!profilePath) { | |
console.log("No profile path found in URL."); | |
return; | |
} | |
if (profilePath.includes('.bsky.social')) { | |
console.log("This is a .bsky.social profile, skipping domain lookup."); | |
return; | |
} | |
const domainMatch = profilePath.match(/^([^/]+)/); | |
if (!domainMatch) { | |
console.log("Could not extract domain from URL."); | |
return; | |
} | |
const domain = domainMatch[1]; | |
// 2. Shodan API Call | |
const SHODAN_API_KEY = 'YOUR_SHODAN_API_KEY'; // REPLACE WITH YOUR API KEY! | |
if (SHODAN_API_KEY === 'YOUR_SHODAN_API_KEY') { | |
console.error("Please replace 'YOUR_SHODAN_API_KEY' with your actual Shodan API key."); | |
alert("Please configure the script with your Shodan API key in the script settings"); | |
return; | |
} | |
const apiUrl = `https://api.shodan.io/dns/domain/${domain}?key=${SHODAN_API_KEY}`; | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: apiUrl, | |
onload: function(response) { | |
if (response.status === 200) { | |
try { | |
const data = JSON.parse(response.responseText); | |
console.log("Shodan API Response for", domain, ":", data); | |
} catch (error) { | |
console.error("Error parsing Shodan API response:", error); | |
} | |
} else { | |
console.error("Shodan API request failed with status:", response.status); | |
console.error("Shodan API request failed with response text:", response.responseText); | |
alert(`Shodan API request failed with status: ${response.status}, see the console for more information`); | |
} | |
}, | |
onerror: function(response) { | |
console.error("Shodan API request error:", response); | |
alert("Shodan API request error, check console for details."); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment