forked from webdog/honeypot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoneypot.py
43 lines (33 loc) · 880 Bytes
/
honeypot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
from flask import Flask, request, Response
import os
app = Flask(__name__)
#Get the hooks we want to monitor from the environment variables
def hk_envs():
vals = {}
for k, v in os.environ.items():
if "hk-" in k and v == "True":
vals[k] = v
else:
pass
return vals
# Assign to variable so we only call the environment once
hks_true = hk_envs()
@app.route('/')
def hello_world():
return "Nothing to see here. Move along."
@app.route('/receive', methods = ['POST'])
def process_post():
headers = request.headers
resp = Response(status=200, mimetype='application/json')
for k, v in headers.items():
if v not in hks_true:
return resp
else:
message = request.to_json()
return resp
@app.route('/receive', methods = ['GET'])
def receive_get():
return "Nothing to see here. Move along."
if __name__ == '__main__':
app.run()