Created
March 15, 2019 16:23
-
-
Save bromiley/a203ad3a8ce4a894f733f528c6030d8f to your computer and use it in GitHub Desktop.
Python script to import tasks in bulk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
task_import.py - A script to ingest a mass data set and create tasks out of it. | |
Author: Matt Bromiley (@mbromileyDFIR) | |
To Do: | |
""" | |
# Future Imports | |
from __future__ import print_function | |
from __future__ import unicode_literals | |
# TheHive4Py Imports | |
from thehive4py.api import TheHiveApi | |
from thehive4py.models import CaseTask | |
# Server variables | |
hiveServer = '<thehive server>' | |
hiveKey = '<api_key>' | |
# Establish API | |
api = TheHiveApi(hiveServer, hiveKey) | |
with open(sys.argv[1]) as f: | |
for line in f: | |
j = json.loads(line) | |
task = CaseTask( | |
title = j['title_data'], | |
description = j['description_data'], | |
group = j['group_data'] | |
) | |
api.create_case_task(<case_id>, task) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment