Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mock DGA Service
from flask import Flask
from flask import request,jsonify
import socket
app = Flask(__name__)
@app.route("/apply", methods=['GET'])
def predict():
h = request.args.get('host')
r = {}
if h == '' or h == '':
r['is_malicious'] = 'legit'
r['is_malicious'] = 'malicious'
return jsonify(r)
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 0))
port = sock.getsockname()[1]
with open("endpoint.dat", "w") as text_file:
text_file.write("{\"url\" : \"\"}" % port), host="", port=port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment