Esempio n. 1
0
    def run(self, collect, num_workers=10):
        if 'group' in collect:
            # Fetch domains/computers for later
            self.pdc.prefetch_info()
            # Initialize enumerator
            membership_enum = MembershipEnumerator(self.ad, self.pdc)
            membership_enum.enumerate_memberships()
        elif 'localadmin' in collect or 'session' in collect:
            # We need to know which computers to query regardless
            # We also need the domains to have a mapping from NETBIOS -> FQDN for local admins
            self.pdc.prefetch_info()
        elif 'trusts' in collect:
            # Prefetch domains
            self.pdc.get_domains()
        if 'trusts' in collect:
            trusts_enum = TrustsEnumerator(self.ad, self.pdc)
            trusts_enum.dump_trusts()
        if 'localadmin' in collect or 'session' in collect:
            # If we don't have a GC server, don't use it for deconflictation
            have_gc = len(self.ad.gcs()) > 0
            computer_enum = ComputerEnumerator(self.ad,
                                               collect,
                                               do_gc_lookup=have_gc)
            computer_enum.enumerate_computers(self.ad.computers,
                                              num_workers=num_workers)

        logging.info('Done')
Esempio n. 2
0
 def run(self, collect, num_workers=10, disable_pooling=False):
     start_time = time.time()
     if 'group' in collect or 'objectprops' in collect or 'acl' in collect:
         # Fetch domains/computers for later
         self.pdc.prefetch_info('objectprops' in collect, 'acl' in collect)
         # Initialize enumerator
         membership_enum = MembershipEnumerator(self.ad, self.pdc, collect,
                                                disable_pooling)
         membership_enum.enumerate_memberships()
     elif any(method in collect for method in [
             'localadmin', 'session', 'loggedon', 'experimental', 'rdp',
             'dcom', 'psremote'
     ]):
         # We need to know which computers to query regardless
         # We also need the domains to have a mapping from NETBIOS -> FQDN for local admins
         self.pdc.prefetch_info('objectprops' in collect, 'acl' in collect)
     elif 'trusts' in collect:
         # Prefetch domains
         self.pdc.get_domains('acl' in collect)
     if 'trusts' in collect or 'acl' in collect or 'objectprops' in collect:
         trusts_enum = DomainEnumerator(self.ad, self.pdc)
         trusts_enum.dump_domain(collect)
     if 'localadmin' in collect or 'session' in collect or 'loggedon' in collect or 'experimental' in collect:
         # If we don't have a GC server, don't use it for deconflictation
         have_gc = len(self.ad.gcs()) > 0
         computer_enum = ComputerEnumerator(self.ad,
                                            self.pdc,
                                            collect,
                                            do_gc_lookup=have_gc)
         computer_enum.enumerate_computers(self.ad.computers,
                                           num_workers=num_workers)
     end_time = time.time()
     minutes, seconds = divmod(int(end_time - start_time), 60)
     logging.info('Done in %02dM %02dS' % (minutes, seconds))
Esempio n. 3
0
    def run(self,
            skip_groups=False,
            skip_computers=False,
            skip_trusts=False,
            num_workers=10):
        if not skip_groups:
            self.pdc.fetch_all()
            membership_enum = MembershipEnumerator(self.ad, self.pdc)
            membership_enum.enumerate_memberships()
        elif not skip_computers:
            # We need to know which computers to query regardless
            self.pdc.get_computers()
            # We also need the domains to have a mapping from NETBIOS -> FQDN for local admins
            self.pdc.get_domains()
            self.pdc.get_forest_domains()
        if not skip_trusts:
            self.pdc.dump_trusts()
        if not skip_computers:
            computer_enum = ComputerEnumerator(self.ad)
            computer_enum.enumerate_computers(self.ad.computers,
                                              num_workers=num_workers)

        logging.info('Done')