Shodan IP Extractor

Extract and copy IP addresses from Shodan search results

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Shodan IP Extractor
// @namespace    https://github.com/dan098/shodanpuller
// @version      1.0
// @description  Extract and copy IP addresses from Shodan search results
// @author       Dan098
// @match        https://www.shodan.io/search*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function extractIPsFromHostLinks() {
        const hostLinks = document.querySelectorAll('a[href^="/host/"]');
        const ips = Array.from(hostLinks).map(link => link.getAttribute('href').split('/').pop());
        return [...new Set(ips)].join('\n');
    }

    function copyIPs() {
        const ips = extractIPsFromHostLinks();
        if (ips) {
            GM_setClipboard(ips);
            alert('IP addresses extracted from host links copied to clipboard:\n\n' + ips);
        } else {
            alert('No IP addresses found in host links.');
        }
    }

    function goToNextPage() {
        const nextButton = document.querySelector('.pagination a.button:last-child');
        if (nextButton && nextButton.textContent.trim() === 'Next') {
            nextButton.click();
        } else {
            alert('No next page button found.');
        }
    }

    function copyAndGoNext() {
        copyIPs();
        setTimeout(goToNextPage, 500); // Delay to ensure the alert is shown before navigating
    }

    function createButton(text, onClick) {
        const button = document.createElement('button');
        button.textContent = text;
        button.style.marginLeft = '10px';
        button.addEventListener('click', onClick);
        return button;
    }

    // Create and add buttons
    const navbar = document.querySelector('.navbar');
    if (navbar) {
        const copyButton = createButton('Copy IPs', copyIPs);
        const copyAndNextButton = createButton('Copy IPs & Next', copyAndGoNext);
        navbar.appendChild(copyButton);
        navbar.appendChild(copyAndNextButton);
    }
})();