How to use the shodan.cli.converter.base.Converter function in shodan

To help you get started, we’ve selected a few shodan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achillean / shodan-python / shodan / cli / converter / images.py View on Github external
from .base import Converter
from ...helpers import iterate_files, get_ip, get_screenshot

# Needed for decoding base64-strings in Python3
from codecs import decode

import os


class ImagesConverter(Converter):

    # The Images converter is special in that it creates a directory and there's
    # special code in the Shodan CLI that relies on the "dirname" property to let
    # the user know where the images have been stored.
    dirname = None

    def process(self, files):
        # Get the filename from the already-open file handle and use it as
        # the directory name to store the images.
        self.dirname = self.fout.name[:-7] + '-images'

        # Remove the original file that was created
        self.fout.close()
        os.unlink(self.fout.name)

        # Create the directory if it doesn't yet exist
github achillean / shodan-python / shodan / cli / converter / kml.py View on Github external
from .base import Converter
from ...helpers import iterate_files


class KmlConverter(Converter):

    def header(self):
        self.fout.write("""

  """)

    def footer(self):
        self.fout.write("""""")

    def process(self, files):
        # Write the header
        self.header()

        hosts = {}
        for banner in iterate_files(files):
            ip = banner.get('ip_str', banner.get('ipv6', None))
github achillean / shodan-python / shodan / cli / converter / excel.py View on Github external
from .base import Converter
from ...helpers import iterate_files, get_ip

from collections import defaultdict
from xlsxwriter import Workbook


class ExcelConverter(Converter):

    fields = [
        'port',
        'timestamp',
        'data',
        'hostnames',
        'org',
        'isp',
        'location.country_name',
        'location.country_code',
        'location.city',
        'os',
        'asn',
        'transport',
        'product',
        'version',
github achillean / shodan-python / shodan / cli / converter / geojson.py View on Github external
from .base import Converter
from ...helpers import get_ip, iterate_files


class GeoJsonConverter(Converter):

    def header(self):
        self.fout.write("""{
            "type": "FeatureCollection",
            "features": [
        """)

    def footer(self):
        self.fout.write("""{ }]}""")

    def process(self, files):
        # Write the header
        self.header()

        hosts = {}
        for banner in iterate_files(files):
github achillean / shodan-python / shodan / cli / converter / csvc.py View on Github external
from .base import Converter
from ...helpers import iterate_files

from collections import MutableMapping
from csv import writer as csv_writer, excel


class CsvConverter(Converter):

    fields = [
        'data',
        'hostnames',
        'ip',
        'ip_str',
        'ipv6',
        'org',
        'isp',
        'location.country_code',
        'location.city',
        'location.country_name',
        'location.latitude',
        'location.longitude',
        'os',
        'asn',