2016-08-18 00:40:30 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from pymisp import PyMISP
|
2017-06-19 16:27:07 +02:00
|
|
|
from keys import misp_url, misp_key,misp_verifycert
|
2016-08-18 00:40:30 +02:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
# Usage for pipe masters: ./last.py -l 5h | jq .
|
|
|
|
|
|
|
|
|
|
|
|
def init(url, key):
|
2017-06-19 16:27:07 +02:00
|
|
|
return PyMISP(url, key, misp_verifycert, 'json', debug=True)
|
2016-08-18 00:40:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
def del_event(m, eventid):
|
|
|
|
result = m.delete_event(eventid)
|
|
|
|
print(result)
|
|
|
|
|
|
|
|
def del_attr(m, attrid):
|
|
|
|
result = m.delete_attribute(attrid)
|
|
|
|
print(result)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = argparse.ArgumentParser(description='Delete an event from a MISP instance.')
|
|
|
|
parser.add_argument("-e", "--event", help="Event ID to delete.")
|
|
|
|
parser.add_argument("-a", "--attribute", help="Attribute ID to delete.")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
misp = init(misp_url, misp_key)
|
|
|
|
|
|
|
|
if args.event:
|
|
|
|
del_event(misp, args.event)
|
|
|
|
else:
|
|
|
|
del_attr(misp, args.attribute)
|