Skip to content

Instantly share code, notes, and snippets.

@ag-michael
Last active March 26, 2019 20:14
Show Gist options
  • Save ag-michael/8ab46263e3d24b8391b99c1c85522543 to your computer and use it in GitHub Desktop.
Save ag-michael/8ab46263e3d24b8391b99c1c85522543 to your computer and use it in GitHub Desktop.
Add a file as an observable
def thehive_alert(alert):
global CONFIG
authheader={'Content-Type': 'application/json', 'Authorization': 'Bearer '+CONFIG['thehiveapikey']}
print(requests.post("http://127.0.0.1:9000/api/alert",headers=authheader,data=json.dumps(alert),verify=False))
myfile=''
try:
with open(fname,"rb") as f:
myfile=fname+";text/plain;"+base64.b64encode(f.read())
except Exception:
pass
alert={
"title": "Your casetitle",
"description":"```\n"+"alert information""\n```",
"type": "SpearPhishing",
"source": "Your script",
"sourceRef": "Some email subject",
"severity":3,
"tlp":3,
"artifacts":[{"dataType":"mail","data":"hacker@malware.com","message":"email sender"},
{"dataType":"file","data":myfile,"message":"FireEye alert email body"}
],
"caseTemplate":"Secops default playbook"
}
thehive_alert(alert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment