Skip to content

Instantly share code, notes, and snippets.

@n0x08
Last active February 25, 2021 11:19
Show Gist options
  • Select an option

  • Save n0x08/0f793b26ce922ae0865fd7d02fe5682f to your computer and use it in GitHub Desktop.

Select an option

Save n0x08/0f793b26ce922ae0865fd7d02fe5682f to your computer and use it in GitHub Desktop.

Revisions

  1. n0x08 revised this gist Jun 4, 2018. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions shoGrey_ip.py
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@
    #
    # Stupid simple IP lookup against Greynoise.io
    # Also looks up against Shodan and returns ports, tags, vulns
    # requires pygments, json, requests
    # requires json, requests, shodan
    #
    # Also requires Shodan Enterprise API key
    # Also requires Shodan API key
    #
    # Example: python3 shoGrey_ip.py 1.2.3.4
    #
    @@ -14,7 +14,6 @@
    import requests
    import shodan


    headers = {'key': '[INSERT GREYNOISE API KEY HERE]'}
    SHODAN_API_KEY = "[INSERT SHODAN API HERE]"

  2. n0x08 revised this gist Jun 4, 2018. 1 changed file with 14 additions and 7 deletions.
    21 changes: 14 additions & 7 deletions shoGrey_ip.py
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,25 @@
    # !/usr/bin/env python
    # gn_ip.py
    # shoGrey_ip.py
    #
    # Stupid simple IP lookup against Greynoise.io
    # Also looks up against Shodan and returns ports, tags, vulns
    # requires pygments, json, requests
    #
    # Also requires Shodan Enterprise API key
    #
    # Example: python3 shoGrey_ip.py 1.2.3.4
    #
    import sys
    import json
    import requests
    import shodan
    import pygments
    from pygments import highlight
    from pygments.lexers import YamlLexer
    from pygments.formatters import TerminalFormatter


    headers = {'key': '[INSERT GREYNOISE API KEY HERE]'}
    SHODAN_API_KEY = "[INSERT SHODAN API HERE]"

    api = shodan.Shodan(SHODAN_API_KEY)
    bots = {}

    ip = sys.argv[1]

    @@ -34,8 +34,15 @@
    data['shodan_tags'] = tags
    data['vulns'] = vulns
    data['open_ports'] = ports
    # Compare open Shodan ports against GN scan ports to find bots
    for i in data['raw_data'].get('scan'):
    if i['port'] in host['ports']:
    key = i['port']
    bots[key] = 'True'
    data['bots'] = bots

    except:
    pass

    json_str = json.dumps(data, indent=4, sort_keys=True)
    print(highlight(json_str, YamlLexer(), TerminalFormatter()))
    json_str = json.dumps(data, indent=4, sort_keys=False)
    print(json_str)
  3. n0x08 revised this gist May 11, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shoGrey_ip.py
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # Also looks up against Shodan and returns ports, tags, vulns
    # requires pygments, json, requests
    #
    # Example: python3 gn_ip.py 1.2.3.4
    # Example: python3 shoGrey_ip.py 1.2.3.4
    #
    import sys
    import json
  4. n0x08 created this gist May 11, 2018.
    41 changes: 41 additions & 0 deletions shoGrey_ip.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    # !/usr/bin/env python
    # gn_ip.py
    #
    # Stupid simple IP lookup against Greynoise.io
    # Also looks up against Shodan and returns ports, tags, vulns
    # requires pygments, json, requests
    #
    # Example: python3 gn_ip.py 1.2.3.4
    #
    import sys
    import json
    import requests
    import shodan
    import pygments
    from pygments import highlight
    from pygments.lexers import YamlLexer
    from pygments.formatters import TerminalFormatter

    headers = {'key': '[INSERT GREYNOISE API KEY HERE]'}
    SHODAN_API_KEY = "[INSERT SHODAN API HERE]"

    api = shodan.Shodan(SHODAN_API_KEY)

    ip = sys.argv[1]

    gnr = requests.get('https://enterprise.api.greynoise.io/v2/noise/context/' + ip, headers = headers) #V2 IP API lookup
    data = gnr.json()

    try:
    host = api.host(ip)
    tags = host['tags']
    vulns = host['vulns']
    ports = host['ports']
    data['shodan_tags'] = tags
    data['vulns'] = vulns
    data['open_ports'] = ports
    except:
    pass

    json_str = json.dumps(data, indent=4, sort_keys=True)
    print(highlight(json_str, YamlLexer(), TerminalFormatter()))