示例#1
0
 def do_transform(self, request, response, config):
     maltego_misp_event = request.entity
     # print(dir(maltego_misp_event))
     misp = get_misp_connection(config)
     event_json = misp.get_event(
         maltego_misp_event.id)  # FIXME get it without attachments
     # print(json.dumps(event_json, sort_keys=True, indent=4))
     if not event_json.get('Event'):
         return response
     for e in event_json['Event']['RelatedEvent']:
         response += event_to_entity(e)
     for a in event_json['Event']["Attribute"]:
         for entity in attribute_to_entity(a):
             if entity:
                 response += entity
     for o in event_json['Event']['Object']:
         # LATER unfortunately we cannot automatically expand the objects
         response += object_to_entity(o)
     for g in event_json['Event']['Galaxy']:
         for c in g['GalaxyCluster']:
             response += galaxycluster_to_entity(c)
     if 'Tag' in event_json['Event']:
         for t in event_json['Event']['Tag']:
             # ignore all misp-galaxies
             if t['name'].startswith('misp-galaxy'):
                 continue
             response += Hashtag(t['name'])
     return response
示例#2
0
    def do_transform(self, request, response, config):
        maltego_misp_event = request.entity
        misp = get_misp_connection(config)
        event_json = misp.get_event(maltego_misp_event.id)  # FIXME get it without attachments # FIXME use search + includeAttachments:0, eventid: as request body
        if not event_json.get('Event'):
            return response

        response += event_to_entity(event_json)
        event_tags = []
        if 'Tag' in event_json['Event']:
            for t in event_json['Event']['Tag']:
                event_tags.append(t['name'])
                # ignore all misp-galaxies
                if t['name'].startswith('misp-galaxy'):
                    continue
                # ignore all those we add as notes
                if tag_matches_note_prefix(t['name']):
                    continue
                response += Hashtag(t['name'])
        for g in event_json['Event']['Galaxy']:
            for c in g['GalaxyCluster']:
                response += galaxycluster_to_entity(c)

        for a in event_json['Event']["Attribute"]:
            for entity in attribute_to_entity(a, event_tags=event_tags):
                if entity:
                    response += entity

        for o in event_json['Event']['Object']:
            response += object_to_entity(o)
        return response
    def do_transform(self, request, response, config):
        maltego_misp_event = request.entity
        misp = get_misp_connection(config)
        event_json = misp.get_event(maltego_misp_event.id)  # FIXME get it without attachments # FIXME use search + includeAttachments:0, eventid: as request body
        if not event_json.get('Event'):
            return response

        response += event_to_entity(event_json)
        event_tags = []
        if 'Tag' in event_json['Event']:
            for t in event_json['Event']['Tag']:
                event_tags.append(t['name'])
                # ignore all misp-galaxies
                if t['name'].startswith('misp-galaxy'):
                    continue
                # ignore all those we add as notes
                if tag_matches_note_prefix(t['name']):
                    continue
                response += Hashtag(t['name'])
        for g in event_json['Event']['Galaxy']:
            for c in g['GalaxyCluster']:
                response += galaxycluster_to_entity(c)

        # for e in event_json['Event']['RelatedEvent']:
        #     response += event_to_entity(e, link_style=LinkStyle.DashDot)

        for a in event_json['Event']["Attribute"]:
            for entity in attribute_to_entity(a, event_tags=event_tags):
                if entity:
                    response += entity

        for o in event_json['Event']['Object']:
            # LATER unfortunately we cannot automatically expand the objects
            response += object_to_entity(o)
        return response
示例#4
0
    def do_transform(self, request, response, config):
        response += check_update(config)
        # skip some Entities
        skip = ['properties.mispevent']
        for i in skip:
            if i in request.entity.fields:
                return response

        if 'ipv4-range' in request.entity.fields:
            # placeholder for https://github.com/MISP/MISP-maltego/issues/11
            pass

        misp = get_misp_connection(config, request.parameters)
        # from Galaxy
        if 'properties.mispgalaxy' in request.entity.fields:
            tag_name = get_entity_property(request.entity, 'tag_name')
            if not tag_name:
                tag_name = request.entity.value
            events_json = misp.search(controller='events', tags=tag_name, with_attachments=False)
            for e in events_json:
                response += event_to_entity(e, link_direction=LinkDirection.OutputToInput)
            return response
        # from Object
        elif 'properties.mispobject' in request.entity.fields:
            if request.entity.fields.get('event_id'):
                events_json = misp.search(controller='events', eventid=request.entity.fields.get('event_id').value,
                                          with_attachments=False)
                for e in events_json:
                    response += event_to_entity(e, link_direction=LinkDirection.OutputToInput)
                return response
            else:
                return response
        # from Hashtag
        elif 'properties.temp' in request.entity.fields:
            tag_name = get_entity_property(request.entity, 'Temp')
            if not tag_name:
                tag_name = request.entity.value
            events_json = misp.search(controller='events', tags=tag_name, with_attachments=False)
            for e in events_json:
                response += event_to_entity(e, link_direction=LinkDirection.OutputToInput)
            return response
        # standard Entities (normal attributes)
        else:
            events_json = misp.search(controller='events', value=request.entity.value, with_attachments=False)

        # return the MISPEvent or MISPObject of the attribute
        for e in events_json:
            # find the value as attribute
            attr = get_attribute_in_event(e, request.entity.value)
            if attr:
                response += event_to_entity(e, link_direction=LinkDirection.OutputToInput)
            # find the value as object
            if 'Object' in e['Event']:
                for o in e['Event']['Object']:
                    if get_attribute_in_object(o, attribute_value=request.entity.value).get('value'):
                        response += object_to_entity(o, link_direction=LinkDirection.OutputToInput)

        return response
示例#5
0
 def gen_response_objects(self):
     for o in self.event_json['Event']['Object']:
         self.response += object_to_entity(o)