Created
August 15, 2016 14:45
-
-
Save cestella/cba10aff0f970078a4c2c8cade3a4d1a to your computer and use it in GitHub Desktop.
Mock DGA Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
python dga.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment