Beispiel #1
0
json_import = sys.argv[1]
event_import_org = sys.argv[2]
event_import_uuid = str(uuid.uuid4())  # Unique ID
event_import_date = date.today()  # Create event with current data
event_import_distribution = 2  # Connected

# Check if organisation already exist
org = MISPOrganisation()
try:
    org.id = api.get_organisation(event_import_org, pythonify=True).id
except:
    # We need to create a new one
    org_new = MISPOrganisation()
    org_new.name = event_import_org
    org_new.uuid = str(uuid.uuid4())
    org_new.type = "CSIRT"
    org_new.sector = "Government"
    org.id = api.add_organisation(org_new, pythonify=True).id

# Create the MISP event by loading the JSON file
# This will not add the attributes, but does add the event tags and galaxies
# We also add a random UUID for uniqueness
event = MISPEvent()
event.load_file(json_import)
event.uuid = event_import_uuid
if not event_import_info:
    event_import_info = event.info
event.info = event_import_info
event.date = event_import_date
event.distribution = event_import_distribution
event.orgc = api.get_organisation(org, pythonify=True)
Beispiel #2
0
    misp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert)

    # CSV format
    #   orgname,nationality,sector,type,contacts,uuid,local,sharingroup
    with open(args.csv_import) as csv_file:
        count_orgs = 0
        csv_reader = csv.reader(csv_file, delimiter=',')
        for row in csv_reader:

            org = MISPOrganisation()
            org.name = row[0]
            print("Process {}".format(org.name))
            org.nationality = row[1]
            org.sector = row[2]
            org.type = row[3]
            org.contacts = row[4]
            org.uuid = row[5]
            org.local = row[6]

            add_org = misp.add_organisation(org, pythonify=True)

            if 'errors' in add_org:
                print(add_org['errors'])
            else:
                count_orgs = count_orgs + 1
                org_uuid = add_org.uuid

                if org_uuid:
                    sharinggroup = MISPSharingGroup()
                    sharinggroup_uuid = row[7]