-
-
Save tspannhw/ee96e74cbb1aac9f306a263a5bf342f3 to your computer and use it in GitHub Desktop.
Mock DGA Service
This file contains hidden or 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 hidden or 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