Code Monkey home page Code Monkey logo

cloudcheck's Introduction

CloudCheck

A simple Python utility to check whether an IP address or hostname belongs to a cloud provider.

cloud_providers.json contains lists of domains and up-to-date CIDRs for each cloud provider (updated daily via CI/CD).

Used by Bighuge BLS OSINT Tool (BBOT).

Installation

pip install cloudcheck

Usage - CLI

$ cloudcheck 168.62.20.37
168.62.20.37 belongs to Azure (cloud) (168.62.0.0/19)

$ cloudcheck test.evilcorp.azurewebsites.net
test.evilcorp.azurewebsites.net belongs to Azure (cloud) (azurewebsites.net)

Usage - Python

import cloudcheck

provider, provider_type, subnet = cloudcheck.check("168.62.20.37")
print(provider) # "Azure"
print(provider_type) # "cloud"
print(subnet) # IPv4Network('168.62.0.0/19')

Supported cloud providers

cloudcheck's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar oxcbr2 avatar thetechromancer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloudcheck's Issues

Support Domains

It would be great to have a separate pipeline to scrape domains for each cloud provider.

Tracking domains in cloudcheck would offload the effort and relieve the burden of having to do it in BBOT.

Implement radix tree

import ipaddress

class RadixTreeNode:
    def __init__(self):
        self.children = {}
        self.network = None

class RadixTree:
    def __init__(self):
        self.root = RadixTreeNode()

    def insert(self, network):
        node = self.root
        for bit in self._network_to_binary(network):
            if bit not in node.children:
                node.children[bit] = RadixTreeNode()
            node = node.children[bit]
        node.network = ipaddress.ip_network(network)

    def search(self, ip_address):
        node = self.root
        matched_network = None
        ip_addr_obj = ipaddress.ip_address(ip_address)  # Convert string to ip_address object
        for bit in self._ip_to_binary(ip_addr_obj):
            if bit in node.children:
                node = node.children[bit]
                if node.network:
                    matched_network = node.network
            else:
                break
        return matched_network if matched_network and ip_addr_obj in matched_network else None

    def _network_to_binary(self, network):
        net = ipaddress.ip_network(network)
        bin_str = ''.join(format(octet, '08b') for octet in net.network_address.packed)
        return bin_str[:net.prefixlen]

    def _ip_to_binary(self, ip_address):
        return ''.join(format(octet, '08b') for octet in ip_address.packed)

# Example usage
rt = RadixTree()
rt.insert("192.168.1.0/24")
print(rt.search("192.168.1.10"))  # Should return 192.168.1.0/24
print(rt.search("192.168.2.10"))  # Should return None

SQLite database is locked

2023-02-14 19:22:39,010 [ERROR] bbot.scanner.manager manager.py:312 Error in ScanManager._emit_event(): database is locked
2023-02-14 19:22:39,011 [TRACE] bbot.scanner.manager manager.py:313 Traceback (most recent call last):
  File "/root/bbot/bbot/scanner/manager.py", line 306, in catch
    ret = callback(*args, **kwargs)
  File "/root/bbot/bbot/scanner/manager.py", line 134, in _emit_event
    ) = self.scan.helpers.dns.resolve_event(event, minimal=not self.dns_resolution)
  File "/root/bbot/bbot/core/helpers/dns.py", line 219, in resolve_event
    result = self._resolve_event(event, minimal=minimal)
  File "/root/bbot/bbot/core/helpers/dns.py", line 326, in _resolve_event
    provider, subnet = cloudcheck.check(ip)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/cloudcheck/cloudcheck.py", line 54, in check
    providers = CloudProviders()
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/cloudcheck/cloudcheck.py", line 23, in __init__
    provider = p(*args, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/cloudcheck/providers.py", line 23, in __init__
    self.ranges = CidrRanges(self.get_ranges())
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/cloudcheck/providers.py", line 27, in get_ranges
    response = self.session.get(self.main_url, allow_redirects=True)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/session.py", line 115, in request
    return super().request(method, url, *args, **kwargs)
  File "/usr/lib/python3.9/functools.py", line 387, in _method
    return self.func(cls_or_self, *self.args, *args, **keywords)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/session.py", line 147, in send
    response = self._send_and_cache(request, actions, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/session.py", line 193, in _send_and_cache
    self.cache.save_response(response, actions.cache_key, actions.expires)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/backends/base.py", line 103, in save_response
    self.responses[cache_key] = cached_response
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/backends/sqlite.py", line 268, in __setitem__
    super().__setitem__(key, serialized_value)
  File "/root/.cache/pypoetry/virtualenvs/bbot-aKeTQkGo-py3.9/lib/python3.9/site-packages/requests_cache/backends/sqlite.py", line 220, in __setitem__
    con.execute(
sqlite3.OperationalError: database is locked

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.