mirror of https://github.com/MISP/PyMISP
fix: Create massive event using ExpandedPyMISP
parent
a3108f7689
commit
4c9e6d0ec8
|
@ -1,8 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pymisp import PyMISP
|
from pymisp import ExpandedPyMISP
|
||||||
from keys import url, key
|
try:
|
||||||
|
from keys import url, key
|
||||||
|
except ImportError:
|
||||||
|
url = 'http://localhost:8080'
|
||||||
|
key = '8h0gHbhS0fv6JUOlTED0AznLXFbf83TYtQrCycqb'
|
||||||
import argparse
|
import argparse
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
|
@ -13,7 +17,7 @@ if __name__ == '__main__':
|
||||||
parser.add_argument("-a", "--attribute", type=int, help="Number of attributes per event (default 3000)")
|
parser.add_argument("-a", "--attribute", type=int, help="Number of attributes per event (default 3000)")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
misp = PyMISP(url, key, True, 'json')
|
misp = ExpandedPyMISP(url, key, True)
|
||||||
|
|
||||||
if args.limit is None:
|
if args.limit is None:
|
||||||
args.limit = 1
|
args.limit = 1
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import random
|
import random
|
||||||
from random import randint
|
from random import randint
|
||||||
import string
|
import string
|
||||||
|
from pymisp import MISPEvent
|
||||||
|
|
||||||
|
|
||||||
def randomStringGenerator(size, chars=string.ascii_lowercase + string.digits):
|
def randomStringGenerator(size, chars=string.ascii_lowercase + string.digits):
|
||||||
|
@ -63,13 +64,16 @@ def create_dummy_event(misp):
|
||||||
|
|
||||||
|
|
||||||
def create_massive_dummy_events(misp, nbattribute):
|
def create_massive_dummy_events(misp, nbattribute):
|
||||||
event = misp.new_event(0, 4, 0, 'massive dummy event')
|
event = MISPEvent()
|
||||||
eventid = event['Event']['id']
|
event.info = 'massive dummy event'
|
||||||
|
event = misp.add_event(event)
|
||||||
|
print(event)
|
||||||
|
eventid = event.id
|
||||||
distribution = '0'
|
distribution = '0'
|
||||||
functions = [floodtxt, floodip, flooddomain, flooddomainip, floodemail, floodattachment]
|
functions = [floodtxt, floodip, flooddomain, flooddomainip, floodemail, floodattachment]
|
||||||
for i in range(nbattribute):
|
for i in range(nbattribute):
|
||||||
choice = randint(0, 5)
|
choice = randint(0, 5)
|
||||||
if choice == 5:
|
if choice == 5:
|
||||||
floodattachment(misp, eventid, distribution, False, 'Payload delivery', '', event['Event']['info'], event['Event']['analysis'], event['Event']['threat_level_id'])
|
floodattachment(misp, eventid, distribution, False, 'Payload delivery', '', event.info, event.analysis, event.threat_level_id)
|
||||||
else:
|
else:
|
||||||
functions[choice](misp, event)
|
functions[choice](misp, event)
|
||||||
|
|
Loading…
Reference in New Issue