2016-07-01 10:33:44 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import random
|
|
|
|
from random import randint
|
|
|
|
import string
|
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
def randomStringGenerator(size, chars=string.ascii_lowercase + string.digits):
|
|
|
|
return ''.join(random.choice(chars) for _ in range(size))
|
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
def randomIpGenerator():
|
|
|
|
return str(randint(0, 255)) + '.' + str(randint(0, 255)) + '.' + str(randint(0, 255)) + '.' + str(randint(0, 255))
|
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
|
|
|
def floodtxt(misp, event, maxlength=255):
|
2016-07-01 10:33:44 +02:00
|
|
|
text = randomStringGenerator(randint(1, maxlength))
|
|
|
|
textfunctions = [misp.add_internal_comment, misp.add_internal_text, misp.add_internal_other, misp.add_email_subject, misp.add_mutex, misp.add_filename]
|
2016-10-12 15:40:49 +02:00
|
|
|
textfunctions[randint(0, 5)](event, text)
|
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
|
|
|
|
def floodip(misp, event):
|
|
|
|
ip = randomIpGenerator()
|
|
|
|
ipfunctions = [misp.add_ipsrc, misp.add_ipdst]
|
2016-10-12 15:40:49 +02:00
|
|
|
ipfunctions[randint(0, 1)](event, ip)
|
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
def flooddomain(misp, event, maxlength=25):
|
2016-07-01 10:33:44 +02:00
|
|
|
a = randomStringGenerator(randint(1, maxlength))
|
|
|
|
b = randomStringGenerator(randint(2, 3), chars=string.ascii_lowercase)
|
|
|
|
domain = a + '.' + b
|
|
|
|
domainfunctions = [misp.add_hostname, misp.add_domain]
|
2016-10-12 15:40:49 +02:00
|
|
|
domainfunctions[randint(0, 1)](event, domain)
|
2016-07-01 10:33:44 +02:00
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
|
|
|
def flooddomainip(misp, event, maxlength=25):
|
2016-07-01 10:33:44 +02:00
|
|
|
a = randomStringGenerator(randint(1, maxlength))
|
|
|
|
b = randomStringGenerator(randint(2, 3), chars=string.ascii_lowercase)
|
|
|
|
domain = a + '.' + b
|
|
|
|
ip = randomIpGenerator()
|
|
|
|
misp.add_domain_ip(event, domain, ip)
|
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
|
|
|
def floodemail(misp, event, maxlength=25):
|
2016-07-01 10:33:44 +02:00
|
|
|
a = randomStringGenerator(randint(1, maxlength))
|
|
|
|
b = randomStringGenerator(randint(1, maxlength))
|
|
|
|
c = randomStringGenerator(randint(2, 3), chars=string.ascii_lowercase)
|
2016-10-12 15:40:49 +02:00
|
|
|
email = a + '@' + b + '.' + c
|
2016-07-01 10:33:44 +02:00
|
|
|
emailfunctions = [misp.add_email_src, misp.add_email_dst]
|
2016-10-12 15:40:49 +02:00
|
|
|
emailfunctions[randint(0, 1)](event, email)
|
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
|
2016-07-01 12:06:49 +02:00
|
|
|
def floodattachment(misp, eventid, distribution, to_ids, category, comment, info, analysis, threat_level_id):
|
2016-10-12 15:40:49 +02:00
|
|
|
filename = randomStringGenerator(randint(1, 128))
|
2016-07-01 10:33:44 +02:00
|
|
|
misp.upload_sample(filename, 'dummy', eventid, distribution, to_ids, category, comment, info, analysis, threat_level_id)
|
|
|
|
|
2016-10-12 15:40:49 +02:00
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
def create_dummy_event(misp):
|
|
|
|
event = misp.new_event(0, 4, 0, 'dummy event')
|
|
|
|
flooddomainip(misp, event)
|
2016-10-12 15:40:49 +02:00
|
|
|
floodattachment(misp, event['Event']['id'], event['Event']['distribution'], False, 'Payload delivery', '', event['Event']['info'], event['Event']['analysis'], event['Event']['threat_level_id'])
|
|
|
|
|
2016-07-01 10:33:44 +02:00
|
|
|
|
|
|
|
def create_massive_dummy_events(misp, nbattribute):
|
|
|
|
event = misp.new_event(0, 4, 0, 'massive dummy event')
|
|
|
|
eventid = event['Event']['id']
|
2018-12-24 20:46:26 +01:00
|
|
|
distribution = '0'
|
2016-07-01 10:33:44 +02:00
|
|
|
functions = [floodtxt, floodip, flooddomain, flooddomainip, floodemail, floodattachment]
|
|
|
|
for i in range(nbattribute):
|
2016-10-12 15:40:49 +02:00
|
|
|
choice = randint(0, 5)
|
2016-07-01 10:33:44 +02:00
|
|
|
if choice == 5:
|
2018-12-24 20:46:26 +01:00
|
|
|
floodattachment(misp, eventid, distribution, False, 'Payload delivery', '', event['Event']['info'], event['Event']['analysis'], event['Event']['threat_level_id'])
|
2016-07-01 10:33:44 +02:00
|
|
|
else:
|
2016-10-12 15:40:49 +02:00
|
|
|
functions[choice](misp, event)
|