-
Notifications
You must be signed in to change notification settings - Fork 0
/
dumpcare.py
executable file
·48 lines (35 loc) · 1.45 KB
/
dumpcare.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
42
43
44
45
46
47
48
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from flask import Flask, render_template, render_template_string, send_from_directory, request
import os
app = Flask(__name__, static_url_path='')
with open("flag.txt") as f:
app.secret_key = f.readline()
@app.route('/')
def root():
return app.send_static_file('index.html')
def goodbye(comment):
comment = render_template_string(comment)
return render_template("result.html", message=comment)
@app.route('/maga', methods=["POST"])
def check():
if not request.form['name']:
return goodbye("You didn't provide a name!")
if not request.form['phone']:
return goodbye("We need your phone number too!")
print("%-18s %s" % (request.remote_addr, request.form['phone']))
# sanitize phone number of special characters using a blacklist
phone = request.form['phone'].translate({ord(c): None for c in '+() -'})
# substring the first ten digits
phone = phone[:10]
if len(phone) < 10:
return goodbye("Your phone numbers can't be less than 10 digits!")
if not phone.isdigit():
return goodbye("\"" + phone + "\" is not a valid phone number. "
+ "Please try again and omit any symbols.")
return goodbye("Thank you! Trump is caring for you now.")
@app.route("/sauce")
def sauce():
return send_from_directory('./', 'dumpcare.py')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=os.getenv('PORT', 7777), threaded=True)