Skip to content
Snippets Groups Projects
kibana_graphs2template.py 677 B
#!/usr/bin/env python

import argparse,re

parser = argparse.ArgumentParser()
parser.add_argument("graphsfile", help="input kibana_graphs.ndjson file")
parser.add_argument("templatefile", help="output template file")
args = parser.parse_args()

r=open(args.graphsfile,"r")
w=open(args.templatefile,"w")

for line in r:
 line=re.sub(r'(^.*thehive_button\\\",\\\"params\\\":{\\\"url\\\":\\\")[^\\"]*(.*apikey\\\":\\\")[^\\\"]*(.*owner\\\":\\\")[^\\"]*(.*$)',"\g<1>{{THEHIVE_URL}}\g<2>{{THEHIVE_API_KEY}}\g<3>{{THEHIVE_OWNER}}\g<4>",line)
 line=re.sub(r"(^.*)https:\/\/[^\/]*(.*destination\.ip_misp\.keyword.*$)","\g<1>{{misp_url}}\g<2>",line)
 w.write(line)

r.close()
w.close()