File size: 1,168 Bytes
7c89ed7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python

import time
import optparse

import mozdef_client as mozdef

parser = optparse.OptionParser()
parser.add_option('--loginput_host', help='MozDef Loginput host (default: http://127.0.0.1:8080)', default='http://127.0.0.1:8080')
parser.add_option('--num_times', help='Number of times event is sent to loginput (default: 20)', default=20)
options, arguments = parser.parse_args()

# Fill in with events you want to write
events = [
    {
        "category": "testcategory",
        "details": {
            "program": "sshd",
            "type": "Success Login",
            "username": "ttesterson",
            "sourceipaddress": '1.2.3.4',
        },
        "processname": "auth0_cron",
        "severity": "INFO",
        "source": "auth0",
        "summary": "login invalid ldap_count_entries failed",
        "tags": ["auth0"],
    }
]

for num in range(0, options.num_times):
    for event in events:
        mozmsg = mozdef.MozDefEvent(options.loginput_host + "/events/")
        for key, value in event.items():
            setattr(mozmsg, key, value)
        mozmsg.send()
        print("Wrote event to loginput")
        time.sleep(0.2)