Skip to content

Instantly share code, notes, and snippets.

@cestella
Created August 15, 2016 14:45
Show Gist options
  • Save cestella/cba10aff0f970078a4c2c8cade3a4d1a to your computer and use it in GitHub Desktop.
Save cestella/cba10aff0f970078a4c2c8cade3a4d1a to your computer and use it in GitHub Desktop.
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 == 'yahoo.com' or h == 'amazon.com':
r['is_malicious'] = 'legit'
else:
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]
sock.close()
with open("endpoint.dat", "w") as text_file:
text_file.write("{\"url\" : \"http://0.0.0.0:%d\"}" % port)
app.run(threaded=True, host="0.0.0.0", port=port)
#!/bin/bash
python dga.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment