Example #1
0
 def __init__(self, db):
     self.db = db
     self.BaseDomain = BaseDomainRepository(db, self.name)
     self.Domain = DomainRepository(db, self.name)
     self.IPAddress = IPRepository(db, self.name)
     self.CIDR = CIDRRepository(db, self.name)
     self.ScopeCIDR = ScopeCIDRRepository(db, self.name)
Example #2
0
class Report(ReportTemplate):
    """
    This report displays all of the various Base Domains, Domains, and IP Addresses with scoping information
    """

    markdown = ["###", "`"]

    name = "CertReport"

    def __init__(self, db):

        self.IPAddress = IPRepository(db)
        self.Domains = DomainRepository(db)
        self.BaseDomains = BaseDomainRepository(db)
        self.CIDRs = CIDRRepository(db)

    def set_options(self):
        super(Report, self).set_options()

    def run(self, args):

        results = []

        base_domains = self.BaseDomains.all()

        for b in base_domains:
            results.append(
                "%s\tActive Scope: %s\tPassive Scope: %s"
                % (b.domain, b.in_scope, b.passive_scope)
            )

            for d in b.subdomains:
                results.append(
                    "\t%s\tActive Scope: %s\tPassive Scope: %s"
                    % (d.domain, d.in_scope, d.passive_scope)
                )

        cidrs = self.CIDRs.all()

        results.append("\n\n")
        for c in cidrs:
            results.append("%s - %s" % (c.cidr, c.org_name))
            for ip in c.ip_addresses:
                results.append(
                    "\t%s\tActive Scope: %s\tPassive Scope: %s"
                    % (ip.ip_address, ip.in_scope, ip.passive_scope)
                )

        self.process_output(results, args)
Example #3
0
 def __init__(self, db):
     self.BaseDomain = BaseDomainRepository(db)
     self.Domain = DomainRepository(db)
     self.IPAddress = IPRepository(db)
     self.CIDR = CIDRRepository(db)
Example #4
0
class Report(ReportTemplate):
    """
    This report displays all of the CIDR information, as well as the IP addresses and
    associated domains.
    """

    markdown = ["### ", "#### ", "- ", "-- "]

    name = ""

    def __init__(self, db):
        self.BaseDomain = BaseDomainRepository(db)
        self.Domain = DomainRepository(db)
        self.IPAddress = IPRepository(db)
        self.CIDR = CIDRRepository(db)

    def run(self, args):
        # Cidrs = self.CIDR.
        results = {}

        CIDRs = self.CIDR.all()
        for c in CIDRs:

            if results.get(c.org_name, False):
                if not results[c.org_name].get(c.cidr, False):
                    results[c.org_name][c.cidr] = {}
            else:
                results[c.org_name] = {c.cidr: {}}
            for ip in c.ip_addresses:
                if (args.scope == "passive" and ip.passive_scope) or (
                    args.scope == "active" and ip.in_scope) or (
                    args.scope == "all"):
                    results[c.org_name][c.cidr][ip.ip_address] = []
                    for d in ip.domains:
                        if d.passive_scope:
                            results[c.org_name][c.cidr][ip.ip_address].append(d.domain)

        res = []
        if results.get(None, False):
            results[""] = results.pop(None)
        
        # This cleans out any CIDRs that don't have scoped hosts.
        newresults = results.copy()
        for k, v in results.items():
            new_vals = v.copy()
            for c, r in v.items():
                if not r:
                    new_vals.pop(c)
            if not new_vals:
                newresults.pop(k)

        results = newresults.copy()
        
        for cidr in sorted(results.keys()):
            if not cidr:
                res.append("")
            else:
                res.append(cidr)
            for ranges in sorted(results[cidr].keys()):
                res.append("\t" + ranges)
                for ips in sorted(results[cidr][ranges].keys()):
                    res.append("\t\t" + ips)
                    for domain in sorted(results[cidr][ranges][ips]):
                        res.append("\t\t\t" + domain)
        self.process_output(res, args)