Exemplo n.º 1
0
    def create_daily_event(self):
        today = str(datetime.date.today())
        event_dict = {
            'id': len(self.manifest) + 1,
            'Tag': settings.Tag,
            'info': self.daily_event_name.format(today),
            'analysis': settings.analysis,  # [0-2]
            'threat_level_id': settings.threat_level_id,  # [1-4]
            'published': settings.published,
            'date': today
        }
        event = MISPEvent()
        event.from_dict(**event_dict)

        # reference org
        org = MISPOrganisation()
        org.name = settings.org_name
        org.uuid = settings.org_uuid
        event.Orgc = org

        # save event on disk
        self.flush_event(new_event=event)
        # add event to manifest
        self.manifest.update(event.manifest)
        self.save_manifest()
        return event
Exemplo n.º 2
0
 def test_feed(self):
     me = MISPEvent()
     me.info = 'Test feed'
     org = MISPOrganisation()
     org.name = 'TestOrg'
     org.uuid = '123478'
     me.Orgc = org
     me.add_attribute('ip-dst', '8.8.8.8')
     obj = me.add_object(name='file')
     obj.add_attributes('filename', *['foo.exe', 'bar.exe'])
     h = hashlib.new('md5')
     h.update(b'8.8.8.8')
     hash_attr_val = h.hexdigest()
     feed = me.to_feed(with_meta=True)
     self.assertEqual(feed['Event']['_hashes'][0], hash_attr_val)
     self.assertEqual(feed['Event']['_manifest'][me.uuid]['info'], 'Test feed')
     self.assertEqual(len(feed['Event']['Object'][0]['Attribute']), 2)
Exemplo n.º 3
0
    def import_all(self, stations_short_names, interval, data_type):
        object_creator = getattr(self, f'{interval}_flask_{data_type}')
        if data_type == 'co2':
            base_url = 'https://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/'
        elif data_type in ['c13', 'o18']:
            base_url = 'https://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_isotopic/'
        for station in stations_short_names:
            url = f'{base_url}/{interval}/{interval}_flask_{data_type}_{station}.csv'
            infofield = f'[{station.upper()}] {interval} average atmospheric {data_type} concentrations'
            filepath = self.fetch(url)
            if not filepath:
                continue
            if infofield in self.scrippts_meta:
                event = MISPEvent()
                event.load_file(str(self.output_dir / self.scrippts_meta[infofield]))
                location = event.get_objects_by_name('geolocation')[0]
                update = True
            else:
                event = MISPEvent()
                event.uuid = str(uuid4())
                event.info = infofield
                event.Orgc = self.misp_org
                event.add_tag(getattr(self, f'tag_{station}')())
                location = getattr(self, f'geolocation_{station}')()
                event.add_object(location)
                event.add_attribute('link', f'https://scrippsco2.ucsd.edu/data/atmospheric_co2/{station}')
                update = False
                with self.scrippts_meta_file.open('a') as f:
                    writer = csv.writer(f)
                    writer.writerow([infofield, f'{event.uuid}.json'])

            object_creator(event, location, filepath, update)
            if update:
                # Bump the publish timestamp
                event.publish_timestamp = datetime.datetime.timestamp(datetime.datetime.now())
            feed_output = event.to_feed(with_meta=False)
            with (self.output_dir / f'{event.uuid}.json').open('w') as f:
                # json.dump(feed_output, f, indent=2, sort_keys=True)  # For testing
                json.dump(feed_output, f)
Exemplo n.º 4
0
urlVap = "https://tap-api-v2.proofpoint.com/v2/people/vap?window=30"  # Window can be 14, 30, and 90 Days

headers = {'Authorization': "Basic " + proofpoint_key}

responseVap = requests.request("GET", urlVap, headers=headers)

jsonDataVap = json.loads(responseVap.text)

for alert in jsonDataVap["users"]:
    orgc = MISPOrganisation()
    orgc.name = 'Proofpoint'
    orgc.id = '#{ORGC.ID}'  # organisation id
    orgc.uuid = '#{ORGC.UUID}'  # organisation uuid
    # initialize and set MISPEvent()
    event = MISPEvent()
    event.Orgc = orgc
    event.info = 'Very Attacked Person ' + jsonDataVap["interval"]
    event.distribution = 0  # Optional, defaults to MISP.default_event_distribution in MISP config
    event.threat_level_id = 2  # setting this to 0 breaks the integration
    event.analysis = 0  # Optional, defaults to 0 (initial analysis)

    totalVapUsers = event.add_attribute('counter',
                                        jsonDataVap["totalVapUsers"],
                                        comment="Total VAP Users")

    averageAttackIndex = event.add_attribute('counter',
                                             jsonDataVap["averageAttackIndex"],
                                             comment="Average Attack Count")

    vapAttackIndexThreshold = event.add_attribute(
        'counter',