Exemple #1
0
    def run(self, target, args, smb_con, loggers, config_obj):
        logger = loggers['console']
        try:
            x = LdapCon(args.user, args.passwd, args.hash, args.domain,
                        args.ldap_srv, args.timeout)
            x.create_ldap_con()
            dc_data = x.custom_query(
                '(userAccountControl:1.2.840.113556.1.4.803:=8192)',
                ATTRIBUTES['cpu'])
            x.close()
        except Exception as e:
            logger.debug("{} Error: {}".format(self.name, str(e)))

        if x.data:
            for srv, data in dc_data.items():
                logger.success([
                    smb_con.host, smb_con.ip,
                    self.name.upper(),
                    "{:<20} OS: {}".format(srv, data['operatingSystem'])
                ])
        else:
            logger.fail([
                smb_con.host, smb_con.ip,
                self.name.upper(), "No data returned".format(self.name)
            ])
Exemple #2
0
def main(args, config_obj, db_obj, loggers):
    logger = loggers['console']
    try:
        query = LdapCon(args.user, args.passwd, args.hash, args.domain,
                        args.srv, args.timeout)
        query.create_ldap_con()
        logger.success([
            'LDAP Connection',
            'Connection established (server: {}) (LDAPS: {})'.format(
                query.host, query.ldaps)
        ])

        # Users
        if args.lookup_type in ['user', 'users']:
            resp = query.user_query(args.query, args.attrs)

        # Groups
        elif args.lookup_type in ['group', 'groups']:
            if args.query:
                resp = query.group_membership(args.query, args.attrs)
            else:
                resp = query.group_query(args.attrs)

        # Computers
        elif args.lookup_type in ['computer', 'computers']:
            resp = query.computer_query(args.query, args.attrs)

        # Domain
        elif args.lookup_type == 'domain':
            resp = query.domain_query(args.attrs)

        # Trust
        elif args.lookup_type == 'trust':
            resp = query.trust_query(args.attrs)

        # Custom
        elif args.lookup_type == 'custom':
            resp = query.custom_query(args.query, args.attrs)

        else:
            logger.fail(
                "Invalid query operation:\n\t"
                "activereign query {user|group|computer|domain|trust|custom} -u {user} -p {password} -d {domain} -s {server}\n\t"
                "activereign query {user|group|computer|domain|trust|custom} -q {lookup value} -a {attributes} -id {credID}"
            )

        # Display results
        if args.lookup_type and resp:
            format_data(logger, resp, args.lookup_type, args.query, args.attrs,
                        args.resolve, args.debug)

        query.close()
    except Exception as e:
        if "invalidCredentials" in str(e):
            logger.fail(["LDAP Error", "Authentication failed"])
        else:
            logger.fail(["LDAP Error", str(e)])