forked from Kaliscuit/underflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
underflow.py
36 lines (30 loc) · 855 Bytes
/
underflow.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
import hashlib
from flask import Flask
from flask import render_template
from flask import request
app = Flask(__name__)
token = 'underflow'
@app.route('/')
def hello():
return 'Hello underflow'
@app.route('/auth', methods=['GET'])
def auth():
signature = request.args.get('signature')
timestamp = request.args.get('timestamp')
nonce = request.args.get('nonce')
echostr = request.args.get('echostr')
arg_list = [token, timestamp, nonce]
arg_list = sorted(arg_list)
arg_str = ''
for arg in arg_list:
arg_str += arg
arg_sha1 = hashlib.sha1()
arg_sha1.update(arg_str)
signature_server = arg_sha1.hexdigest()
if signature == signature_server:
return echostr
else:
return repr(signature+timestamp+nonce+echostr)
if __name__ == '__main__':
app.debug = True
app.run()