NullArray / AutoSploit

Automated Mass Exploiter
GNU General Public License v3.0
5.02k stars 1.13k forks source link

Void shodan library #49

Closed Ekultek closed 6 years ago

Ekultek commented 6 years ago

Would it be an issue to create your own shodan library for this, something along the lines of:

import json
import time
import threading
import base64

import requests

import lib.settings
import lib.output

def get_token(encoded):
    encoded = encoded.strip()
    token, n = encoded.split(":")
    for _ in range(int(n)):
        token = base64.b64decode(token)
    return token

def gather_hosts(query):
    discovered = set()

    try:
        animation_text = "gathering hosts relevant to query {}...".format(query)
        t = threading.Thread(target=lib.settings.animation, args=(animation_text,))
        t.daemon = True
        t.start()

        token = get_token(open(lib.settings.TOKEN_PATH).read())
        req = requests.get(lib.settings.SHODAN_API_LINK.format(key=token, query=query))
        data = json.loads(req.content)
        for match in data["matches"]:
            discovered.add(match["ip_str"])
        file_path = "{}/hosts.lst".format(lib.settings.GATHERED_HOSTS_PATH)
        lib.settings.write_to_file(discovered, file_path)
        output_text = "done, successfully gathered {} hosts".format(len(discovered))
        padding_needed = len(animation_text) - len(output_text)
        lib.output.info(output_text + "{}".format(" " * padding_needed))
        lib.settings.STOP_ANIMATION = True
        return file_path
    except Exception as e:
        lib.output.error("caught exception '{}' while gathering hosts".format(str(e)))
        lib.settings.shutdown()

def view_gathered_hosts(host_file):
    with open(host_file) as hosts:
        for i, host in enumerate(hosts, start=1):
            lib.output.info("[{}] {}".format(i, host.strip()))
    return

That should grab at least 100 IP addresses from shodan

NullArray commented 6 years ago

Well we could. I take it this is to circumvent the limited number of hosts available through the free API?

Ekultek commented 6 years ago

Yeah i was writing a rip off of autosploit to see what I could come up with and what functions we could implement into it earlier and figured out we could use the free API, that way we can use one API key dedicated to this program, saves everyone from putting their own info in and possibly getting tracked

Ekultek commented 6 years ago

I'll take care of this when I get #51 done

Ekultek commented 6 years ago

Going to implement this in with #60

It will probably limit the number of hosts gathered at a time to 100 but using both of the search engines will be freaking awesome

NullArray commented 6 years ago

Agreed Censys support is awesome.

Ekultek commented 6 years ago

Done just need to implement it into the flow