示例#1
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
示例#3
0
 def gen_response_tags(self, gen_response=True):
     self.event_tags = []
     if 'Tag' in self.event_json['Event']:
         for t in self.event_json['Event']['Tag']:
             self.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
             if gen_response:
                 self.response += Hashtag(t['name'])