Example #1
0
    def import_domains(self):
        print('Importing domains!')
        for domain in self.get_file('domains')['domains']:  #['computers']:
            #pprint.pprint(domain)
            #input()

            di = ADInfo()
            di.name = domain['Name']
            di.objectSid = domain['Properties']['objectsid']

            self.db_session.add(di)
            self.db_session.commit()
            self.db_session.refresh(di)
            self.ad_id = di.id

            self.ads[di.objectSid] = di.id
            self.adn[di.name] = di.id
Example #2
0
 def get_domain_info(self):
     try:
         info = self.ldap.get_ad_info()
         adinfo = ADInfo.from_dict(info.to_dict())
         self.agent_out_q.put((LDAPAgentCommand.DOMAININFO, adinfo))
     except:
         self.agent_out_q.put(
             (LDAPAgentCommand.EXCEPTION, str(traceback.format_exc())))
     finally:
         self.agent_out_q.put((LDAPAgentCommand.DOMAININFO_FINISHED, None))
Example #3
0
	async def get_domain_info(self):
		try:
			info, err = await self.ldap.get_ad_info()
			if err is not None:
				raise err
			adinfo = ADInfo.from_msldap(info)
			await self.agent_out_q.put((LDAPAgentCommand.DOMAININFO, adinfo))
		except:
			await self.agent_out_q.put((LDAPAgentCommand.EXCEPTION, str(traceback.format_exc())))
		finally:
			await self.agent_out_q.put((LDAPAgentCommand.DOMAININFO_FINISHED, None))
Example #4
0
    def get_stored_cred(self, cmd):
        domain = None
        username = None
        password = None

        print(cmd.__dict__)

        if cmd.username is not None and len(cmd.username) > 0:
            username = cmd.username
        if cmd.password is not None and len(cmd.password) > 0:
            password = cmd.password
        if cmd.domain is not None and len(cmd.domain) > 0:
            domain = cmd.domain

        if username == 'auto' and domain is None and cmd.user_ad_id is not None:
            adinfo = ADInfo.get(cmd.user_ad_id)
            domain = adinfo.name

        print(username)
        if username == 'auto' or username is not None:
            return True, domain, username, password

        return self.get_stored_cred_db(cmd.user_ad_id, cmd.user_sid)
Example #5
0
    def import_domains(self):
        gi = GraphInfo('bloodhound import')

        self.db_session.add(gi)
        self.db_session.commit()
        self.db_session.refresh(gi)
        self.graphid = gi.id
        aces = []

        meta = self.get_file('domains')['meta']
        if 'version' in meta:
            logger.debug('[BHIMPORT] Found version info in file!')
            self.bloodhound_version = str(meta['version'])
        logger.debug('[BHIMPORT] Selecting bloodhound file version %s' %
                     self.bloodhound_version)
        total = meta['count']
        for domain in tqdm(
                self.get_file('domains')['domains'],
                desc='Domains ',
                total=total,
                disable=self.disable_print_progress):  #['computers']:
            try:
                if self.debug is True:
                    pretty(domain)
                    input('a')
                di = ADInfo()
                if self.bloodhound_version == '2':
                    di.name = domain['Name']
                    di.objectSid = domain['Properties']['objectsid']
                    di.distinguishedName = 'DC='.join(
                        domain['Name'].split('.'))

                    #not importing: [Properties][functionallevel] , [Properties][description], [Links], [Trusts]

                else:
                    di.name = domain['Properties']['name']
                    di.objectSid = domain['Properties']['objectid']
                    di.distinguishedName = domain['Properties'][
                        'distinguishedname']

                    #not importing: [Properties][functionallevel] , [Properties][description], [ChildOus], [Links], [Trusts]

                self.db_session.add(di)
                self.db_session.commit()
                self.db_session.refresh(di)
                self.ad_id = di.id

                edgeinfo = EdgeLookup(di.id, di.objectSid, 'domain')
                self.db_session.add(edgeinfo)
                self.db_session.commit()

                self.ads[di.objectSid] = di.id
                self.adn[di.name] = di.id

                giad = GraphInfoAD(di.id, self.graphid)
                self.db_session.add(giad)
                self.db_session.commit()

                if domain['Aces'] is not None:
                    aces.append(
                        (di.objectSid, 'domain', domain['Aces'], di.id))

            except Exception as e:
                logger.debug(
                    '[BHIMPORT] Error while processing domain %s Reason: %s' %
                    (domain, e))
                raise e

        for objectSid, ot, aces, adid in aces:
            self.insert_acl(objectSid, ot, aces, adid)

        self.db_session.commit()
        logger.debug('[BHIMPORT] Domain import finished!')
Example #6
0
	def get_domain_info(self):
		info = self.ldap.get_ad_info()
		return ADInfo.from_msldap(info)