Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Authentication option over GET variable #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions MISP2CBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import hashlib
import socket
import re
from keys import misp_url, misp_key, misp_verifycert, misp_tag, proxies, flask_cert, flask_key, app_debug
from flask import Flask, Response
from keys import misp_url, misp_verifycert, misp_tag, proxies, flask_cert, flask_key, app_debug
from flask import Flask, Response, request
app = Flask(__name__)

__author__ = "Dennis Rand - eCrimeLabs"
Expand Down Expand Up @@ -72,7 +72,7 @@ def splash():
def init(misp_url, misp_key):
return PyMISP(misp_url, misp_key, misp_verifycert, 'json', debug=False, proxies=proxies)

def GetMISPData():
def GetMISPData(misp_key):
reports = {}
relative_path = 'attributes/restSearch'
body = {
Expand Down Expand Up @@ -143,8 +143,12 @@ def Build_CB_Feed(iocs_dns, iocs_ipv4, iocs_ipv6, iocs_md5, iocs_sha256):

@app.route("/")
def fetch_and_deliver():
feed = GetMISPData()
return Response(json.dumps(feed), mimetype='application/json')
misp_key = request.args.get('key', default=None, type=str)
if not misp_key:
return "Please use your MISP authentication key in the GET request to authenticate, ex. wget -k https://mymisp:8443?key=myauthenticationkey."
else:
feed = GetMISPData(misp_key)
return Response(json.dumps(feed), mimetype='application/json')



Expand Down